Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
linux_perf_event.hh
1/*
2 * Copyright (C) 2021-present ScyllaDB
3 */
4
5/*
6 * This file is open source software, licensed to you under the terms
7 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
8 * distributed with this work for additional information regarding copyright
9 * ownership. You may not use this file except in compliance with the License.
10 *
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 */
22
23/*
24 * This file was copied from Scylla (https://github.com/scylladb/scylla)
25 */
26
27#pragma once
28
29
30#include <cstdint>
31#include <utility>
32#include <unistd.h>
33
34struct perf_event_attr; // from <linux/perf_event.h>
35
37 int _fd = -1;
38public:
39 linux_perf_event(const struct ::perf_event_attr& attr, pid_t pid, int cpu, int group_fd, unsigned long flags);
40 linux_perf_event(linux_perf_event&& x) noexcept : _fd(std::exchange(x._fd, -1)) {}
41 linux_perf_event& operator=(linux_perf_event&& x) noexcept;
43 uint64_t read();
44 void enable();
45 void disable();
46public:
47 static linux_perf_event user_instructions_retired();
48 static linux_perf_event user_cpu_cycles_retired();
49};
50
Definition: linux_perf_event.hh:36