Linux Audio

Check our new training course

Embedded Linux training

Mar 31-Apr 8, 2025
Register
Loading...
Note: File does not exist in v3.15.
 1// SPDX-License-Identifier: LGPL-2.1
 2/*
 3 * Copyright (C) 2015 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
 4 */
 5#include <stdio.h>
 6#include <stdlib.h>
 7#include <string.h>
 8
 9#include "event-parse.h"
10
11enum tlb_flush_reason {
12	TLB_FLUSH_ON_TASK_SWITCH,
13	TLB_REMOTE_SHOOTDOWN,
14	TLB_LOCAL_SHOOTDOWN,
15	TLB_LOCAL_MM_SHOOTDOWN,
16	NR_TLB_FLUSH_REASONS,
17};
18
19static int tlb_flush_handler(struct trace_seq *s, struct tep_record *record,
20			     struct tep_event *event, void *context)
21{
22	unsigned long long val;
23
24	trace_seq_printf(s, "pages=");
25
26	tep_print_num_field(s, "%ld", event, "pages", record, 1);
27
28	if (tep_get_field_val(s, event, "reason", record, &val, 1) < 0)
29		return -1;
30
31	trace_seq_puts(s, " reason=");
32
33	switch (val) {
34	case TLB_FLUSH_ON_TASK_SWITCH:
35		trace_seq_puts(s, "flush on task switch");
36		break;
37	case TLB_REMOTE_SHOOTDOWN:
38		trace_seq_puts(s, "remote shootdown");
39		break;
40	case TLB_LOCAL_SHOOTDOWN:
41		trace_seq_puts(s, "local shootdown");
42		break;
43	case TLB_LOCAL_MM_SHOOTDOWN:
44		trace_seq_puts(s, "local mm shootdown");
45		break;
46	}
47
48	trace_seq_printf(s, " (%lld)", val);
49
50	return 0;
51}
52
53int TEP_PLUGIN_LOADER(struct tep_handle *tep)
54{
55	tep_register_event_handler(tep, -1, "tlb", "tlb_flush",
56				   tlb_flush_handler, NULL);
57
58	return 0;
59}
60
61void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
62{
63	tep_unregister_event_handler(tep, -1,
64				     "tlb", "tlb_flush",
65				     tlb_flush_handler, NULL);
66}