Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161036AbWLTX6H (ORCPT ); Wed, 20 Dec 2006 18:58:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1161030AbWLTX6G (ORCPT ); Wed, 20 Dec 2006 18:58:06 -0500 Received: from tomts43.bellnexxia.net ([209.226.175.110]:57501 "EHLO tomts43-srv.bellnexxia.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161038AbWLTX6E (ORCPT ); Wed, 20 Dec 2006 18:58:04 -0500 X-Greylist: delayed 346 seconds by postgrey-1.27 at vger.kernel.org; Wed, 20 Dec 2006 18:58:04 EST Date: Wed, 20 Dec 2006 18:57:57 -0500 From: Mathieu Desnoyers To: linux-kernel@vger.kernel.org, Andrew Morton , Ingo Molnar , Greg Kroah-Hartman , Christoph Hellwig Cc: ltt-dev@shafik.org, systemtap@sources.redhat.com, Douglas Niehaus , "Martin J. Bligh" , Thomas Gleixner Subject: [PATCH 1/4] Linux Kernel Markers : Architecture agnostic code. Message-ID: <20061220235757.GB28643@Krystal> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <20061220235216.GA28643@Krystal> X-Editor: vi X-Info: http://krystal.dyndns.org:8080 X-Operating-System: Linux/2.4.32-grsec (i686) X-Uptime: 18:56:35 up 119 days, 21:04, 6 users, load average: 0.63, 0.92, 0.80 User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 12559 Lines: 512 Linux Kernel Markers, architecture independant code. This patch also includes non-optimized default behavior from asm-generic in each architecture where the optimised support is not implemented. Signed-off-by: Mathieu Desnoyers --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -118,6 +118,14 @@ #define RODATA \ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ *(__ksymtab_strings) \ } \ + /* Kernel markers : pointers */ \ + .markers : AT(ADDR(.markers) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__start___markers) = .; \ + *(.markers) \ + VMLINUX_SYMBOL(__stop___markers) = .; \ + } \ + __end_rodata = .; \ + . = ALIGN(4096); \ \ /* Built-in module parameters. */ \ __param : AT(ADDR(__param) - LOAD_OFFSET) { \ --- /dev/null +++ b/kernel/Kconfig.marker @@ -0,0 +1,17 @@ +# Code markers configuration + +config MARKERS + bool "Activate markers" + select MODULES + default n + help + Place an empty function call at each marker site. Can be + dynamically changed for a probe function. + +config MARKERS_DISABLE_OPTIMIZATION + bool "Disable architecture specific marker optimization" + depends EMBEDDED + default n + help + Disable code replacement jump optimisations. Especially useful if your + code is in a read-only rom/flash. --- a/include/linux/module.h +++ b/include/linux/module.h @@ -356,6 +356,9 @@ #endif /* The command line arguments (may be mangled). People like keeping pointers to this stuff */ char *args; + + const struct __mark_marker *markers; + unsigned int num_markers; }; /* FIXME: It'd be nice to isolate modules during init, too, so they @@ -469,6 +472,7 @@ extern void print_modules(void); struct device_driver; void module_add_driver(struct module *, struct device_driver *); void module_remove_driver(struct device_driver *); +extern void list_modules(void); #else /* !CONFIG_MODULES... */ #define EXPORT_SYMBOL(sym) --- /dev/null +++ b/include/linux/marker.h @@ -0,0 +1,65 @@ +#ifndef _LINUX_MARKER_H +#define _LINUX_MARKER_H + +/* + * marker.h + * + * Code markup for dynamic and static tracing. + * + * Example : + * + * MARK(subsystem_event, "%d %s", someint, somestring); + * Where : + * - Subsystem is the name of your subsystem. + * - event is the name of the event to mark. + * - "%d %s" is the formatted string for printk. + * - someint is an integer. + * - somestring is a char *. + * + * - Dynamically overridable function call based on marker mechanism + * from Frank Ch. Eigler . + * - Thanks to Jeremy Fitzhardinge for his constructive + * criticism about gcc optimization related issues. + * + * The marker mechanism supports multiple instances of the same marker. + * Markers can be put in inline functions, inlined static functions and + * unrolled loops. + * + * (C) Copyright 2006 Mathieu Desnoyers + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#ifndef __ASSEMBLY__ + +typedef void marker_probe_func(const char *fmt, ...); + +#ifndef CONFIG_MARKERS_DISABLE_OPTIMIZATION +#include +#else +#include +#endif + +#define MARK_NOARGS " " +#define MARK_MAX_FORMAT_LEN 1024 + +#ifndef CONFIG_MARKERS +#define MARK(name, format, args...) \ + __mark_check_format(format, ## args) +#endif + +static inline __attribute__ ((format (printf, 1, 2))) +void __mark_check_format(const char *fmt, ...) +{ } + +extern marker_probe_func __mark_empty_function; + +extern int marker_set_probe(const char *name, const char *format, + marker_probe_func *probe); + +extern int marker_remove_probe(marker_probe_func *probe); +extern int marker_list_probe(marker_probe_func *probe); + +#endif +#endif --- /dev/null +++ b/include/asm-arm/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-cris/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-frv/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-generic/marker.h @@ -0,0 +1,49 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Generic header. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + * + * Note : the empty asm volatile with read constraint is used here instead of a + * "used" attribute to fix a gcc 4.1.x bug. + */ + +struct __mark_marker_c { + const char *name; + marker_probe_func **call; + const char *format; +} __attribute__((packed)); + +struct __mark_marker { + const struct __mark_marker_c *cmark; + volatile char *enable; +} __attribute__((packed)); + +#ifdef CONFIG_MARKERS + +#define MARK(name, format, args...) \ + do { \ + static marker_probe_func *__mark_call_##name = \ + __mark_empty_function; \ + volatile static char __marker_enable_##name = 0; \ + static const struct __mark_marker_c __mark_c_##name \ + __attribute__((section(".markers.c"))) = \ + { #name, &__mark_call_##name, format } ; \ + static const struct __mark_marker __mark_##name \ + __attribute__((section(".markers"))) = \ + { &__mark_c_##name, &__marker_enable_##name } ; \ + asm volatile ( "" : : "i" (&__mark_##name)); \ + __mark_check_format(format, ## args); \ + if (unlikely(__marker_enable_##name)) { \ + preempt_disable(); \ + (*__mark_call_##name)(format, ## args); \ + preempt_enable_no_resched(); \ + } \ + } while (0) + + +#define MARK_ENABLE_IMMEDIATE_OFFSET 0 + +#endif --- /dev/null +++ b/include/asm-h8300/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-ia64/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-m32r/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-m68k/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-m68knommu/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-mips/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-parisc/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-ppc/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-s390/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-sh64/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-sh/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-sparc64/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-sparc/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-um/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-v850/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-x86_64/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include --- /dev/null +++ b/include/asm-xtensa/marker.h @@ -0,0 +1,13 @@ +/* + * marker.h + * + * Code markup for dynamic and static tracing. Architecture specific + * optimisations. + * + * No optimisation implemented. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include OpenPGP public key: http://krystal.dyndns.org:8080/key/compudj.gpg Key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/