File Index
Files and directories
Sign in
FILE

pagefault.c

File preview with syntax highlighting.

linux-6.19.14/kernel/trace/rv/monitors/pagefault/pagefault.c C
 1// SPDX-License-Identifier: GPL-2.0
 2#include <linux/ftrace.h>
 3#include <linux/init.h>
 4#include <linux/kernel.h>
 5#include <linux/module.h>
 6#include <linux/rv.h>
 7#include <linux/sched/deadline.h>
 8#include <linux/sched/rt.h>
 9#include <linux/tracepoint.h>
10#include <rv/instrumentation.h>
11
12#define MODULE_NAME "pagefault"
13
14#include <rv_trace.h>
15#include <trace/events/exceptions.h>
16#include <monitors/rtapp/rtapp.h>
17
18#include "pagefault.h"
19#include <rv/ltl_monitor.h>
20
21static void ltl_atoms_fetch(struct task_struct *task, struct ltl_monitor *mon)
22{
23	/*
24	 * This includes "actual" real-time tasks and also PI-boosted
25	 * tasks. A task being PI-boosted means it is blocking an "actual"
26	 * real-task, therefore it should also obey the monitor's rule,
27	 * otherwise the "actual" real-task may be delayed.
28	 */
29	ltl_atom_set(mon, LTL_RT, rt_or_dl_task(task));
30}
31
32static void ltl_atoms_init(struct task_struct *task, struct ltl_monitor *mon, bool task_creation)
33{
34	if (task_creation)
35		ltl_atom_set(mon, LTL_PAGEFAULT, false);
36}
37
38static void handle_page_fault(void *data, unsigned long address, struct pt_regs *regs,
39			      unsigned long error_code)
40{
41	ltl_atom_pulse(current, LTL_PAGEFAULT, true);
42}
43
44static int enable_pagefault(void)
45{
46	int retval;
47
48	retval = ltl_monitor_init();
49	if (retval)
50		return retval;
51
52	rv_attach_trace_probe("rtapp_pagefault", page_fault_kernel, handle_page_fault);
53	rv_attach_trace_probe("rtapp_pagefault", page_fault_user, handle_page_fault);
54
55	return 0;
56}
57
58static void disable_pagefault(void)
59{
60	rv_detach_trace_probe("rtapp_pagefault", page_fault_kernel, handle_page_fault);
61	rv_detach_trace_probe("rtapp_pagefault", page_fault_user, handle_page_fault);
62
63	ltl_monitor_destroy();
64}
65
66static struct rv_monitor rv_pagefault = {
67	.name = "pagefault",
68	.description = "Monitor that RT tasks do not raise page faults",
69	.enable = enable_pagefault,
70	.disable = disable_pagefault,
71};
72
73static int __init register_pagefault(void)
74{
75	return rv_register_monitor(&rv_pagefault, &rv_rtapp);
76}
77
78static void __exit unregister_pagefault(void)
79{
80	rv_unregister_monitor(&rv_pagefault);
81}
82
83module_init(register_pagefault);
84module_exit(unregister_pagefault);
85
86MODULE_LICENSE("GPL");
87MODULE_AUTHOR("Nam Cao <namcao@linutronix.de>");
88MODULE_DESCRIPTION("pagefault: Monitor that RT tasks do not raise page faults");
~/ Read-only file preview.