Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31155bc0 authored by Mathieu Desnoyers's avatar Mathieu Desnoyers Committed by Linus Torvalds
Browse files

Linux Kernel Markers - Samples



Module example showing how to use the Linux Kernel Markers.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 267c4025
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -61,7 +61,6 @@ struct marker {
		__attribute__((section("__markers"), aligned(8))) =	\
		__attribute__((section("__markers"), aligned(8))) =	\
		{ __mstrtab_name_##name, __mstrtab_format_##name,	\
		{ __mstrtab_name_##name, __mstrtab_format_##name,	\
		0, __mark_empty_function, NULL };			\
		0, __mark_empty_function, NULL };			\
		asm volatile("" : : "i" (&__mark_##name));		\
		__mark_check_format(format, ## args);			\
		__mark_check_format(format, ## args);			\
		if (unlikely(__mark_##name.state)) {			\
		if (unlikely(__mark_##name.state)) {			\
			preempt_disable();				\
			preempt_disable();				\
+5 −0
Original line number Original line Diff line number Diff line
@@ -7,5 +7,10 @@ menuconfig SAMPLES


if SAMPLES
if SAMPLES


config SAMPLE_MARKERS
	tristate "Build markers examples -- loadable modules only"
	depends on MARKERS && m
	help
	  This build markers example modules.


endif # SAMPLES
endif # SAMPLES

samples/Makefile

0 → 100644
+3 −0
Original line number Original line Diff line number Diff line
# Makefile for Linux samples code

obj-$(CONFIG_SAMPLES)	+= markers/
+4 −0
Original line number Original line Diff line number Diff line
# builds the kprobes example kernel modules;
# then to use one (as root):  insmod <module_name.ko>

obj-$(CONFIG_SAMPLE_MARKERS) += probe-example.o marker-example.o
+54 −0
Original line number Original line Diff line number Diff line
/* marker-example.c
 *
 * Executes a marker when /proc/marker-example is opened.
 *
 * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
 *
 * This file is released under the GPLv2.
 * See the file COPYING for more details.
 */

#include <linux/module.h>
#include <linux/marker.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>

struct proc_dir_entry *pentry_example;

static int my_open(struct inode *inode, struct file *file)
{
	int i;

	trace_mark(subsystem_event, "%d %s", 123, "example string");
	for (i = 0; i < 10; i++)
		trace_mark(subsystem_eventb, MARK_NOARGS);
	return -EPERM;
}

static struct file_operations mark_ops = {
	.open = my_open,
};

static int example_init(void)
{
	printk(KERN_ALERT "example init\n");
	pentry_example = create_proc_entry("marker-example", 0444, NULL);
	if (pentry_example)
		pentry_example->proc_fops = &mark_ops;
	else
		return -EPERM;
	return 0;
}

static void example_exit(void)
{
	printk(KERN_ALERT "example exit\n");
	remove_proc_entry("marker-example", NULL);
}

module_init(example_init)
module_exit(example_exit)

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mathieu Desnoyers");
MODULE_DESCRIPTION("Marker example");
Loading