* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
From: H. Peter Anvin @ 2010-06-23 15:51 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Christoph Lameter, WANG Cong, Heiko Carstens, Oleg Nesterov,
linuxppc-dev, Paul Mackerras, Sam Ravnborg, Andi Kleen,
Mike Frysinger, Eric Dumazet, Jeff Moyer, Ingo Molnar,
KOSAKI Motohiro, David Rientjes, Ingo Molnar, Arnd Bergmann,
Steven Rostedt, Ian Munsie, Thomas Gleixner, Johannes Berg,
Roland McGrath, Lee Schermerhorn, Arnaldo Carvalho de Melo,
Neil Horman, linux-mm, netdev, Jason Baron, Greg Kroah-Hartman,
Roel Kluin, linux-kernel, kexec, Eric Biederman, linux-fsdevel,
Simon Kagstrom, Andrew Morton, David S. Miller, Alexander Viro
In-Reply-To: <20100623113806.GD5242@nowhere>
On 06/23/2010 04:38 AM, Frederic Weisbecker wrote:
>
> I haven't heard any complains about existing syscalls wrappers.
>
Then you truly haven't been listening.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply
* [PATCH v3 2/2] powerpc: add support for new hcall H_BEST_ENERGY
From: Vaidyanathan Srinivasan @ 2010-06-23 6:04 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Anton Blanchard; +Cc: linuxppc-dev
In-Reply-To: <20100623060122.4957.33819.stgit@drishya.in.ibm.com>
Create sysfs interface to export data from H_BEST_ENERGY hcall
that can be used by administrative tools on supported pseries
platforms for energy management optimizations.
/sys/device/system/cpu/pseries_(de)activate_hint_list and
/sys/device/system/cpu/cpuN/pseries_(de)activate_hint will provide
hints for activation and deactivation of cpus respectively.
Added new driver module
arch/powerpc/platforms/pseries/pseries_energy.c
under new config option CONFIG_PSERIES_ENERGY
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/hvcall.h | 3
arch/powerpc/platforms/pseries/Kconfig | 10 +
arch/powerpc/platforms/pseries/Makefile | 1
arch/powerpc/platforms/pseries/pseries_energy.c | 258 +++++++++++++++++++++++
4 files changed, 271 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/platforms/pseries/pseries_energy.c
diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h
index 5119b7d..34b66e0 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -231,7 +231,8 @@
#define H_GET_EM_PARMS 0x2B8
#define H_SET_MPP 0x2D0
#define H_GET_MPP 0x2D4
-#define MAX_HCALL_OPCODE H_GET_MPP
+#define H_BEST_ENERGY 0x2F4
+#define MAX_HCALL_OPCODE H_BEST_ENERGY
#ifndef __ASSEMBLY__
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
index c667f0f..b3dd108 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -33,6 +33,16 @@ config PSERIES_MSI
depends on PCI_MSI && EEH
default y
+config PSERIES_ENERGY
+ tristate "pseries energy management capabilities driver"
+ depends on PPC_PSERIES
+ default y
+ help
+ Provides interface to platform energy management capabilities
+ on supported PSERIES platforms.
+ Provides: /sys/devices/system/cpu/pseries_(de)activation_hint_list
+ and /sys/devices/system/cpu/cpuN/pseries_(de)activation_hint
+
config SCANLOG
tristate "Scanlog dump interface"
depends on RTAS_PROC && PPC_PSERIES
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 3dbef30..32ae72e 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_EEH) += eeh.o eeh_cache.o eeh_driver.o eeh_event.o eeh_sysfs.o
obj-$(CONFIG_KEXEC) += kexec.o
obj-$(CONFIG_PCI) += pci.o pci_dlpar.o
obj-$(CONFIG_PSERIES_MSI) += msi.o
+obj-$(CONFIG_PSERIES_ENERGY) += pseries_energy.o
obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o
obj-$(CONFIG_MEMORY_HOTPLUG) += hotplug-memory.o
diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c
new file mode 100644
index 0000000..9a936b1
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/pseries_energy.c
@@ -0,0 +1,258 @@
+/*
+ * POWER platform energy management driver
+ * Copyright (C) 2010 IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This pseries platform device driver provides access to
+ * platform energy management capabilities.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/seq_file.h>
+#include <linux/sysdev.h>
+#include <linux/cpu.h>
+#include <linux/of.h>
+#include <asm/cputhreads.h>
+#include <asm/page.h>
+#include <asm/hvcall.h>
+
+
+#define MODULE_VERS "1.0"
+#define MODULE_NAME "pseries_energy"
+
+/* Helper Routines to convert between drc_index to cpu numbers */
+
+static u32 cpu_to_drc_index(int cpu)
+{
+ struct device_node *dn = NULL;
+ const int *indexes;
+ int i;
+ dn = of_find_node_by_path("/cpus");
+ if (dn == NULL)
+ goto err;
+ indexes = of_get_property(dn, "ibm,drc-indexes", NULL);
+ if (indexes == NULL)
+ goto err;
+ /* Convert logical cpu number to core number */
+ i = cpu_core_of_thread(cpu);
+ /*
+ * The first element indexes[0] is the number of drc_indexes
+ * returned in the list. Hence i+1 will get the drc_index
+ * corresponding to core number i.
+ */
+ WARN_ON(i > indexes[0]);
+ return indexes[i + 1];
+err:
+ printk(KERN_WARNING "cpu_to_drc_index(%d) failed", cpu);
+ return 0;
+}
+
+static int drc_index_to_cpu(u32 drc_index)
+{
+ struct device_node *dn = NULL;
+ const int *indexes;
+ int i, cpu;
+ dn = of_find_node_by_path("/cpus");
+ if (dn == NULL)
+ goto err;
+ indexes = of_get_property(dn, "ibm,drc-indexes", NULL);
+ if (indexes == NULL)
+ goto err;
+ /*
+ * First element in the array is the number of drc_indexes
+ * returned. Search through the list to find the matching
+ * drc_index and get the core number
+ */
+ for (i = 0; i < indexes[0]; i++) {
+ if (indexes[i + 1] == drc_index)
+ break;
+ }
+ /* Convert core number to logical cpu number */
+ cpu = cpu_first_thread_of_core(i);
+ return cpu;
+err:
+ printk(KERN_WARNING "drc_index_to_cpu(%d) failed", drc_index);
+ return 0;
+}
+
+/*
+ * pseries hypervisor call H_BEST_ENERGY provides hints to OS on
+ * preferred logical cpus to activate or deactivate for optimized
+ * energy consumption.
+ */
+
+#define FLAGS_MODE1 0x004E200000080E01
+#define FLAGS_MODE2 0x004E200000080401
+#define FLAGS_ACTIVATE 0x100
+
+static ssize_t get_best_energy_list(char *page, int activate)
+{
+ int rc, cnt, i, cpu;
+ unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
+ unsigned long flags = 0;
+ u32 *buf_page;
+ char *s = page;
+
+ buf_page = (u32 *) get_zeroed_page(GFP_KERNEL);
+ if (!buf_page)
+ return -ENOMEM;
+
+ flags = FLAGS_MODE1;
+ if (activate)
+ flags |= FLAGS_ACTIVATE;
+
+ rc = plpar_hcall9(H_BEST_ENERGY, retbuf, flags, 0, __pa(buf_page),
+ 0, 0, 0, 0, 0, 0);
+ if (rc != H_SUCCESS) {
+ free_page((unsigned long) buf_page);
+ return -EINVAL;
+ }
+
+ cnt = retbuf[0];
+ for (i = 0; i < cnt; i++) {
+ cpu = drc_index_to_cpu(buf_page[2*i+1]);
+ if ((cpu_online(cpu) && !activate) ||
+ (!cpu_online(cpu) && activate))
+ s += sprintf(s, "%d,", cpu);
+ }
+ if (s > page) { /* Something to show */
+ s--; /* Suppress last comma */
+ s += sprintf(s, "\n");
+ }
+
+ free_page((unsigned long) buf_page);
+ return s-page;
+}
+
+static ssize_t get_best_energy_data(struct sys_device *dev,
+ char *page, int activate)
+{
+ int rc;
+ unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
+ unsigned long flags = 0;
+
+ flags = FLAGS_MODE2;
+ if (activate)
+ flags |= FLAGS_ACTIVATE;
+
+ rc = plpar_hcall9(H_BEST_ENERGY, retbuf, flags,
+ cpu_to_drc_index(dev->id),
+ 0, 0, 0, 0, 0, 0, 0);
+
+ if (rc != H_SUCCESS)
+ return -EINVAL;
+
+ return sprintf(page, "%lu\n", retbuf[1] >> 32);
+}
+
+/* Wrapper functions */
+
+static ssize_t cpu_activate_hint_list_show(struct sysdev_class *class,
+ struct sysdev_class_attribute *attr, char *page)
+{
+ return get_best_energy_list(page, 1);
+}
+
+static ssize_t cpu_deactivate_hint_list_show(struct sysdev_class *class,
+ struct sysdev_class_attribute *attr, char *page)
+{
+ return get_best_energy_list(page, 0);
+}
+
+static ssize_t percpu_activate_hint_show(struct sys_device *dev,
+ struct sysdev_attribute *attr, char *page)
+{
+ return get_best_energy_data(dev, page, 1);
+}
+
+static ssize_t percpu_deactivate_hint_show(struct sys_device *dev,
+ struct sysdev_attribute *attr, char *page)
+{
+ return get_best_energy_data(dev, page, 0);
+}
+
+/*
+ * Create sysfs interface:
+ * /sys/devices/system/cpu/pseries_activate_hint_list
+ * /sys/devices/system/cpu/pseries_deactivate_hint_list
+ * Comma separated list of cpus to activate or deactivate
+ * /sys/devices/system/cpu/cpuN/pseries_activate_hint
+ * /sys/devices/system/cpu/cpuN/pseries_deactivate_hint
+ * Per-cpu value of the hint
+ */
+
+struct sysdev_class_attribute attr_cpu_activate_hint_list =
+ _SYSDEV_CLASS_ATTR(pseries_activate_hint_list, 0444,
+ cpu_activate_hint_list_show, NULL);
+
+struct sysdev_class_attribute attr_cpu_deactivate_hint_list =
+ _SYSDEV_CLASS_ATTR(pseries_deactivate_hint_list, 0444,
+ cpu_deactivate_hint_list_show, NULL);
+
+struct sysdev_attribute attr_percpu_activate_hint =
+ _SYSDEV_ATTR(pseries_activate_hint, 0444,
+ percpu_activate_hint_show, NULL);
+
+struct sysdev_attribute attr_percpu_deactivate_hint =
+ _SYSDEV_ATTR(pseries_deactivate_hint, 0444,
+ percpu_deactivate_hint_show, NULL);
+
+static int __init pseries_energy_init(void)
+{
+ int cpu, err;
+ struct sys_device *cpu_sys_dev;
+
+ /* Create the sysfs files */
+ err = sysfs_create_file(&cpu_sysdev_class.kset.kobj,
+ &attr_cpu_activate_hint_list.attr);
+ if (!err)
+ err = sysfs_create_file(&cpu_sysdev_class.kset.kobj,
+ &attr_cpu_deactivate_hint_list.attr);
+
+ for_each_possible_cpu(cpu) {
+ cpu_sys_dev = get_cpu_sysdev(cpu);
+ err = sysfs_create_file(&cpu_sys_dev->kobj,
+ &attr_percpu_activate_hint.attr);
+ if (err)
+ break;
+ err = sysfs_create_file(&cpu_sys_dev->kobj,
+ &attr_percpu_deactivate_hint.attr);
+ if (err)
+ break;
+ }
+ return err;
+
+}
+
+static void __exit pseries_energy_cleanup(void)
+{
+ int cpu;
+ struct sys_device *cpu_sys_dev;
+
+ /* Remove the sysfs files */
+ sysfs_remove_file(&cpu_sysdev_class.kset.kobj,
+ &attr_cpu_activate_hint_list.attr);
+
+ sysfs_remove_file(&cpu_sysdev_class.kset.kobj,
+ &attr_cpu_deactivate_hint_list.attr);
+
+ for_each_possible_cpu(cpu) {
+ cpu_sys_dev = get_cpu_sysdev(cpu);
+ sysfs_remove_file(&cpu_sys_dev->kobj,
+ &attr_percpu_activate_hint.attr);
+ sysfs_remove_file(&cpu_sys_dev->kobj,
+ &attr_percpu_deactivate_hint.attr);
+ }
+}
+
+module_init(pseries_energy_init);
+module_exit(pseries_energy_cleanup);
+MODULE_DESCRIPTION("Driver for pseries platform energy management");
+MODULE_AUTHOR("Vaidyanathan Srinivasan");
+MODULE_LICENSE("GPL");
^ permalink raw reply related
* [PATCH v3 1/2] powerpc: cleanup APIs for cpu/thread/core mappings
From: Vaidyanathan Srinivasan @ 2010-06-23 6:04 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Anton Blanchard; +Cc: linuxppc-dev
In-Reply-To: <20100623060122.4957.33819.stgit@drishya.in.ibm.com>
These APIs take logical cpu number as input
Change cpu_first_thread_in_core() to cpu_leftmost_thread_sibling()
Change cpu_last_thread_in_core() to cpu_rightmost_thread_sibling()
These APIs convert core number (index) to logical cpu/thread numbers
Add cpu_first_thread_of_core(int core)
Changed cpu_thread_to_core() to cpu_core_of_thread(int cpu)
The goal is to make 'threads_per_core' accessible to the
pseries_energy module. Instead of making an API to read
threads_per_core, this is a higher level wrapper function to
convert from logical cpu number to core number.
The current APIs cpu_first_thread_in_core() and
cpu_last_thread_in_core() returns logical CPU number while
cpu_thread_to_core() returns core number or index which is
not a logical CPU number. The APIs are now clearly named to
distinguish 'core number' versus first and last 'logical cpu
number' in that core.
The new APIs cpu_{left,right}most_thread_sibling() work on
logical cpu numbers. While cpu_first_thread_of_core() and
cpu_core_of_thread() work on core index.
Example usage: (4 threads per core system)
cpu_leftmost_thread_sibling(5) = 4
cpu_rightmost_thread_sibling(5) = 7
cpu_core_of_thread(5) = 1
cpu_first_thread_of_core(1) = 4
cpu_core_of_thread() is used in cpu_to_drc_index() in the
module and cpu_first_thread_of_core() is used in
drc_index_to_cpu() in the module.
Made API changes to few callers. Exported symbols for use
in modules.
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/cputhreads.h | 15 +++++++++------
arch/powerpc/kernel/smp.c | 19 ++++++++++++++++---
arch/powerpc/mm/mmu_context_nohash.c | 12 ++++++------
3 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h
index a8e1844..26dc6bd 100644
--- a/arch/powerpc/include/asm/cputhreads.h
+++ b/arch/powerpc/include/asm/cputhreads.h
@@ -61,22 +61,25 @@ static inline cpumask_t cpu_online_cores_map(void)
return cpu_thread_mask_to_cores(cpu_online_map);
}
-static inline int cpu_thread_to_core(int cpu)
-{
- return cpu >> threads_shift;
-}
+#ifdef CONFIG_SMP
+int cpu_core_of_thread(int cpu);
+int cpu_first_thread_of_core(int core);
+#else
+static inline int cpu_core_of_thread(int cpu) { return cpu; }
+static inline int cpu_first_thread_of_core(int core) { return core; }
+#endif
static inline int cpu_thread_in_core(int cpu)
{
return cpu & (threads_per_core - 1);
}
-static inline int cpu_first_thread_in_core(int cpu)
+static inline int cpu_leftmost_thread_sibling(int cpu)
{
return cpu & ~(threads_per_core - 1);
}
-static inline int cpu_last_thread_in_core(int cpu)
+static inline int cpu_rightmost_thread_sibling(int cpu)
{
return cpu | (threads_per_core - 1);
}
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 5c196d1..da4c2f8 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -468,7 +468,20 @@ out:
return id;
}
-/* Must be called when no change can occur to cpu_present_mask,
+/* Helper routines for cpu to core mapping */
+int cpu_core_of_thread(int cpu)
+{
+ return cpu >> threads_shift;
+}
+EXPORT_SYMBOL_GPL(cpu_core_of_thread);
+
+int cpu_first_thread_of_core(int core)
+{
+ return core << threads_shift;
+}
+EXPORT_SYMBOL_GPL(cpu_first_thread_of_core);
+
+/* Must be called when no change can occur to cpu_present_map,
* i.e. during cpu online or offline.
*/
static struct device_node *cpu_to_l2cache(int cpu)
@@ -527,7 +540,7 @@ int __devinit start_secondary(void *unused)
notify_cpu_starting(cpu);
set_cpu_online(cpu, true);
/* Update sibling maps */
- base = cpu_first_thread_in_core(cpu);
+ base = cpu_leftmost_thread_sibling(cpu);
for (i = 0; i < threads_per_core; i++) {
if (cpu_is_offline(base + i))
continue;
@@ -606,7 +619,7 @@ int __cpu_disable(void)
return err;
/* Update sibling maps */
- base = cpu_first_thread_in_core(cpu);
+ base = cpu_leftmost_thread_sibling(cpu);
for (i = 0; i < threads_per_core; i++) {
cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i));
cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu));
diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
index ddfd7ad..22f3bc5 100644
--- a/arch/powerpc/mm/mmu_context_nohash.c
+++ b/arch/powerpc/mm/mmu_context_nohash.c
@@ -111,8 +111,8 @@ static unsigned int steal_context_smp(unsigned int id)
* a core map instead but this will do for now.
*/
for_each_cpu(cpu, mm_cpumask(mm)) {
- for (i = cpu_first_thread_in_core(cpu);
- i <= cpu_last_thread_in_core(cpu); i++)
+ for (i = cpu_leftmost_thread_sibling(cpu);
+ i <= cpu_rightmost_thread_sibling(cpu); i++)
__set_bit(id, stale_map[i]);
cpu = i - 1;
}
@@ -264,14 +264,14 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
*/
if (test_bit(id, stale_map[cpu])) {
pr_hardcont(" | stale flush %d [%d..%d]",
- id, cpu_first_thread_in_core(cpu),
- cpu_last_thread_in_core(cpu));
+ id, cpu_leftmost_thread_sibling(cpu),
+ cpu_rightmost_thread_sibling(cpu));
local_flush_tlb_mm(next);
/* XXX This clear should ultimately be part of local_flush_tlb_mm */
- for (i = cpu_first_thread_in_core(cpu);
- i <= cpu_last_thread_in_core(cpu); i++) {
+ for (i = cpu_leftmost_thread_sibling(cpu);
+ i <= cpu_rightmost_thread_sibling(cpu); i++) {
__clear_bit(id, stale_map[i]);
}
}
^ permalink raw reply related
* [PATCH v3 0/2] powerpc: add support for new hcall H_BEST_ENERGY
From: Vaidyanathan Srinivasan @ 2010-06-23 6:03 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Anton Blanchard; +Cc: linuxppc-dev
Hi Ben,
The following series adds a kernel module for powerpc pseries platforms in
order to export platform energy management capabilities.
The module exports data from a new hypervisor call H_BEST_ENERGY.
Comments and suggestions made on the previous iteration of the patch
has been incorporated.
Changed in v3:
* Added more documentation in the cleanup patch
* Removed RFC tag, rebased and tested on 2.6.35-rc3
* Ready for inclusion in powerpc/next tree for further testing
Changes in v2:
[1] [RFC PATCH v2 0/2] powerpc: add support for new hcall H_BEST_ENERGY
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-May/082246.html
* Cleanup cpu/thread/core APIs
* Export APIs to module instead of threads_per_core
* Use of_find_node_by_path() instead of of_find_node_by_name()
* Error checking and whitespace cleanups
First version:
[2] [RFC] powerpc: add support for new hcall H_BEST_ENERGY
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-March/080796.html
Please review and include in powerpc/next tree for further testing. I will
add the following enhancements incrementally:
* Detect h_call support from ibm,hypertas-functions
* Limit sysfs file creation only on hcall availability
This patch series will apply on 2.6.35-rc3 as well as powerpc/next tree.
Thanks,
Vaidy
---
Vaidyanathan Srinivasan (2):
powerpc: cleanup APIs for cpu/thread/core mappings
powerpc: add support for new hcall H_BEST_ENERGY
arch/powerpc/include/asm/cputhreads.h | 15 +
arch/powerpc/include/asm/hvcall.h | 3
arch/powerpc/kernel/smp.c | 19 +-
arch/powerpc/mm/mmu_context_nohash.c | 12 +
arch/powerpc/platforms/pseries/Kconfig | 10 +
arch/powerpc/platforms/pseries/Makefile | 1
arch/powerpc/platforms/pseries/pseries_energy.c | 258 +++++++++++++++++++++++
7 files changed, 302 insertions(+), 16 deletions(-)
create mode 100644 arch/powerpc/platforms/pseries/pseries_energy.c
--
^ permalink raw reply
* Re: [PATCH 10/40] tracing: add tracing support for compat syscalls
From: Steven Rostedt @ 2010-06-23 15:26 UTC (permalink / raw)
To: Ian Munsie
Cc: Lai Jiangshan, Arnd Bergmann, Jason Baron, Li Zefan, linux-kernel,
linuxppc-dev, Ingo Molnar, Paul Mackerras, Frederic Weisbecker,
Andrew Morton, David S. Miller, Masami Hiramatsu
In-Reply-To: <1277287401-28571-11-git-send-email-imunsie@au1.ibm.com>
On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> From: Jason Baron <jbaron@redhat.com>
>
> Add core support to event tracing for compat syscalls. The basic idea is that we
> check if we have a compat task via 'is_compat_task()'. If so, we lookup in the
> new compat_syscalls_metadata table, the corresponding struct syscall_metadata, to
> check syscall arguments and whether or not we are enabled.
>
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---
> include/linux/compat.h | 2 +
> include/trace/syscall.h | 4 ++
> kernel/trace/trace.h | 2 +
> kernel/trace/trace_syscalls.c | 86 +++++++++++++++++++++++++++++++++++++----
> 4 files changed, 86 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/compat.h b/include/linux/compat.h
> index ab638e9..a94f13d 100644
> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -363,6 +363,8 @@ extern ssize_t compat_rw_copy_check_uvector(int type,
>
> #else /* CONFIG_COMPAT */
>
> +#define NR_syscalls_compat 0
> +
> static inline int is_compat_task(void)
> {
> return 0;
> diff --git a/include/trace/syscall.h b/include/trace/syscall.h
> index 75f3dce..67d4e64 100644
> --- a/include/trace/syscall.h
> +++ b/include/trace/syscall.h
> @@ -22,6 +22,7 @@
> struct syscall_metadata {
> const char *name;
> int syscall_nr;
> + int compat_syscall_nr;
This is also bloating the kernel. I don't like to add fields to the
syscall_metadata lightly.
You're adding 4 more bytes to this structure to handle a few items. Find
a better way to do this.
> int nb_args;
> const char **types;
> const char **args;
> @@ -38,6 +39,9 @@ struct syscall_metadata {
>
> #ifdef CONFIG_FTRACE_SYSCALLS
> extern unsigned long arch_syscall_addr(int nr);
> +#ifdef CONFIG_COMPAT
> +extern unsigned long arch_compat_syscall_addr(int nr);
> +#endif
> extern int init_syscall_trace(struct ftrace_event_call *call);
>
> extern int reg_event_syscall_enter(struct ftrace_event_call *call);
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 01ce088..53ace4b 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -79,12 +79,14 @@ enum trace_type {
> struct syscall_trace_enter {
> struct trace_entry ent;
> int nr;
> + int compat;
You're adding 4 bytes to a trace (taking up precious buffer space) for a
single flag. If anything, set the 31st bit of nr if it is compat.
-- Steve
> unsigned long args[];
> };
>
> struct syscall_trace_exit {
> struct trace_entry ent;
> int nr;
> + int compat;
> long ret;
> };
>
^ permalink raw reply
* Re: [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support
From: Steven Rostedt @ 2010-06-23 15:16 UTC (permalink / raw)
To: Ian Munsie
Cc: Lai Jiangshan, Jason Baron, linux-kernel, linuxppc-dev,
Ingo Molnar, Paul Mackerras, Frederic Weisbecker, Ingo Molnar,
Masami Hiramatsu
In-Reply-To: <1277287401-28571-9-git-send-email-imunsie@au1.ibm.com>
On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> From: Jason Baron <jbaron@redhat.com>
>
> In preparation for compat syscall tracing support, let's store the enabled
> syscalls, with the struct syscall_metadata itself. That way we don't duplicate
> enabled information when the compat table points to an entry in the regular
> syscall table. Also, allows us to remove the bitmap data structures completely.
>
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---
> include/linux/syscalls.h | 8 +++++++
> include/trace/syscall.h | 4 +++
> kernel/trace/trace_syscalls.c | 42 +++++++++++++++++++---------------------
> 3 files changed, 32 insertions(+), 22 deletions(-)
>
> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> index 86f082b..755d05b 100644
> --- a/include/linux/syscalls.h
> +++ b/include/linux/syscalls.h
> @@ -163,6 +163,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
> .nb_args = nb, \
> .types = types_##sname, \
> .args = args_##sname, \
> + .ftrace_enter = 0, \
> + .ftrace_exit = 0, \
> + .perf_enter = 0, \
> + .perf_exit = 0, \
I really hate this change!
You just removed a nice compressed bitmap (1 bit per syscall) to add 4
bytes per syscall. On my box I have 308 syscalls being traced. That was
308 bits per bitmask = 39 bytes * 2 = 78 * 2 (perf and ftrace) = 156.
Now we have 8 bytes per syscall (enter and exit), which is 1232 bytes.
Thus this change added 1076 bytes.
This may not seem as much, but the change is not worth 1K. Can't we just
add another bitmask or something for the compat case?
I also hate the moving of ftrace and perf internal data to an external
interface.
-- Steve
> .enter_event = &event_enter_##sname, \
> .exit_event = &event_exit_##sname, \
> .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
> @@ -179,6 +183,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
> .name = "sys_"#sname, \
> .syscall_nr = -1, /* Filled in at boot */ \
> .nb_args = 0, \
> + .ftrace_enter = 0, \
> + .ftrace_exit = 0, \
> + .perf_enter = 0, \
> + .perf_exit = 0, \
> .enter_event = &event_enter__##sname, \
> .exit_event = &event_exit__##sname, \
> .enter_fields = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
^ permalink raw reply
* Re: [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls
From: Steven Rostedt @ 2010-06-23 15:02 UTC (permalink / raw)
To: Ian Munsie
Cc: Jason Baron, linux-kernel, linuxppc-dev, Ingo Molnar,
Paul Mackerras, Frederic Weisbecker, Ingo Molnar,
Masami Hiramatsu
In-Reply-To: <1277287401-28571-2-git-send-email-imunsie@au1.ibm.com>
On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
>
> FTRACE_SYSCALLS would create events for each and every system call, even
> if it had failed to map the system call's name with it's number. This
> resulted in a number of events being created that would not behave as
> expected.
>
> This could happen, for example, on architectures who's symbol names are
> unusual and will not match the system call name. It could also happen
> with system calls which were mapped to sys_ni_syscall.
>
> This patch changes the default system call number in the metadata to -1.
> If the system call name from the metadata is not successfully mapped to
> a system call number during boot, than the event initialisation routine
> will now return an error, preventing the event from being created.
>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---
> include/linux/syscalls.h | 2 ++
> kernel/trace/trace_syscalls.c | 8 ++++++++
> 2 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> index 7f614ce..86f082b 100644
> --- a/include/linux/syscalls.h
> +++ b/include/linux/syscalls.h
> @@ -159,6 +159,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
> __attribute__((section("__syscalls_metadata"))) \
> __syscall_meta_##sname = { \
> .name = "sys"#sname, \
> + .syscall_nr = -1, /* Filled in at boot */ \
> .nb_args = nb, \
> .types = types_##sname, \
> .args = args_##sname, \
> @@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
> __attribute__((section("__syscalls_metadata"))) \
> __syscall_meta__##sname = { \
> .name = "sys_"#sname, \
> + .syscall_nr = -1, /* Filled in at boot */ \
> .nb_args = 0, \
> .enter_event = &event_enter__##sname, \
> .exit_event = &event_exit__##sname, \
> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
> index 34e3580..82246ce 100644
> --- a/kernel/trace/trace_syscalls.c
> +++ b/kernel/trace/trace_syscalls.c
> @@ -431,6 +431,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
> int init_syscall_trace(struct ftrace_event_call *call)
> {
> int id;
> + int num;
> +
> + num = ((struct syscall_metadata *)call->data)->syscall_nr;
> + if (num < 0 || num >= NR_syscalls) {
> + pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
> + ((struct syscall_metadata *)call->data)->name);
> + return -ENOSYS;
> + }
Perhaps this should be:
if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls)
return -ENOSYS;
-- Steve
>
> if (set_syscall_print_fmt(call) < 0)
> return -ENOMEM;
^ permalink raw reply
* unsubscribe
From: Frederic LEGER @ 2010-06-23 14:33 UTC (permalink / raw)
To: linuxppc-dev
unsubscribe
^ permalink raw reply
* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
From: Christoph Hellwig @ 2010-06-23 12:41 UTC (permalink / raw)
To: Andi Kleen
Cc: Christoph Lameter, WANG Cong, Frederic Weisbecker, Heiko Carstens,
Oleg Nesterov, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
Sam Ravnborg, Mike Frysinger, Eric Dumazet, Jeff Moyer,
Ingo Molnar, KOSAKI Motohiro, Ingo Molnar, Arnd Bergmann,
David Rientjes, Steven Rostedt, Ian Munsie, Thomas Gleixner,
Johannes Berg, Roland McGrath, Lee Schermerhorn,
Arnaldo Carvalho de Melo, Neil Horman, linux-mm, netdev,
Jason Baron, Greg Kroah-Hartman, Roel Kluin, linux-kernel, kexec,
Eric Biederman, linux-fsdevel, Simon Kagstrom, Andrew Morton,
David S. Miller, Alexander Viro
In-Reply-To: <4C21FF9A.2040207@linux.intel.com>
On Wed, Jun 23, 2010 at 02:35:38PM +0200, Andi Kleen wrote:
> >I haven't heard any complains about existing syscalls wrappers.
>
> At least for me they always interrupt my grepping.
>
> >
> >What kind of annotations could solve that?
>
> If you put the annotation in a separate macro and leave the original
> prototype alone. Then C parsers could still parse it.
I personally hate the way SYSCALL_DEFINE works with passion, mostly
for the grep reason, but also because it looks horribly ugly.
But there is no reason not to be consistent here. We already use
the wrappers for all native system calls, so leaving the compat
calls out doesn't make any sense. And I'd cheer for anyone who
comes up with a better scheme for the native and compat wrappers.
^ permalink raw reply
* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
From: Andi Kleen @ 2010-06-23 12:35 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Christoph Lameter, WANG Cong, Heiko Carstens, Oleg Nesterov,
linuxppc-dev, Paul Mackerras, H. Peter Anvin, Sam Ravnborg,
Mike Frysinger, Eric Dumazet, Jeff Moyer, Ingo Molnar,
KOSAKI Motohiro, David Rientjes, Ingo Molnar, Arnd Bergmann,
Steven Rostedt, Ian Munsie, Thomas Gleixner, Johannes Berg,
Roland McGrath, Lee Schermerhorn, Arnaldo Carvalho de Melo,
Neil Horman, linux-mm, netdev, Jason Baron, Greg Kroah-Hartman,
Roel Kluin, linux-kernel, kexec, Eric Biederman, linux-fsdevel,
Simon Kagstrom, Andrew Morton, David S. Miller, Alexander Viro
In-Reply-To: <20100623113806.GD5242@nowhere>
>
> I haven't heard any complains about existing syscalls wrappers.
At least for me they always interrupt my grepping.
>
> What kind of annotations could solve that?
If you put the annotation in a separate macro and leave the original
prototype alone. Then C parsers could still parse it.
-Andi
^ permalink raw reply
* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
From: Frederic Weisbecker @ 2010-06-23 11:41 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Jason Baron, x86, Greg Ungerer, linux-kernel, Steven Rostedt,
linuxppc-dev, Ingo Molnar, Paul Mackerras, Ian Munsie,
H. Peter Anvin, Russell King, Thomas Gleixner, Andrew Morton
In-Reply-To: <20100623104603.GB11845@lst.de>
On Wed, Jun 23, 2010 at 12:46:04PM +0200, Christoph Hellwig wrote:
> On Wed, Jun 23, 2010 at 12:36:21PM +0200, Frederic Weisbecker wrote:
> > I think we wanted that to keep the sys32_ prefixed based naming, to avoid
> > collisions with generic compat handler names.
>
> For native syscalls we do this by adding a arch prefix inside the
> syscall name, e.g.:
>
> arch/s390/kernel/sys_s390.c:SYSCALL_DEFINE(s390_fallocate)(int fd, int mode, loff_t offset,
> arch/sparc/kernel/sys_sparc_64.c:SYSCALL_DEFINE1(sparc_pipe_real, struct pt_regs *, regs)
In fact we sort of wanted to standardize the name of arch overriden compat
syscalls, so that userspace programs playing with syscalls tracing won't have
to deal with arch naming differences.
^ permalink raw reply
* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
From: Frederic Weisbecker @ 2010-06-23 11:38 UTC (permalink / raw)
To: Andi Kleen
Cc: Christoph Lameter, WANG Cong, Heiko Carstens, Oleg Nesterov,
linuxppc-dev, Paul Mackerras, H. Peter Anvin, Sam Ravnborg,
Mike Frysinger, Eric Dumazet, Jeff Moyer, Ingo Molnar,
KOSAKI Motohiro, David Rientjes, Ingo Molnar, Arnd Bergmann,
Steven Rostedt, Ian Munsie, Thomas Gleixner, Johannes Berg,
Roland McGrath, Lee Schermerhorn, Arnaldo Carvalho de Melo,
Neil Horman, linux-mm, netdev, Jason Baron, Greg Kroah-Hartman,
Roel Kluin, linux-kernel, kexec, Eric Biederman, linux-fsdevel,
Simon Kagstrom, Andrew Morton, David S. Miller, Alexander Viro
In-Reply-To: <4C21E3F8.9000405@linux.intel.com>
On Wed, Jun 23, 2010 at 12:37:44PM +0200, Andi Kleen wrote:
> , Frederic Weisbecker wrote:
>> On Wed, Jun 23, 2010 at 12:19:38PM +0200, Andi Kleen wrote:
>>> , Ian Munsie wrote:
>>>> From: Ian Munsie<imunsie@au1.ibm.com>
>>>>
>>>> This patch converts numerous trivial compat syscalls through the generic
>>>> kernel code to use the COMPAT_SYSCALL_DEFINE family of macros.
>>>
>>> Why? This just makes the code look uglier and the functions harder
>>> to grep for.
>>
>>
>> Because it makes them usable with syscall tracing.
>
> Ok that information is missing in the changelog then.
Agreed, the changelog lacks the purpose of what it does.
> Also I hope the uglification<->usefullness factor is really worth it.
> The patch is certainly no slouch on the uglification side.
It's worth because the kernel's syscall tracing is not complete, we lack all
the compat part.
These wrappers let us create TRACE_EVENT() for every syscalls automatically.
If we had to create them manually, the uglification would be way much more worse.
Most syscalls use the syscall wrappers already, so the uglification
is there mostly. We just forgot to uglify a bunch of them :)
> It also has maintenance costs, e.g. I doubt ctags and cscope
> will be able to deal with these kinds of macros, so it has a
> high cost for everyone using these tools. For those
> it would be actually better if you used separate annotation
> that does not confuse standard C parsers.
I haven't heard any complains about existing syscalls wrappers.
What kind of annotations could solve that?
^ permalink raw reply
* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
From: KOSAKI Motohiro @ 2010-06-23 10:30 UTC (permalink / raw)
To: Andi Kleen
Cc: Christoph Lameter, WANG Cong, Frederic Weisbecker, Heiko Carstens,
Oleg Nesterov, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
Sam Ravnborg, Mike Frysinger, Eric Dumazet, Jeff Moyer,
Ingo Molnar, kosaki.motohiro, Ingo Molnar, Arnd Bergmann,
David Rientjes, Steven Rostedt, Ian Munsie, Thomas Gleixner,
Johannes Berg, Roland McGrath, Lee Schermerhorn,
Arnaldo Carvalho de Melo, Neil Horman, linux-mm, netdev,
Jason Baron, Greg Kroah-Hartman, Roel Kluin, linux-kernel, kexec,
Eric Biederman, linux-fsdevel, Simon Kagstrom, Andrew Morton,
David S. Miller, Alexander Viro
In-Reply-To: <4C21DFBA.2070202@linux.intel.com>
> , Ian Munsie wrote:
> > From: Ian Munsie<imunsie@au1.ibm.com>
> >
> > This patch converts numerous trivial compat syscalls through the generic
> > kernel code to use the COMPAT_SYSCALL_DEFINE family of macros.
>
> Why? This just makes the code look uglier and the functions harder
> to grep for.
I guess trace-syscall feature need to override COMPAT_SYSCALL_DEFINE. but
It's only guess...
^ permalink raw reply
* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
From: Andi Kleen @ 2010-06-23 10:37 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Christoph Lameter, WANG Cong, Heiko Carstens, Oleg Nesterov,
linuxppc-dev, Paul Mackerras, H. Peter Anvin, Sam Ravnborg,
Mike Frysinger, Eric Dumazet, Jeff Moyer, Ingo Molnar,
KOSAKI Motohiro, David Rientjes, Ingo Molnar, Arnd Bergmann,
Steven Rostedt, Ian Munsie, Thomas Gleixner, Johannes Berg,
Roland McGrath, Lee Schermerhorn, Arnaldo Carvalho de Melo,
Neil Horman, linux-mm, netdev, Jason Baron, Greg Kroah-Hartman,
Roel Kluin, linux-kernel, kexec, Eric Biederman, linux-fsdevel,
Simon Kagstrom, Andrew Morton, David S. Miller, Alexander Viro
In-Reply-To: <20100623102931.GB5242@nowhere>
, Frederic Weisbecker wrote:
> On Wed, Jun 23, 2010 at 12:19:38PM +0200, Andi Kleen wrote:
>> , Ian Munsie wrote:
>>> From: Ian Munsie<imunsie@au1.ibm.com>
>>>
>>> This patch converts numerous trivial compat syscalls through the generic
>>> kernel code to use the COMPAT_SYSCALL_DEFINE family of macros.
>>
>> Why? This just makes the code look uglier and the functions harder
>> to grep for.
>
>
> Because it makes them usable with syscall tracing.
Ok that information is missing in the changelog then.
Also I hope the uglification<->usefullness factor is really worth it.
The patch is certainly no slouch on the uglification side.
It also has maintenance costs, e.g. I doubt ctags and cscope
will be able to deal with these kinds of macros, so it has a
high cost for everyone using these tools. For those
it would be actually better if you used separate annotation
that does not confuse standard C parsers.
-Andi
^ permalink raw reply
* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
From: Christoph Hellwig @ 2010-06-23 10:46 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Andrew Morton, Jason Baron, x86, Greg Ungerer, linux-kernel,
Steven Rostedt, linuxppc-dev, Ingo Molnar, Paul Mackerras,
Ian Munsie, H. Peter Anvin, Russell King, Thomas Gleixner,
Christoph Hellwig
In-Reply-To: <20100623103619.GC5242@nowhere>
On Wed, Jun 23, 2010 at 12:36:21PM +0200, Frederic Weisbecker wrote:
> I think we wanted that to keep the sys32_ prefixed based naming, to avoid
> collisions with generic compat handler names.
For native syscalls we do this by adding a arch prefix inside the
syscall name, e.g.:
arch/s390/kernel/sys_s390.c:SYSCALL_DEFINE(s390_fallocate)(int fd, int mode, loff_t offset,
arch/sparc/kernel/sys_sparc_64.c:SYSCALL_DEFINE1(sparc_pipe_real, struct pt_regs *, regs)
^ permalink raw reply
* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
From: Frederic Weisbecker @ 2010-06-23 10:36 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Jason Baron, x86, Greg Ungerer, linux-kernel, Steven Rostedt,
linuxppc-dev, Ingo Molnar, Paul Mackerras, Ian Munsie,
H. Peter Anvin, Russell King, Thomas Gleixner, Andrew Morton
In-Reply-To: <20100623101402.GA10564@lst.de>
On Wed, Jun 23, 2010 at 12:14:02PM +0200, Christoph Hellwig wrote:
> Any reason we need to differenciate between COMPAT_SYSCALL_DEFINE and
> ARCH_COMPAT_SYSCALL_DEFINE? We don't need this for native system calls,
> so I can't see the reason to do it for compat system calls.
>
I think we wanted that to keep the sys32_ prefixed based naming, to avoid
collisions with generic compat handler names.
^ permalink raw reply
* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
From: Andi Kleen @ 2010-06-23 10:19 UTC (permalink / raw)
To: Ian Munsie
Cc: Christoph Lameter, WANG Cong, Frederic Weisbecker, Heiko Carstens,
Oleg Nesterov, linuxppc-dev, Paul Mackerras, H. Peter Anvin,
Sam Ravnborg, Mike Frysinger, Eric Dumazet, Jeff Moyer,
Ingo Molnar, KOSAKI Motohiro, Ingo Molnar, Arnd Bergmann,
David Rientjes, Steven Rostedt, Alexander Viro, Thomas Gleixner,
Johannes Berg, Roland McGrath, Lee Schermerhorn,
Arnaldo Carvalho de Melo, Neil Horman, linux-mm, netdev,
Jason Baron, Greg Kroah-Hartman, Roel Kluin, linux-kernel, kexec,
Eric Biederman, linux-fsdevel, Simon Kagstrom, Andrew Morton,
David S. Miller
In-Reply-To: <1277287401-28571-32-git-send-email-imunsie@au1.ibm.com>
, Ian Munsie wrote:
> From: Ian Munsie<imunsie@au1.ibm.com>
>
> This patch converts numerous trivial compat syscalls through the generic
> kernel code to use the COMPAT_SYSCALL_DEFINE family of macros.
Why? This just makes the code look uglier and the functions harder
to grep for.
-Andi
^ permalink raw reply
* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
From: Frederic Weisbecker @ 2010-06-23 10:29 UTC (permalink / raw)
To: Andi Kleen
Cc: Christoph Lameter, WANG Cong, Heiko Carstens, Oleg Nesterov,
linuxppc-dev, Paul Mackerras, H. Peter Anvin, Sam Ravnborg,
Mike Frysinger, Eric Dumazet, Jeff Moyer, Ingo Molnar,
KOSAKI Motohiro, David Rientjes, Ingo Molnar, Arnd Bergmann,
Steven Rostedt, Ian Munsie, Thomas Gleixner, Johannes Berg,
Roland McGrath, Lee Schermerhorn, Arnaldo Carvalho de Melo,
Neil Horman, linux-mm, netdev, Jason Baron, Greg Kroah-Hartman,
Roel Kluin, linux-kernel, kexec, Eric Biederman, linux-fsdevel,
Simon Kagstrom, Andrew Morton, David S. Miller, Alexander Viro
In-Reply-To: <4C21DFBA.2070202@linux.intel.com>
On Wed, Jun 23, 2010 at 12:19:38PM +0200, Andi Kleen wrote:
> , Ian Munsie wrote:
>> From: Ian Munsie<imunsie@au1.ibm.com>
>>
>> This patch converts numerous trivial compat syscalls through the generic
>> kernel code to use the COMPAT_SYSCALL_DEFINE family of macros.
>
> Why? This just makes the code look uglier and the functions harder
> to grep for.
Because it makes them usable with syscall tracing.
^ permalink raw reply
* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
From: Christoph Hellwig @ 2010-06-23 10:14 UTC (permalink / raw)
To: Ian Munsie
Cc: Andrew Morton, Frederic Weisbecker, Jason Baron, x86,
Greg Ungerer, linux-kernel, Steven Rostedt, linuxppc-dev,
Ingo Molnar, Paul Mackerras, H. Peter Anvin, Russell King,
Thomas Gleixner, Christoph Hellwig
In-Reply-To: <1277287401-28571-13-git-send-email-imunsie@au1.ibm.com>
Any reason we need to differenciate between COMPAT_SYSCALL_DEFINE and
ARCH_COMPAT_SYSCALL_DEFINE? We don't need this for native system calls,
so I can't see the reason to do it for compat system calls.
^ permalink raw reply
* [PATCH 32/40] trace syscalls: Record metadata for syscalls with their own wrappers
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: Jan Kara, Tetsuo Handa, Frederic Weisbecker, Julia Lawall,
Heiko Carstens, linux-mm, Paul Mackerras, Jens Axboe, Jan Blunck,
Christoph Hellwig, Nick Piggin, linux-s390, Jesper Nilsson,
Manfred Spraul, James Morris, Ingo Molnar, Russell King,
Ingo Molnar, Rik van Riel, Steven Rostedt, linux-fsdevel,
Ian Munsie, Serge E. Hallyn, Jason Baron, Eric Paris,
Johannes Weiner, Martin Schwidefsky, linux390, Andrew Morton,
Wu Fengguang, Alexander Viro
In-Reply-To: <1277287401-28571-1-git-send-email-imunsie@au1.ibm.com>
From: Ian Munsie <imunsie@au1.ibm.com>
This patch adds support for syscalls using the SYSCALL_DEFINE macro
(i.e. ones that require a specialised syscall wrapper) to record their
meta-data for system call tracing.
The semantics of the SYSCALL_DEFINE macro therefore change to include
the number of arguments to the syscall and the arguments and types. All
instances of this macro have been updated to the new semantics.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
arch/s390/kernel/sys_s390.c | 4 ++--
fs/dcookies.c | 2 +-
fs/open.c | 6 +++---
fs/read_write.c | 8 ++++----
fs/sync.c | 8 ++++----
include/linux/syscalls.h | 9 +++++++--
ipc/sem.c | 2 +-
mm/fadvise.c | 4 ++--
mm/filemap.c | 2 +-
9 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
index 7b6b0f8..7773c87 100644
--- a/arch/s390/kernel/sys_s390.c
+++ b/arch/s390/kernel/sys_s390.c
@@ -185,8 +185,8 @@ SYSCALL_DEFINE1(s390_fadvise64_64, struct fadvise64_64_args __user *, args)
* to
* %r2: fd, %r3: mode, %r4/%r5: offset, 96(%r15)-103(%r15): len
*/
-SYSCALL_DEFINE(s390_fallocate)(int fd, int mode, loff_t offset,
- u32 len_high, u32 len_low)
+SYSCALL_DEFINE(s390_fallocate, 5, int, fd, int, mode, loff_t, offset,
+ u32, len_high, u32, len_low)
{
return sys_fallocate(fd, mode, offset, ((u64)len_high << 32) | len_low);
}
diff --git a/fs/dcookies.c b/fs/dcookies.c
index a21cabd..794cf94 100644
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -145,7 +145,7 @@ out:
/* And here is where the userspace process can look up the cookie value
* to retrieve the path.
*/
-SYSCALL_DEFINE(lookup_dcookie)(u64 cookie64, char __user * buf, size_t len)
+SYSCALL_DEFINE(lookup_dcookie, 3, u64, cookie64, char __user *, buf, size_t, len)
{
unsigned long cookie = (unsigned long)cookie64;
int err = -EINVAL;
diff --git a/fs/open.c b/fs/open.c
index 5463266..4107638 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -185,7 +185,7 @@ SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length)
/* LFS versions of truncate are only needed on 32 bit machines */
#if BITS_PER_LONG == 32
-SYSCALL_DEFINE(truncate64)(const char __user * path, loff_t length)
+SYSCALL_DEFINE(truncate64, 2, const char __user *, path, loff_t, length)
{
return do_sys_truncate(path, length);
}
@@ -197,7 +197,7 @@ asmlinkage long SyS_truncate64(long path, loff_t length)
SYSCALL_ALIAS(sys_truncate64, SyS_truncate64);
#endif
-SYSCALL_DEFINE(ftruncate64)(unsigned int fd, loff_t length)
+SYSCALL_DEFINE(ftruncate64, 2, unsigned int, fd, loff_t, length)
{
long ret = do_sys_ftruncate(fd, length, 0);
/* avoid REGPARM breakage on x86: */
@@ -256,7 +256,7 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
return inode->i_op->fallocate(inode, mode, offset, len);
}
-SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)
+SYSCALL_DEFINE(fallocate, 4, int, fd, int, mode, loff_t, offset, loff_t, len)
{
struct file *file;
int error = -EBADF;
diff --git a/fs/read_write.c b/fs/read_write.c
index 9c04852..5b4044f 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -423,8 +423,8 @@ SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf,
return ret;
}
-SYSCALL_DEFINE(pread64)(unsigned int fd, char __user *buf,
- size_t count, loff_t pos)
+SYSCALL_DEFINE(pread64, 4, unsigned int, fd, char __user *, buf,
+ size_t, count, loff_t, pos)
{
struct file *file;
ssize_t ret = -EBADF;
@@ -452,8 +452,8 @@ asmlinkage long SyS_pread64(long fd, long buf, long count, loff_t pos)
SYSCALL_ALIAS(sys_pread64, SyS_pread64);
#endif
-SYSCALL_DEFINE(pwrite64)(unsigned int fd, const char __user *buf,
- size_t count, loff_t pos)
+SYSCALL_DEFINE(pwrite64, 4, unsigned int, fd, const char __user *, buf,
+ size_t, count, loff_t, pos)
{
struct file *file;
ssize_t ret = -EBADF;
diff --git a/fs/sync.c b/fs/sync.c
index 15aa6f0..5cb8072 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -292,8 +292,8 @@ EXPORT_SYMBOL(generic_write_sync);
* already-instantiated disk blocks, there are no guarantees here that the data
* will be available after a crash.
*/
-SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes,
- unsigned int flags)
+SYSCALL_DEFINE(sync_file_range, 4, int, fd, loff_t, offset, loff_t, nbytes,
+ unsigned int, flags)
{
int ret;
struct file *file;
@@ -387,8 +387,8 @@ SYSCALL_ALIAS(sys_sync_file_range, SyS_sync_file_range);
/* It would be nice if people remember that not all the world's an i386
when they introduce new system calls */
-SYSCALL_DEFINE(sync_file_range2)(int fd, unsigned int flags,
- loff_t offset, loff_t nbytes)
+SYSCALL_DEFINE(sync_file_range2, 4, int, fd, unsigned int, flags,
+ loff_t, offset, loff_t, nbytes)
{
return sys_sync_file_range(fd, offset, nbytes, flags);
}
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 1076ae8..d7eaa4b 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -251,7 +251,9 @@ extern struct trace_event_functions exit_syscall_print_funcs;
#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
-#define SYSCALL_DEFINE(name) static inline long SYSC_##name
+#define SYSCALL_DEFINE(name, x, ...) \
+ SYSCALL_METADATAx(sys_##name, sys_##name, x, syscall, __VA_ARGS__);\
+ static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__))
#define __SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \
@@ -266,7 +268,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
-#define SYSCALL_DEFINE(name) asmlinkage long sys_##name
+#define SYSCALL_DEFINE(name, x, ...) \
+ SYSCALL_METADATAx(sys_##name, sys_##name, x, syscall, __VA_ARGS__);\
+ asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__))
+
#define __SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))
diff --git a/ipc/sem.c b/ipc/sem.c
index 506c849..1a1716b 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1074,7 +1074,7 @@ out_up:
return err;
}
-SYSCALL_DEFINE(semctl)(int semid, int semnum, int cmd, union semun arg)
+SYSCALL_DEFINE(semctl, 4, int, semid, int, semnum, int, cmd, union semun, arg)
{
int err = -EINVAL;
int version;
diff --git a/mm/fadvise.c b/mm/fadvise.c
index 8d723c9..5105afa 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -24,7 +24,7 @@
* POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could
* deactivate the pages and clear PG_Referenced.
*/
-SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
+SYSCALL_DEFINE(fadvise64_64, 4, int, fd, loff_t, offset, loff_t, len, int, advice)
{
struct file *file = fget(fd);
struct address_space *mapping;
@@ -144,7 +144,7 @@ SYSCALL_ALIAS(sys_fadvise64_64, SyS_fadvise64_64);
#ifdef __ARCH_WANT_SYS_FADVISE64
-SYSCALL_DEFINE(fadvise64)(int fd, loff_t offset, size_t len, int advice)
+SYSCALL_DEFINE(fadvise64, 4, int, fd, loff_t, offset, size_t, len, int, advice)
{
return sys_fadvise64_64(fd, offset, len, advice);
}
diff --git a/mm/filemap.c b/mm/filemap.c
index 20e5642..967d6bb 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1372,7 +1372,7 @@ do_readahead(struct address_space *mapping, struct file *filp,
return 0;
}
-SYSCALL_DEFINE(readahead)(int fd, loff_t offset, size_t count)
+SYSCALL_DEFINE(readahead, 3, int, fd, loff_t, offset, size_t, count)
{
ssize_t ret;
struct file *file;
--
1.7.1
^ permalink raw reply related
* [PATCH 40/40] trace syscalls, PPC: Convert morphing native/compat syscalls
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: Chase Douglas, Dave Kleikamp, Frederic Weisbecker, Jason Baron,
Ingo Molnar, Steven Rostedt, David Gibson, Ingo Molnar,
Paul Mackerras, Ian Munsie, Andrew Morton, Arjan van de Ven,
Christoph Hellwig, Anton Blanchard
In-Reply-To: <1277287401-28571-1-git-send-email-imunsie@au1.ibm.com>
From: Ian Munsie <imunsie@au1.ibm.com>
Several of the PowerPC system call implementations are used as both the
32bit compat version on PPC64 and the 32bit native version on PPC32.
Previousely these used the preprocessor to change the function names on
PPC64 to add the compat_ prefix.
This patch converts these system calls to use the SYSCALL_DEFINE family
of macros, with the preprocessor selecting which macro to use at their
implementation (which should also make things a little clearer, if more
verbose).
This patch also renames the swapcontext syscall and it's assembly
wrapper such that only the first three characters of their names will
differ which ftrace syscalls ignores when matching the syscall names
to their symbol names. This ensures that the appropriate meta-data will
match for this system call.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
arch/powerpc/include/asm/systbl.h | 2 +-
arch/powerpc/kernel/entry_64.S | 4 +-
arch/powerpc/kernel/signal_32.c | 56 +++++++++++++++++++++++++-----------
3 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 06c0a73..a0afa14 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -252,7 +252,7 @@ COMPAT_SYS_SPU(clock_settime)
COMPAT_SYS_SPU(clock_gettime)
COMPAT_SYS_SPU(clock_getres)
COMPAT_SYS_SPU(clock_nanosleep)
-SYSX(ppc64_swapcontext,ppc32_swapcontext,ppc_swapcontext)
+SYSX(ppc_swapcontext,ppc32_swapcontext,ppc_swapcontext)
COMPAT_SYS_SPU(tgkill)
COMPAT_SYS_SPU(utimes)
COMPAT_SYS_SPU(statfs64)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 42e9d90..8c23ff1 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -346,10 +346,10 @@ _GLOBAL(ppc_clone)
_GLOBAL(ppc32_swapcontext)
bl .save_nvgprs
- bl .compat_sys_swapcontext
+ bl .sys32_swapcontext
b syscall_exit
-_GLOBAL(ppc64_swapcontext)
+_GLOBAL(ppc_swapcontext)
bl .save_nvgprs
bl .sys_swapcontext
b syscall_exit
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 212583d..2c4071f 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -55,13 +55,6 @@
#undef DEBUG_SIG
#ifdef CONFIG_PPC64
-#define sys_sigsuspend compat_sys_sigsuspend
-#define sys_rt_sigsuspend compat_sys_rt_sigsuspend
-#define sys_rt_sigreturn compat_sys_rt_sigreturn
-#define sys_sigaction compat_sys_sigaction
-#define sys_swapcontext compat_sys_swapcontext
-#define sys_sigreturn compat_sys_sigreturn
-
#define old_sigaction old_sigaction32
#define sigcontext sigcontext32
#define mcontext mcontext32
@@ -239,7 +232,11 @@ static inline int restore_general_regs(struct pt_regs *regs,
/*
* Atomically swap in the new signal mask, and wait for a signal.
*/
-long sys_sigsuspend(old_sigset_t mask)
+#ifdef CONFIG_PPC64
+COMPAT_SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
+#else
+SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
+#endif
{
mask &= _BLOCKABLE;
spin_lock_irq(¤t->sighand->siglock);
@@ -254,8 +251,15 @@ long sys_sigsuspend(old_sigset_t mask)
return -ERESTARTNOHAND;
}
-long sys_sigaction(int sig, struct old_sigaction __user *act,
- struct old_sigaction __user *oact)
+#ifdef CONFIG_PPC64
+COMPAT_SYSCALL_DEFINE3(sigaction, int, sig,
+ struct old_sigaction __user *, act,
+ struct old_sigaction __user *, oact)
+#else
+SYSCALL_DEFINE3(sigaction, int, sig,
+ struct old_sigaction __user *, act,
+ struct old_sigaction __user *, oact)
+#endif
{
struct k_sigaction new_ka, old_ka;
int ret;
@@ -938,9 +942,21 @@ static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int
return 0;
}
-long sys_swapcontext(struct ucontext __user *old_ctx,
- struct ucontext __user *new_ctx,
- int ctx_size, int r6, int r7, int r8, struct pt_regs *regs)
+/*
+ * Note: Named sys_swapcontext on PPC32 and sys32_swapcontext on PPC64.
+ * Ensures that it's name will still match when compared with it's wrappers
+ * name (ppc_swapcontext on PPC32, ppc32_swapcontext on PPC64) for ftrace
+ * syscalls (which ignores the 1st three characters).
+ */
+#ifdef CONFIG_PPC64
+PPC_REGS_COMPAT_SYSCALL_DEFINEx(3, long, sys32_, swapcontext, regs,
+ struct ucontext __user *, old_ctx,
+ struct ucontext __user *, new_ctx, int, ctx_size)
+#else
+PPC_REGS_SYSCALL_DEFINE3_RET(long, swapcontext, regs,
+ struct ucontext __user *, old_ctx,
+ struct ucontext __user *, new_ctx, int, ctx_size)
+#endif
{
unsigned char tmp;
int ctx_has_vsx_region = 0;
@@ -1029,8 +1045,11 @@ long sys_swapcontext(struct ucontext __user *old_ctx,
return 0;
}
-long sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
- struct pt_regs *regs)
+#ifdef CONFIG_PPC64
+PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(long, rt_sigreturn, regs)
+#else
+PPC_REGS_SYSCALL_DEFINE0_RET(long, rt_sigreturn, regs)
+#endif
{
struct rt_sigframe __user *rt_sf;
@@ -1256,8 +1275,11 @@ badframe:
/*
* Do a signal return; undo the signal stack.
*/
-long sys_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
- struct pt_regs *regs)
+#ifdef CONFIG_PPC64
+PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(long, sigreturn, regs)
+#else
+PPC_REGS_SYSCALL_DEFINE0_RET(long, sigreturn, regs)
+#endif
{
struct sigcontext __user *sc;
struct sigcontext sigctx;
--
1.7.1
^ permalink raw reply related
* [PATCH 39/40] trace syscalls: Clean confusing {s, r, }name and fix ABI breakage
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: Jesper Nilsson, Frederic Weisbecker, Jason Baron, Ingo Molnar,
Steven Rostedt, Ingo Molnar, Paul Mackerras, Ian Munsie,
Andrew Morton, Christoph Hellwig
In-Reply-To: <1277287401-28571-1-git-send-email-imunsie@au1.ibm.com>
From: Ian Munsie <imunsie@au1.ibm.com>
This patch cleans up the preprocessor macros defining system calls by
standidising on the parameters passing around the system call name, with
and without it's prefix.
Overall this makes the preprocessor code easier to understand and
follow and less likely to introduce bugs due to misunderstanding what to
place into each parameter.
The parameters henceforth should be named:
sname is the system call name WITHOUT the prefix (e.g. read)
prefix is the prefix INCLUDING the trailing underscore (e.g. sys_)
These are mashed together to form the full syscall name when required
like blah##prefix##sname. For just prefix##sname please use the provided
SYSNAME(prefix,sname) macro instead as it will be safe if prefix itself
is a macro.
This patch also fixes an ABI breakage - the ftrace events are once again
named like 'sys_enter_read' instead of 'enter_sys_read'. The rwtop
script shipped with perf relies on this ABI. Others may as well.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
arch/powerpc/include/asm/syscalls.h | 58 +++++-----
include/linux/syscalls.h | 200 ++++++++++++++++++-----------------
2 files changed, 131 insertions(+), 127 deletions(-)
diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index 050cca3..b01fedf 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -21,48 +21,50 @@ struct sigaction;
#define __SC_DUMMY_ARGS6
/* Native syscalls that require register access */
-#define PPC_REGS_SYSCALL_DEFINE1_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(1, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE2_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(2, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE3_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(3, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE4_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(4, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE5_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(5, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE6_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(6, ret, sys_##name, _##name, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE0_RET(ret, sname, regs ) PPC_REGS_SYSCALL_DEFINE0( ret, sys_, sname, regs)
+#define PPC_REGS_SYSCALL_DEFINE1_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(1, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE2_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(2, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE3_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(3, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE4_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(4, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE5_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(5, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE6_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(6, ret, sys_, sname, regs, __VA_ARGS__)
#ifdef CONFIG_COMPAT
/* 32bit compat syscalls that require register access */
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE1_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE2_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE3_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE4_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE5_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE6_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-
-#define PPC_REGS_COMPAT_SYSCALL_DEFINEx(x, ret, sysname, sname, regs, ...) \
- SYSCALL_METADATAx(sysname, compat_sys_##sname, x, compat_syscall, __VA_ARGS__);\
- __PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, __VA_ARGS__)
-
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(ret, name, regs) \
- SYSCALL_METADATA0(compat_sys_##name, name, syscall) \
- __PPC_REGS_SYSCALL_DEFINE0(ret, compat_sys_##name, regs)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(ret, sname, regs ) PPC_REGS_COMPAT_SYSCALL_DEFINE0( ret, compat_sys_, sname, regs)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE1_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE2_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE3_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE4_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE5_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE6_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_, sname, regs, __VA_ARGS__)
+
+#define PPC_REGS_COMPAT_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, ...) \
+ SYSCALL_METADATAx(prefix, sname, x, compat_syscall, __VA_ARGS__); \
+ __PPC_REGS_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, __VA_ARGS__)
+
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE0(ret, prefix, sname, regs) \
+ SYSCALL_METADATA0(prefix, sname, syscall) \
+ __PPC_REGS_SYSCALL_DEFINE0(ret, prefix, sname, regs)
#endif /*CONFIG_COMPAT */
-#define PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, sname, regs, ...) \
- SYSCALL_METADATAx(sysname, sname, x, syscall, __VA_ARGS__); \
- __PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, ...) \
+ SYSCALL_METADATAx(prefix, sname, x, syscall, __VA_ARGS__); \
+ __PPC_REGS_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE0_RET(ret, name, regs) \
- SYSCALL_METADATA0(sys_##name, name, syscall) \
- __PPC_REGS_SYSCALL_DEFINE0(ret, sys_##name, regs)
+#define PPC_REGS_SYSCALL_DEFINE0(ret, prefix, sname, regs) \
+ SYSCALL_METADATA0(prefix, sname, syscall) \
+ __PPC_REGS_SYSCALL_DEFINE0(ret, prefix, sname, regs)
-#define __PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, ...) \
- ret sysname(__SC_DECL##x(__VA_ARGS__), \
+#define __PPC_REGS_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, ...) \
+ ret SYSNAME(prefix, sname)(__SC_DECL##x(__VA_ARGS__), \
__SC_DUMMY_ARGS##x \
struct pt_regs *regs)
-#define __PPC_REGS_SYSCALL_DEFINE0(ret, sysname, regs) \
- ret sysname(__SC_DUMMY_ARGS0 struct pt_regs *regs)
+#define __PPC_REGS_SYSCALL_DEFINE0(ret, prefix, sname, regs) \
+ ret SYSNAME(prefix, sname)(__SC_DUMMY_ARGS0 struct pt_regs *regs)
asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len,
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 0cef707..dbc630a 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -103,6 +103,8 @@ struct perf_event_attr;
#define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__)
#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
+#define SYSNAME(prefix, sname) prefix##sname
+
#ifdef CONFIG_FTRACE_SYSCALLS
#define __SC_STR_ADECL1(t, a) #a
#define __SC_STR_ADECL2(t, a, ...) #a, __SC_STR_ADECL1(__VA_ARGS__)
@@ -125,42 +127,42 @@ extern struct ftrace_event_class event_class_compat_syscall_exit;
extern struct trace_event_functions enter_syscall_print_funcs;
extern struct trace_event_functions exit_syscall_print_funcs;
-#define SYSCALL_TRACE_ENTER_EVENT(sname, event_class) \
- static struct syscall_metadata __syscall_meta_##sname; \
+#define SYSCALL_TRACE_ENTER_EVENT(prefix, sname, event_class) \
+ static struct syscall_metadata __syscall_meta_##prefix##sname; \
static struct ftrace_event_call \
- __attribute__((__aligned__(4))) event_enter_##sname; \
+ __attribute__((__aligned__(4))) event_enter_##prefix##sname; \
static struct ftrace_event_call __used \
__attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_events"))) \
- event_enter_##sname = { \
- .name = "enter_"#sname, \
+ event_enter_##prefix##sname = { \
+ .name = #prefix"enter_"#sname, \
.class = &event_class_##event_class##_enter,\
.event.funcs = &enter_syscall_print_funcs, \
- .data = (void *)&__syscall_meta_##sname,\
+ .data = (void *)&__syscall_meta_##prefix##sname,\
}
-#define SYSCALL_TRACE_EXIT_EVENT(sname, event_class) \
- static struct syscall_metadata __syscall_meta_##sname; \
+#define SYSCALL_TRACE_EXIT_EVENT(prefix, sname, event_class) \
+ static struct syscall_metadata __syscall_meta_##prefix##sname; \
static struct ftrace_event_call \
- __attribute__((__aligned__(4))) event_exit_##sname; \
+ __attribute__((__aligned__(4))) event_exit_##prefix##sname; \
static struct ftrace_event_call __used \
__attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_events"))) \
- event_exit_##sname = { \
- .name = "exit_"#sname, \
+ event_exit_##prefix##sname = { \
+ .name = #prefix"exit_"#sname, \
.class = &event_class_##event_class##_exit,\
.event.funcs = &exit_syscall_print_funcs, \
- .data = (void *)&__syscall_meta_##sname,\
+ .data = (void *)&__syscall_meta_##prefix##sname,\
}
-#define SYSCALL_METADATA(rname, sname, nb, event_class, stypes, sargs)\
- SYSCALL_TRACE_ENTER_EVENT(sname, event_class); \
- SYSCALL_TRACE_EXIT_EVENT(sname, event_class); \
+#define SYSCALL_METADATA(prefix, sname, nb, event_class, stypes, sargs)\
+ SYSCALL_TRACE_ENTER_EVENT(prefix, sname, event_class); \
+ SYSCALL_TRACE_EXIT_EVENT(prefix, sname, event_class); \
static struct syscall_metadata __used \
__attribute__((__aligned__(4))) \
__attribute__((section("__syscalls_metadata"))) \
- __syscall_meta_##sname = { \
- .name = #rname, \
+ __syscall_meta_##prefix##sname = { \
+ .name = #prefix#sname, \
.syscall_nr = -1, /* Filled in at boot */ \
.compat_syscall_nr = -1,/* Filled in at boot */ \
.nb_args = nb, \
@@ -170,85 +172,85 @@ extern struct trace_event_functions exit_syscall_print_funcs;
.ftrace_exit = 0, \
.perf_enter = 0, \
.perf_exit = 0, \
- .enter_event = &event_enter_##sname, \
- .exit_event = &event_exit_##sname, \
- .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
- .exit_fields = LIST_HEAD_INIT(__syscall_meta_##sname.exit_fields), \
+ .enter_event = &event_enter_##prefix##sname, \
+ .exit_event = &event_exit_##prefix##sname, \
+ .enter_fields = LIST_HEAD_INIT(__syscall_meta_##prefix##sname.enter_fields), \
+ .exit_fields = LIST_HEAD_INIT(__syscall_meta_##prefix##sname.exit_fields), \
};
-#define SYSCALL_METADATAx(rname, sname, nb, event_class, ...) \
- static const char *types_##sname[] = { \
+#define SYSCALL_METADATAx(prefix, sname, nb, event_class, ...) \
+ static const char *types_##prefix##sname[] = { \
__SC_STR_TDECL##nb(__VA_ARGS__) \
}; \
- static const char *args_##sname[] = { \
+ static const char *args_##prefix##sname[] = { \
__SC_STR_ADECL##nb(__VA_ARGS__) \
}; \
- SYSCALL_METADATA(rname, sname, nb, event_class, types_##sname, args_##sname)
+ SYSCALL_METADATA(prefix, sname, nb, event_class, types_##prefix##sname, args_##prefix##sname)
-#define SYSCALL_METADATA0(rname, sname, event_class) \
- SYSCALL_METADATA(rname, sname, 0, event_class, NULL, NULL)
+#define SYSCALL_METADATA0(prefix, sname, event_class) \
+ SYSCALL_METADATA(prefix, sname, 0, event_class, NULL, NULL)
#else /* !CONFIG_FTRACE_SYSCALLS */
#define SYSCALL_METADATAx(...)
#define SYSCALL_METADATA0(...)
#endif /* CONFIG_FTRACE_SYSCALLS */
-#define SYSCALL_DEFINE0(name) SYSCALL_DEFINE0_RET(long, name)
-#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, long, _##name, __VA_ARGS__)
-
-#define SYSCALL_DEFINE1_RET(ret, name, ...) SYSCALL_DEFINEx(1, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE2_RET(ret, name, ...) SYSCALL_DEFINEx(2, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE3_RET(ret, name, ...) SYSCALL_DEFINEx(3, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE4_RET(ret, name, ...) SYSCALL_DEFINEx(4, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE5_RET(ret, name, ...) SYSCALL_DEFINEx(5, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE6_RET(ret, name, ...) SYSCALL_DEFINEx(6, ret, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE0(sname) SYSCALL_DEFINE0_RET(long, sname)
+#define SYSCALL_DEFINE1(sname, ...) SYSCALL_DEFINEx(1, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE2(sname, ...) SYSCALL_DEFINEx(2, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE3(sname, ...) SYSCALL_DEFINEx(3, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE4(sname, ...) SYSCALL_DEFINEx(4, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE5(sname, ...) SYSCALL_DEFINEx(5, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE6(sname, ...) SYSCALL_DEFINEx(6, long, sname, __VA_ARGS__)
+
+#define SYSCALL_DEFINE1_RET(ret, sname, ...) SYSCALL_DEFINEx(1, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE2_RET(ret, sname, ...) SYSCALL_DEFINEx(2, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE3_RET(ret, sname, ...) SYSCALL_DEFINEx(3, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE4_RET(ret, sname, ...) SYSCALL_DEFINEx(4, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE5_RET(ret, sname, ...) SYSCALL_DEFINEx(5, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE6_RET(ret, sname, ...) SYSCALL_DEFINEx(6, ret, sname, __VA_ARGS__)
#ifdef CONFIG_COMPAT
-#define ARCH_COMPAT_SYSCALL_DEFINE0(name) COMPAT_SYSCALL_DEFINE0_RET(long, sys32_##name, name)
-#define ARCH_COMPAT_SYSCALL_DEFINE1(name, ...) COMPAT_SYSCALL_DEFINEx(1, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE2(name, ...) COMPAT_SYSCALL_DEFINEx(2, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE3(name, ...) COMPAT_SYSCALL_DEFINEx(3, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE4(name, ...) COMPAT_SYSCALL_DEFINEx(4, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE5(name, ...) COMPAT_SYSCALL_DEFINEx(5, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE6(name, ...) COMPAT_SYSCALL_DEFINEx(6, long, sys32_##name, name, __VA_ARGS__)
-
-#define ARCH_COMPAT_SYSCALL_DEFINE0_RET(ret, name) COMPAT_SYSCALL_DEFINE0_RET(0, ret, sys32_##name, name)
-#define ARCH_COMPAT_SYSCALL_DEFINE1_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(1, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE2_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(2, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE3_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(3, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE4_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(4, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE5_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(5, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE6_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(6, ret, sys32_##name, name, __VA_ARGS__)
-
-#define COMPAT_SYSCALL_DEFINE0(name) COMPAT_SYSCALL_DEFINE0_RET(long, compat_sys_##name, name)
-#define COMPAT_SYSCALL_DEFINE1(name, ...) COMPAT_SYSCALL_DEFINEx(1, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE2(name, ...) COMPAT_SYSCALL_DEFINEx(2, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE3(name, ...) COMPAT_SYSCALL_DEFINEx(3, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE4(name, ...) COMPAT_SYSCALL_DEFINEx(4, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE5(name, ...) COMPAT_SYSCALL_DEFINEx(5, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE6(name, ...) COMPAT_SYSCALL_DEFINEx(6, long, compat_sys_##name, name, __VA_ARGS__)
-
-#define COMPAT_SYSCALL_DEFINE0_RET(ret, name) __COMPAT_SYSCALL_DEFINE0(ret, compat_sys_##name, name)
-#define COMPAT_SYSCALL_DEFINE1_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE2_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE3_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE4_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE5_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE6_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_##name, name, __VA_ARGS__)
-
-#define COMPAT_SYSCALL_DEFINEx(x, ret, syscall, sname, ...) \
- SYSCALL_METADATAx(syscall, compat_sys_##sname, x, compat_syscall, __VA_ARGS__);\
- asmlinkage ret syscall(__SC_DECL##x(__VA_ARGS__))
-
-#define __COMPAT_SYSCALL_DEFINE0_RET(ret, syscall, name) \
- SYSCALL_METADATA0(syscall, name, compat_syscall) \
- asmlinkage ret syscall()
+#define ARCH_COMPAT_SYSCALL_DEFINE0(sname) COMPAT_SYSCALL_DEFINE0_RET(long, sys32_, sname)
+#define ARCH_COMPAT_SYSCALL_DEFINE1(sname, ...) COMPAT_SYSCALL_DEFINEx(1, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE2(sname, ...) COMPAT_SYSCALL_DEFINEx(2, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE3(sname, ...) COMPAT_SYSCALL_DEFINEx(3, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE4(sname, ...) COMPAT_SYSCALL_DEFINEx(4, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE5(sname, ...) COMPAT_SYSCALL_DEFINEx(5, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE6(sname, ...) COMPAT_SYSCALL_DEFINEx(6, long, sys32_, sname, __VA_ARGS__)
+
+#define ARCH_COMPAT_SYSCALL_DEFINE0_RET(ret, sname) COMPAT_SYSCALL_DEFINE0_RET(0, ret, sys32_, sname)
+#define ARCH_COMPAT_SYSCALL_DEFINE1_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(1, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE2_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(2, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE3_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(3, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE4_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(4, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE5_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(5, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE6_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(6, ret, sys32_, sname, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINE0(sname) COMPAT_SYSCALL_DEFINE0_RET(long, compat_sys_, sname)
+#define COMPAT_SYSCALL_DEFINE1(sname, ...) COMPAT_SYSCALL_DEFINEx(1, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE2(sname, ...) COMPAT_SYSCALL_DEFINEx(2, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE3(sname, ...) COMPAT_SYSCALL_DEFINEx(3, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE4(sname, ...) COMPAT_SYSCALL_DEFINEx(4, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE5(sname, ...) COMPAT_SYSCALL_DEFINEx(5, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE6(sname, ...) COMPAT_SYSCALL_DEFINEx(6, long, compat_sys_, sname, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINE0_RET(ret, sname) __COMPAT_SYSCALL_DEFINE0(ret, compat_sys_, sname)
+#define COMPAT_SYSCALL_DEFINE1_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE2_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE3_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE4_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE5_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE6_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_, sname, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINEx(x, ret, prefix, sname, ...) \
+ SYSCALL_METADATAx(prefix, sname, x, compat_syscall, __VA_ARGS__);\
+ asmlinkage ret SYSNAME(prefix, sname)(__SC_DECL##x(__VA_ARGS__))
+
+#define __COMPAT_SYSCALL_DEFINE0_RET(ret, prefix, sname) \
+ SYSCALL_METADATA0(prefix, sname, compat_syscall) \
+ asmlinkage ret SYSNAME(prefix, sname)()
#endif /* CONFIG_COMPAT */
@@ -268,38 +270,38 @@ extern struct trace_event_functions exit_syscall_print_funcs;
#endif
#define SYSCALL_DEFINEx(x, ret, sname, ...) \
- SYSCALL_METADATAx(sys##sname, sys##sname, x, syscall, __VA_ARGS__);\
+ SYSCALL_METADATAx(sys_, sname, x, syscall, __VA_ARGS__); \
__SYSCALL_DEFINEx(x, ret, sname, __VA_ARGS__)
-#define SYSCALL_DEFINE0_RET(ret, name) \
- SYSCALL_METADATA0(sys_##name, name, syscall) \
- asmlinkage ret sys_##name(void)
+#define SYSCALL_DEFINE0_RET(ret, sname) \
+ SYSCALL_METADATA0(sys_, sname, syscall) \
+ asmlinkage ret sys_##sname(void)
#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
-#define SYSCALL_DEFINE(name, x, ...) \
- SYSCALL_METADATAx(sys_##name, sys_##name, x, syscall, __VA_ARGS__);\
- static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__))
+#define SYSCALL_DEFINE(sname, x, ...) \
+ SYSCALL_METADATAx(sys_, sname, x, syscall, __VA_ARGS__); \
+ static inline long SYSC_##sname(__SC_DECL##x(__VA_ARGS__))
-#define __SYSCALL_DEFINEx(x, ret, name, ...) \
- asmlinkage ret sys##name(__SC_DECL##x(__VA_ARGS__)); \
- static inline ret SYSC##name(__SC_DECL##x(__VA_ARGS__)); \
- asmlinkage ret SyS##name(__SC_LONG##x(__VA_ARGS__)) \
+#define __SYSCALL_DEFINEx(x, ret, sname, ...) \
+ asmlinkage ret sys_##sname(__SC_DECL##x(__VA_ARGS__)); \
+ static inline ret SYSC_##sname(__SC_DECL##x(__VA_ARGS__)); \
+ asmlinkage ret SyS_##sname(__SC_LONG##x(__VA_ARGS__)) \
{ \
__SC_TEST##x(__VA_ARGS__); \
- return (ret) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \
+ return (ret) SYSC_##sname(__SC_CAST##x(__VA_ARGS__)); \
} \
- SYSCALL_ALIAS(sys##name, SyS##name); \
- static inline ret SYSC##name(__SC_DECL##x(__VA_ARGS__))
+ SYSCALL_ALIAS(sys_##sname, SyS_##sname); \
+ static inline ret SYSC_##sname(__SC_DECL##x(__VA_ARGS__))
#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
-#define SYSCALL_DEFINE(name, x, ...) \
- SYSCALL_METADATAx(sys_##name, sys_##name, x, syscall, __VA_ARGS__);\
- asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__))
+#define SYSCALL_DEFINE(sname, x, ...) \
+ SYSCALL_METADATAx(sys_, sname, x, syscall, __VA_ARGS__); \
+ asmlinkage long sys_##sname(__SC_DECL##x(__VA_ARGS__))
-#define __SYSCALL_DEFINEx(x, ret, name, ...) \
- asmlinkage ret sys##name(__SC_DECL##x(__VA_ARGS__))
+#define __SYSCALL_DEFINEx(x, ret, sname, ...) \
+ asmlinkage ret sys_##sname(__SC_DECL##x(__VA_ARGS__))
#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
--
1.7.1
^ permalink raw reply related
* [PATCH 35/40] trace syscalls, PPC: Convert PPC syscalls without long return types
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: Alexey Dobriyan, Jesper Nilsson, Thomas Gleixner, Peter Zijlstra,
Frederic Weisbecker, Jason Baron, Ingo Molnar, Chase Douglas,
Steven Rostedt, David S. Miller, Ingo Molnar, Paul Mackerras,
Ian Munsie, Andrew Morton, Christoph Hellwig, Eric W. Biederman
In-Reply-To: <1277287401-28571-1-git-send-email-imunsie@au1.ibm.com>
From: Ian Munsie <imunsie@au1.ibm.com>
This patch converts the PowerPC system calls with return types other
than long to use the various *SYSCALL_DEFINEx_RET family of macros so
their metadata is recorded for tracing.
This patch also renamed the ppc_rtas syscall to sys_rtas to fit in with
the naming convention of the SYSCALL_DEFINE macros.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
arch/powerpc/include/asm/syscalls.h | 2 +-
arch/powerpc/include/asm/systbl.h | 4 ++--
arch/powerpc/kernel/rtas.c | 2 +-
arch/powerpc/kernel/sys_ppc32.c | 33 +++++++++++++++++++--------------
arch/powerpc/kernel/syscalls.c | 12 ++++++------
5 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index 531b45d..050cca3 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -91,7 +91,7 @@ asmlinkage long sys_rt_sigaction(int sig,
const struct sigaction __user *act,
struct sigaction __user *oact, size_t sigsetsize);
asmlinkage long sys_ppc64_personality(unsigned long personality);
-asmlinkage int ppc_rtas(struct rtas_args __user *uargs);
+asmlinkage int sys_rtas(struct rtas_args __user *uargs);
asmlinkage time_t sys64_time(time_t __user * tloc);
asmlinkage long sys_rt_sigsuspend(sigset_t __user *unewset,
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index bbcc700..06c0a73 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -22,7 +22,7 @@ SYSCALL_SPU(chmod)
SYSCALL_SPU(lchown)
SYSCALL(ni_syscall)
OLDSYS(stat)
-SYSX_SPU(sys_lseek,ppc32_lseek,sys_lseek)
+SYSX_SPU(sys_lseek,sys32_lseek,sys_lseek)
SYSCALL_SPU(getpid)
COMPAT_SYS(mount)
SYSX(sys_ni_syscall,sys_oldumount,sys_oldumount)
@@ -258,7 +258,7 @@ COMPAT_SYS_SPU(utimes)
COMPAT_SYS_SPU(statfs64)
COMPAT_SYS_SPU(fstatfs64)
SYSX(sys_ni_syscall, sys_ppc_fadvise64_64, sys_ppc_fadvise64_64)
-PPC_SYS_SPU(rtas)
+SYSCALL_SPU(rtas)
OLDSYS(debug_setcontext)
SYSCALL(ni_syscall)
COMPAT_SYS(migrate_pages)
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 0e1ec6f..ca5f8ea 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -826,7 +826,7 @@ static int rtas_ibm_suspend_me(struct rtas_args *args)
}
#endif
-asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
+SYSCALL_DEFINE1_RET(int, rtas, struct rtas_args __user *, uargs)
{
struct rtas_args args;
unsigned long flags;
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index cf18164..431de48 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -167,7 +167,8 @@ COMPAT_SYSCALL_DEFINE4(sendfile, u32, out_fd, u32, in_fd,
return ret;
}
-asmlinkage int compat_sys_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
+COMPAT_SYSCALL_DEFINE4_RET(int, sendfile64, int, out_fd, int, in_fd,
+ compat_loff_t __user *, offset, s32, count)
{
mm_segment_t old_fs = get_fs();
int ret;
@@ -347,7 +348,8 @@ COMPAT_SYSCALL_DEFINE1(nice, u32, increment)
return sys_nice((int)increment);
}
-off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin)
+ARCH_COMPAT_SYSCALL_DEFINE3_RET(off_t, lseek,
+ unsigned int, fd, u32, offset, unsigned int, origin)
{
/* sign extend n */
return sys_lseek(fd, (int)offset, origin);
@@ -539,9 +541,9 @@ COMPAT_SYSCALL_DEFINE1(umask, u32, mask)
return sys_umask((int)mask);
}
-unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
- unsigned long prot, unsigned long flags,
- unsigned long fd, unsigned long pgoff)
+COMPAT_SYSCALL_DEFINE6_RET(unsigned long, mmap2, unsigned long, addr, size_t, len,
+ unsigned long, prot, unsigned long, flags,
+ unsigned long, fd, unsigned long, pgoff)
{
/* This should remain 12 even if PAGE_SIZE changes */
return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
@@ -558,25 +560,28 @@ COMPAT_SYSCALL_DEFINE3(tgkill, u32, tgid, u32, pid, int, sig)
* The 32 bit ABI passes long longs in an odd even register pair.
*/
-compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
- u32 reg6, u32 poshi, u32 poslo)
+COMPAT_SYSCALL_DEFINE6_RET(compat_ssize_t, pread64,
+ unsigned int, fd, char __user *, ubuf, compat_size_t, count,
+ u32, reg6, u32, poshi, u32, poslo)
{
return sys_pread64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
}
-compat_ssize_t compat_sys_pwrite64(unsigned int fd, char __user *ubuf, compat_size_t count,
- u32 reg6, u32 poshi, u32 poslo)
+COMPAT_SYSCALL_DEFINE6_RET(compat_ssize_t, pwrite64,
+ unsigned int, fd, char __user *, ubuf, compat_size_t, count,
+ u32, reg6, u32, poshi, u32, poslo)
{
return sys_pwrite64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
}
-compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 count)
+COMPAT_SYSCALL_DEFINE5_RET(compat_ssize_t, readahead,
+ int, fd, u32, r4, u32, offhi, u32, offlo, u32, count)
{
return sys_readahead(fd, ((loff_t)offhi << 32) | offlo, count);
}
-asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
- unsigned long high, unsigned long low)
+COMPAT_SYSCALL_DEFINE4_RET(int, truncate64, const char __user *, path,
+ u32, reg4, unsigned long, high, unsigned long, low)
{
return sys_truncate(path, (high << 32) | low);
}
@@ -588,8 +593,8 @@ COMPAT_SYSCALL_DEFINE6(fallocate, int, fd, int, mode,
((loff_t)lenhi << 32) | lenlo);
}
-asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high,
- unsigned long low)
+COMPAT_SYSCALL_DEFINE4_RET(int, ftruncate64, unsigned int, fd,
+ u32, reg4, unsigned long, high, unsigned long, low)
{
return sys_ftruncate(fd, (high << 32) | low);
}
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index f3bce3a..aee8ebb 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -62,16 +62,16 @@ out:
return ret;
}
-unsigned long sys_mmap2(unsigned long addr, size_t len,
- unsigned long prot, unsigned long flags,
- unsigned long fd, unsigned long pgoff)
+SYSCALL_DEFINE6_RET(unsigned long, mmap2, unsigned long, addr, size_t, len,
+ unsigned long, prot, unsigned long, flags,
+ unsigned long, fd, unsigned long, pgoff)
{
return do_mmap2(addr, len, prot, flags, fd, pgoff, PAGE_SHIFT-12);
}
-unsigned long sys_mmap(unsigned long addr, size_t len,
- unsigned long prot, unsigned long flags,
- unsigned long fd, off_t offset)
+SYSCALL_DEFINE6_RET(unsigned long, mmap, unsigned long, addr, size_t, len,
+ unsigned long, prot, unsigned long, flags,
+ unsigned long, fd, off_t, offset)
{
return do_mmap2(addr, len, prot, flags, fd, offset, PAGE_SHIFT);
}
--
1.7.1
^ permalink raw reply related
* [PATCH 36/40] trace syscalls: Early terminate search for sys_ni_syscall
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: Frederic Weisbecker, Jason Baron, Steven Rostedt, Ingo Molnar,
Paul Mackerras, Ian Munsie, Masami Hiramatsu
In-Reply-To: <1277287401-28571-1-git-send-email-imunsie@au1.ibm.com>
From: Ian Munsie <imunsie@au1.ibm.com>
Many system calls are unimplemented and mapped to sys_ni_syscall, but at
boot ftrace would still search through every syscall metadata entry for
a match which wouldn't be there.
This patch adds causes the search to terminate early if the system call
is not mapped.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
kernel/trace/trace_syscalls.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 264441e..58ef002 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -95,6 +95,9 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
stop = (struct syscall_metadata *)__stop_syscalls_metadata;
kallsyms_lookup(syscall, NULL, NULL, NULL, str);
+ if (arch_syscall_match_sym_name(str, "sys_ni_syscall"))
+ return NULL;
+
for ( ; start < stop; start++) {
if (start->name && arch_syscall_match_sym_name(str, start->name))
return start;
--
1.7.1
^ permalink raw reply related
* [PATCH 38/40] trace syscalls: Remove redundant test for unmapped compat syscalls
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: Frederic Weisbecker, Jason Baron, Steven Rostedt, Ingo Molnar,
Paul Mackerras, Ian Munsie, Masami Hiramatsu
In-Reply-To: <1277287401-28571-1-git-send-email-imunsie@au1.ibm.com>
From: Ian Munsie <imunsie@au1.ibm.com>
Since the ftrace event initialisation routine now verifies that either
the syscall number or the compat syscall number is valid and will not
create events for unmapped syscalls, it is unnecessary to explicitly
search for them, so remove it.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
kernel/trace/trace_syscalls.c | 20 --------------------
1 files changed, 0 insertions(+), 20 deletions(-)
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index c0041e3..108c2eb 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -528,26 +528,6 @@ int __init init_ftrace_syscalls(void)
meta->compat_syscall_nr = i;
compat_syscalls_metadata[i] = meta;
}
- /* now check if any compat_syscalls are not referenced */
- for (ftrace_event = __start_ftrace_events;
- (unsigned long)ftrace_event <
- (unsigned long)__stop_ftrace_events; ftrace_event++) {
-
- match = 0;
- if (!ftrace_event->name)
- continue;
- if (strcmp(ftrace_event->class->system, "compat_syscalls"))
- continue;
- for (i = 0; i < NR_syscalls_compat; i++) {
- if (ftrace_event->data ==
- compat_syscalls_metadata[i]) {
- match = 1;
- break;
- }
- }
- if (!match)
- ftrace_event->name = NULL;
- }
}
#endif
return 0;
--
1.7.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox