Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: LGPL-2.1
0002 /*
0003  * Copyright (C) 2015 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
0004  */
0005 #include <stdio.h>
0006 #include <stdlib.h>
0007 #include <string.h>
0008 
0009 #include "event-parse.h"
0010 
0011 enum tlb_flush_reason {
0012     TLB_FLUSH_ON_TASK_SWITCH,
0013     TLB_REMOTE_SHOOTDOWN,
0014     TLB_LOCAL_SHOOTDOWN,
0015     TLB_LOCAL_MM_SHOOTDOWN,
0016     NR_TLB_FLUSH_REASONS,
0017 };
0018 
0019 static int tlb_flush_handler(struct trace_seq *s, struct tep_record *record,
0020                  struct tep_event *event, void *context)
0021 {
0022     unsigned long long val;
0023 
0024     trace_seq_printf(s, "pages=");
0025 
0026     tep_print_num_field(s, "%ld", event, "pages", record, 1);
0027 
0028     if (tep_get_field_val(s, event, "reason", record, &val, 1) < 0)
0029         return -1;
0030 
0031     trace_seq_puts(s, " reason=");
0032 
0033     switch (val) {
0034     case TLB_FLUSH_ON_TASK_SWITCH:
0035         trace_seq_puts(s, "flush on task switch");
0036         break;
0037     case TLB_REMOTE_SHOOTDOWN:
0038         trace_seq_puts(s, "remote shootdown");
0039         break;
0040     case TLB_LOCAL_SHOOTDOWN:
0041         trace_seq_puts(s, "local shootdown");
0042         break;
0043     case TLB_LOCAL_MM_SHOOTDOWN:
0044         trace_seq_puts(s, "local mm shootdown");
0045         break;
0046     }
0047 
0048     trace_seq_printf(s, " (%lld)", val);
0049 
0050     return 0;
0051 }
0052 
0053 int TEP_PLUGIN_LOADER(struct tep_handle *tep)
0054 {
0055     tep_register_event_handler(tep, -1, "tlb", "tlb_flush",
0056                    tlb_flush_handler, NULL);
0057 
0058     return 0;
0059 }
0060 
0061 void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
0062 {
0063     tep_unregister_event_handler(tep, -1,
0064                      "tlb", "tlb_flush",
0065                      tlb_flush_handler, NULL);
0066 }