cregit-Linux how code gets into the kernel

Release 4.15 kernel/trace/trace_sched_switch.c

Directory: kernel/trace
// SPDX-License-Identifier: GPL-2.0
/*
 * trace context switch
 *
 * Copyright (C) 2007 Steven Rostedt <srostedt@redhat.com>
 *
 */
#include <linux/module.h>
#include <linux/kallsyms.h>
#include <linux/uaccess.h>
#include <linux/ftrace.h>
#include <trace/events/sched.h>

#include "trace.h"


#define RECORD_CMDLINE	1

#define RECORD_TGID	2


static int		sched_cmdline_ref;

static int		sched_tgid_ref;
static DEFINE_MUTEX(sched_register_mutex);


static void probe_sched_switch(void *ignore, bool preempt, struct task_struct *prev, struct task_struct *next) { int flags; flags = (RECORD_TGID * !!sched_tgid_ref) + (RECORD_CMDLINE * !!sched_cmdline_ref); if (!flags) return; tracing_record_taskinfo_sched_switch(prev, next, flags); }

Contributors

PersonTokensPropCommitsCommitProp
Joel Fernandes2644.07%116.67%
Steven Rostedt2338.98%350.00%
Mathieu Desnoyers711.86%116.67%
Peter Zijlstra35.08%116.67%
Total59100.00%6100.00%


static void probe_sched_wakeup(void *ignore, struct task_struct *wakee) { int flags; flags = (RECORD_TGID * !!sched_tgid_ref) + (RECORD_CMDLINE * !!sched_cmdline_ref); if (!flags) return; tracing_record_taskinfo(current, flags); }

Contributors

PersonTokensPropCommitsCommitProp
Joel Fernandes2551.02%114.29%
Ingo Molnar1428.57%228.57%
Mathieu Desnoyers510.20%228.57%
Steven Rostedt48.16%114.29%
Zhao Lei12.04%114.29%
Total49100.00%7100.00%


static int tracing_sched_register(void) { int ret; ret = register_trace_sched_wakeup(probe_sched_wakeup, NULL); if (ret) { pr_info("wakeup trace: Couldn't activate tracepoint" " probe to kernel_sched_wakeup\n"); return ret; } ret = register_trace_sched_wakeup_new(probe_sched_wakeup, NULL); if (ret) { pr_info("wakeup trace: Couldn't activate tracepoint" " probe to kernel_sched_wakeup_new\n"); goto fail_deprobe; } ret = register_trace_sched_switch(probe_sched_switch, NULL); if (ret) { pr_info("sched trace: Couldn't activate tracepoint" " probe to kernel_sched_switch\n"); goto fail_deprobe_wake_new; } return ret; fail_deprobe_wake_new: unregister_trace_sched_wakeup_new(probe_sched_wakeup, NULL); fail_deprobe: unregister_trace_sched_wakeup(probe_sched_wakeup, NULL); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Mathieu Desnoyers9689.72%250.00%
Steven Rostedt109.35%125.00%
Wenji Huang10.93%125.00%
Total107100.00%4100.00%


static void tracing_sched_unregister(void) { unregister_trace_sched_switch(probe_sched_switch, NULL); unregister_trace_sched_wakeup_new(probe_sched_wakeup, NULL); unregister_trace_sched_wakeup(probe_sched_wakeup, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Mathieu Desnoyers2379.31%266.67%
Steven Rostedt620.69%133.33%
Total29100.00%3100.00%


static void tracing_start_sched_switch(int ops) { bool sched_register = (!sched_cmdline_ref && !sched_tgid_ref); mutex_lock(&sched_register_mutex); switch (ops) { case RECORD_CMDLINE: sched_cmdline_ref++; break; case RECORD_TGID: sched_tgid_ref++; break; } if (sched_register && (sched_cmdline_ref || sched_tgid_ref)) tracing_sched_register(); mutex_unlock(&sched_register_mutex); }

Contributors

PersonTokensPropCommitsCommitProp
Joel Fernandes3858.46%120.00%
Frédéric Weisbecker1726.15%240.00%
Mathieu Desnoyers913.85%120.00%
Ingo Molnar11.54%120.00%
Total65100.00%5100.00%


static void tracing_stop_sched_switch(int ops) { mutex_lock(&sched_register_mutex); switch (ops) { case RECORD_CMDLINE: sched_cmdline_ref--; break; case RECORD_TGID: sched_tgid_ref--; break; } if (!sched_cmdline_ref && !sched_tgid_ref) tracing_sched_unregister(); mutex_unlock(&sched_register_mutex); }

Contributors

PersonTokensPropCommitsCommitProp
Joel Fernandes2650.00%120.00%
Mathieu Desnoyers1426.92%120.00%
Frédéric Weisbecker1121.15%240.00%
Ingo Molnar11.92%120.00%
Total52100.00%5100.00%


void tracing_start_cmdline_record(void) { tracing_start_sched_switch(RECORD_CMDLINE); }

Contributors

PersonTokensPropCommitsCommitProp
Steven Rostedt975.00%150.00%
Joel Fernandes325.00%150.00%
Total12100.00%2100.00%


void tracing_stop_cmdline_record(void) { tracing_stop_sched_switch(RECORD_CMDLINE); }

Contributors

PersonTokensPropCommitsCommitProp
Steven Rostedt758.33%150.00%
Joel Fernandes541.67%150.00%
Total12100.00%2100.00%


void tracing_start_tgid_record(void) { tracing_start_sched_switch(RECORD_TGID); }

Contributors

PersonTokensPropCommitsCommitProp
Joel Fernandes12100.00%1100.00%
Total12100.00%1100.00%


void tracing_stop_tgid_record(void) { tracing_stop_sched_switch(RECORD_TGID); }

Contributors

PersonTokensPropCommitsCommitProp
Joel Fernandes1083.33%150.00%
Steven Rostedt216.67%150.00%
Total12100.00%2100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Joel Fernandes15835.03%16.25%
Mathieu Desnoyers15734.81%212.50%
Steven Rostedt7917.52%425.00%
Frédéric Weisbecker357.76%212.50%
Ingo Molnar163.55%318.75%
Peter Zijlstra30.67%16.25%
Wenji Huang10.22%16.25%
Zhao Lei10.22%16.25%
Greg Kroah-Hartman10.22%16.25%
Total451100.00%16100.00%
Directory: kernel/trace
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.