[PATCH][2.6.11-rc3-mm2] perfctr-2.7.10 API update 1/4: common
Andrew, This set of patches form the first half of a major perfctr API update. The goal is to change the upload-new-control-data system call to be much more generic and independent of struct layouts. To this end the upload-new-control-data syscall will become ret = sys_vperfctr_write(fd, namespace, data, datalen) where namespace determines how data is to be interpreted. Initially there will probably be one namespace for perfctr's software state, and one CPU-specific namespace for pure hardware state; the latter will probably be expressed generically as a array. This API change will however require that the write() operation doesn't imply a (re)start of the context, since usually more than one write will be needed to upload all control data. Therefore this first set of patches alter the API so that control data uploads and parameterless state changes are performed by different system calls. The current control() call becomes a light-weight write() call, but still using the old control data layout. A new unified control() call is introduced for state changes, replacing and extending the current unlink() and iresume() calls. perfctr-2.7.10 update, 1/4: - Added new sys_vperfctr_control(), with UNLINK, SUSPEND, RESUME, and CLEAR sub-commands. Deleted sys_vperfctr_unlink() and sys_vperfctr_iresume(). Changed sys_vperfctr_write() to only update control data and not reenable the context. RESUME now works both for resuming after overflow interrupts and for restarting after changing control data. - Renamed old sys_vperfctr_control() to sys_vperfctr_write(). Signed-off-by: Mikael Pettersson <[EMAIL PROTECTED]> drivers/perfctr/version.h |2 drivers/perfctr/virtual.c | 233 -- include/linux/perfctr.h | 19 ++- kernel/sys_ni.c |3 4 files changed, 159 insertions(+), 98 deletions(-) diff -rupN linux-2.6.11-rc3-mm2/drivers/perfctr/version.h linux-2.6.11-rc3-mm2.perfctr-2.7.10-common-update/drivers/perfctr/version.h --- linux-2.6.11-rc3-mm2/drivers/perfctr/version.h 2005-02-20 12:39:29.0 +0100 +++ linux-2.6.11-rc3-mm2.perfctr-2.7.10-common-update/drivers/perfctr/version.h 2005-02-20 13:17:43.0 +0100 @@ -1 +1 @@ -#define VERSION "2.7.9" +#define VERSION "2.7.10" diff -rupN linux-2.6.11-rc3-mm2/drivers/perfctr/virtual.c linux-2.6.11-rc3-mm2.perfctr-2.7.10-common-update/drivers/perfctr/virtual.c --- linux-2.6.11-rc3-mm2/drivers/perfctr/virtual.c 2005-02-20 12:39:29.0 +0100 +++ linux-2.6.11-rc3-mm2.perfctr-2.7.10-common-update/drivers/perfctr/virtual.c 2005-02-20 13:17:43.0 +0100 @@ -1,7 +1,7 @@ -/* $Id: virtual.c,v 1.110 2004/11/24 00:38:30 mikpe Exp $ +/* $Id: virtual.c,v 1.111 2005/02/20 11:56:44 mikpe Exp $ * Virtual per-process performance counters. * - * Copyright (C) 1999-2004 Mikael Pettersson + * Copyright (C) 1999-2005 Mikael Pettersson */ #include #include @@ -39,8 +39,10 @@ struct vperfctr { #ifdef CONFIG_PERFCTR_CPUS_FORBIDDEN_MASK atomic_t bad_cpus_allowed; #endif + unsigned int preserve; + unsigned int resume_cstatus; #ifdef CONFIG_PERFCTR_INTERRUPT_SUPPORT - unsigned int iresume_cstatus; + unsigned int ireload_needed; /* only valid if resume_cstatus != 0 */ #endif /* children_lock protects inheritance_id and children, when parent is not the one doing release_task() */ @@ -64,14 +66,8 @@ static inline void vperfctr_set_ihandler perfctr_cpu_set_ihandler(vperfctr_ihandler); } -static inline void vperfctr_clear_iresume_cstatus(struct vperfctr *perfctr) -{ - perfctr->iresume_cstatus = 0; -} - #else static inline void vperfctr_set_ihandler(void) { } -static inline void vperfctr_clear_iresume_cstatus(struct vperfctr *perfctr) { } #endif #ifdef CONFIG_PERFCTR_CPUS_FORBIDDEN_MASK @@ -280,10 +276,11 @@ static void vperfctr_handle_overflow(str __FUNCTION__, tsk->pid); return; } + perfctr->ireload_needed = 1; /* suspend a-mode and i-mode PMCs, leaving only TSC on */ /* XXX: some people also want to suspend the TSC */ - perfctr->iresume_cstatus = perfctr->cpu_state.cstatus; - if (perfctr_cstatus_has_tsc(perfctr->iresume_cstatus)) { + perfctr->resume_cstatus = perfctr->cpu_state.cstatus; + if (perfctr_cstatus_has_tsc(perfctr->resume_cstatus)) { perfctr->cpu_state.cstatus = perfctr_mk_cstatus(1, 0, 0); vperfctr_resume(perfctr); } else @@ -387,7 +384,7 @@ static void vperfctr_unlink(struct task_ task_unlock(owner); perfctr->cpu_state.cstatus = 0; - vperfctr_clear_iresume_cstatus(perfctr); + perfctr->resume_cstatus = 0; if (do_unlink) put_vperfctr(perfctr); } @@ -486,7 +483,7 @@ void __vperfctr_resume(struct vperfctr * if (unlikely(atomic_read(>bad_cpus_allowed)) &&
[PATCH][2.6.11-rc3-mm2] perfctr-2.7.10 API update 1/4: common
Andrew, This set of patches form the first half of a major perfctr API update. The goal is to change the upload-new-control-data system call to be much more generic and independent of struct layouts. To this end the upload-new-control-data syscall will become ret = sys_vperfctr_write(fd, namespace, data, datalen) where namespace determines how data is to be interpreted. Initially there will probably be one namespace for perfctr's software state, and one CPU-specific namespace for pure hardware state; the latter will probably be expressed generically as a reg.nr, reg.value array. This API change will however require that the write() operation doesn't imply a (re)start of the context, since usually more than one write will be needed to upload all control data. Therefore this first set of patches alter the API so that control data uploads and parameterless state changes are performed by different system calls. The current control() call becomes a light-weight write() call, but still using the old control data layout. A new unified control() call is introduced for state changes, replacing and extending the current unlink() and iresume() calls. perfctr-2.7.10 update, 1/4: - Added new sys_vperfctr_control(), with UNLINK, SUSPEND, RESUME, and CLEAR sub-commands. Deleted sys_vperfctr_unlink() and sys_vperfctr_iresume(). Changed sys_vperfctr_write() to only update control data and not reenable the context. RESUME now works both for resuming after overflow interrupts and for restarting after changing control data. - Renamed old sys_vperfctr_control() to sys_vperfctr_write(). Signed-off-by: Mikael Pettersson [EMAIL PROTECTED] drivers/perfctr/version.h |2 drivers/perfctr/virtual.c | 233 -- include/linux/perfctr.h | 19 ++- kernel/sys_ni.c |3 4 files changed, 159 insertions(+), 98 deletions(-) diff -rupN linux-2.6.11-rc3-mm2/drivers/perfctr/version.h linux-2.6.11-rc3-mm2.perfctr-2.7.10-common-update/drivers/perfctr/version.h --- linux-2.6.11-rc3-mm2/drivers/perfctr/version.h 2005-02-20 12:39:29.0 +0100 +++ linux-2.6.11-rc3-mm2.perfctr-2.7.10-common-update/drivers/perfctr/version.h 2005-02-20 13:17:43.0 +0100 @@ -1 +1 @@ -#define VERSION 2.7.9 +#define VERSION 2.7.10 diff -rupN linux-2.6.11-rc3-mm2/drivers/perfctr/virtual.c linux-2.6.11-rc3-mm2.perfctr-2.7.10-common-update/drivers/perfctr/virtual.c --- linux-2.6.11-rc3-mm2/drivers/perfctr/virtual.c 2005-02-20 12:39:29.0 +0100 +++ linux-2.6.11-rc3-mm2.perfctr-2.7.10-common-update/drivers/perfctr/virtual.c 2005-02-20 13:17:43.0 +0100 @@ -1,7 +1,7 @@ -/* $Id: virtual.c,v 1.110 2004/11/24 00:38:30 mikpe Exp $ +/* $Id: virtual.c,v 1.111 2005/02/20 11:56:44 mikpe Exp $ * Virtual per-process performance counters. * - * Copyright (C) 1999-2004 Mikael Pettersson + * Copyright (C) 1999-2005 Mikael Pettersson */ #include linux/config.h #include linux/init.h @@ -39,8 +39,10 @@ struct vperfctr { #ifdef CONFIG_PERFCTR_CPUS_FORBIDDEN_MASK atomic_t bad_cpus_allowed; #endif + unsigned int preserve; + unsigned int resume_cstatus; #ifdef CONFIG_PERFCTR_INTERRUPT_SUPPORT - unsigned int iresume_cstatus; + unsigned int ireload_needed; /* only valid if resume_cstatus != 0 */ #endif /* children_lock protects inheritance_id and children, when parent is not the one doing release_task() */ @@ -64,14 +66,8 @@ static inline void vperfctr_set_ihandler perfctr_cpu_set_ihandler(vperfctr_ihandler); } -static inline void vperfctr_clear_iresume_cstatus(struct vperfctr *perfctr) -{ - perfctr-iresume_cstatus = 0; -} - #else static inline void vperfctr_set_ihandler(void) { } -static inline void vperfctr_clear_iresume_cstatus(struct vperfctr *perfctr) { } #endif #ifdef CONFIG_PERFCTR_CPUS_FORBIDDEN_MASK @@ -280,10 +276,11 @@ static void vperfctr_handle_overflow(str __FUNCTION__, tsk-pid); return; } + perfctr-ireload_needed = 1; /* suspend a-mode and i-mode PMCs, leaving only TSC on */ /* XXX: some people also want to suspend the TSC */ - perfctr-iresume_cstatus = perfctr-cpu_state.cstatus; - if (perfctr_cstatus_has_tsc(perfctr-iresume_cstatus)) { + perfctr-resume_cstatus = perfctr-cpu_state.cstatus; + if (perfctr_cstatus_has_tsc(perfctr-resume_cstatus)) { perfctr-cpu_state.cstatus = perfctr_mk_cstatus(1, 0, 0); vperfctr_resume(perfctr); } else @@ -387,7 +384,7 @@ static void vperfctr_unlink(struct task_ task_unlock(owner); perfctr-cpu_state.cstatus = 0; - vperfctr_clear_iresume_cstatus(perfctr); + perfctr-resume_cstatus = 0; if (do_unlink) put_vperfctr(perfctr); } @@ -486,7 +483,7 @@ void __vperfctr_resume(struct vperfctr * if (unlikely(atomic_read(perfctr-bad_cpus_allowed))