* [GIT PULL] oprofile fixes for v2.6.37
@ 2010-12-29 14:47 Robert Richter
2010-12-29 16:37 ` Ingo Molnar
0 siblings, 1 reply; 9+ messages in thread
From: Robert Richter @ 2010-12-29 14:47 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net
Ingo,
please pull oprofile fixes for v2.6.37 (tip/perf/urgent):
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent
(uploaded but not yet sync'ed until now)
Thanks,
-Robert
The following changes since commit e1e359273576ee8fe27021356b064c772ed29af3:
ring_buffer: Off-by-one and duplicate events in ring_buffer_read_page (2010-12-23 12:09:30 -0500)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent
Andrew Morton (1):
arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU
arch/x86/oprofile/op_model_amd.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
--
Advanced Micro Devices, Inc.
Operating System Research Center
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [GIT PULL] oprofile fixes for v2.6.37 2010-12-29 14:47 [GIT PULL] oprofile fixes for v2.6.37 Robert Richter @ 2010-12-29 16:37 ` Ingo Molnar 2010-12-30 13:08 ` Robert Richter 0 siblings, 1 reply; 9+ messages in thread From: Ingo Molnar @ 2010-12-29 16:37 UTC (permalink / raw) To: Robert Richter Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net, Peter Zijlstra, Frédéric Weisbecker * Robert Richter <robert.richter@amd.com> wrote: > Ingo, > > please pull oprofile fixes for v2.6.37 (tip/perf/urgent): > > git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent > > (uploaded but not yet sync'ed until now) > > Thanks, > > -Robert > > > The following changes since commit e1e359273576ee8fe27021356b064c772ed29af3: > > ring_buffer: Off-by-one and duplicate events in ring_buffer_read_page (2010-12-23 12:09:30 -0500) > > are available in the git repository at: > git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent > > Andrew Morton (1): > arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU > > arch/x86/oprofile/op_model_amd.c | 6 ++++++ > 1 files changed, 6 insertions(+), 0 deletions(-) Hm, i'm not sure this fix is correct: static int op_amd_init(struct oprofile_operations *ops) { + /* + * init_ibs() preforms implictly cpu-local operations, so pin this + * thread to its current CPU + */ + preempt_disable(); init_ibs(); + preempt_enable(); If init_ibs() is indeed CPU local, then it needs to be called on all CPUs. Does that happen and if not why not? AFAICS it's only called on one CPU. Thanks, Ingo ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [GIT PULL] oprofile fixes for v2.6.37 2010-12-29 16:37 ` Ingo Molnar @ 2010-12-30 13:08 ` Robert Richter 2010-12-30 17:38 ` Ingo Molnar 0 siblings, 1 reply; 9+ messages in thread From: Robert Richter @ 2010-12-30 13:08 UTC (permalink / raw) To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net, Peter Zijlstra, Frédéric Weisbecker On 29.12.10 11:37:43, Ingo Molnar wrote: > Hm, i'm not sure this fix is correct: > > static int op_amd_init(struct oprofile_operations *ops) > { > + /* > + * init_ibs() preforms implictly cpu-local operations, so pin this > + * thread to its current CPU > + */ > + preempt_disable(); > init_ibs(); > + preempt_enable(); > > If init_ibs() is indeed CPU local, then it needs to be called on all CPUs. > Does that happen and if not why not? AFAICS it's only called on one CPU. It is correct to run init_ibs() only on one cpu. It only checks the ibs capabilities and sets up pci devices (if necessary). It runs only on one cpu but operates with the local APIC and some MSRs, thus it is better to disable preemption. The cpu setup itself runs in op_amd_setup_ctrs() which is per cpu. -Robert -- Advanced Micro Devices, Inc. Operating System Research Center ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [GIT PULL] oprofile fixes for v2.6.37 2010-12-30 13:08 ` Robert Richter @ 2010-12-30 17:38 ` Ingo Molnar 2011-01-03 11:15 ` [PATCH] arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU Robert Richter 0 siblings, 1 reply; 9+ messages in thread From: Ingo Molnar @ 2010-12-30 17:38 UTC (permalink / raw) To: Robert Richter Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net, Peter Zijlstra, Frédéric Weisbecker * Robert Richter <robert.richter@amd.com> wrote: > On 29.12.10 11:37:43, Ingo Molnar wrote: > > > Hm, i'm not sure this fix is correct: > > > > static int op_amd_init(struct oprofile_operations *ops) > > { > > + /* > > + * init_ibs() preforms implictly cpu-local operations, so pin this > > + * thread to its current CPU > > + */ > > + preempt_disable(); > > init_ibs(); > > + preempt_enable(); > > > > If init_ibs() is indeed CPU local, then it needs to be called on all CPUs. Does > > that happen and if not why not? AFAICS it's only called on one CPU. > > It is correct to run init_ibs() only on one cpu. It only checks the ibs > capabilities and sets up pci devices (if necessary). It runs only on one cpu but > operates with the local APIC and some MSRs, thus it is better to disable > preemption. Ok, but in that case the prempt_disable()/enable() should be put into init_ibs(), not be open-coded at the caller like that. The comment about its cpu-localness could move to init_ibs() as well. Thanks, Ingo ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU 2010-12-30 17:38 ` Ingo Molnar @ 2011-01-03 11:15 ` Robert Richter 2011-01-03 12:03 ` Ingo Molnar 0 siblings, 1 reply; 9+ messages in thread From: Robert Richter @ 2011-01-03 11:15 UTC (permalink / raw) To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net, Peter Zijlstra, Frédéric Weisbecker, atswartz, Rafael J. Wysocki, Dan Carpenter, Andrew Morton, stable On 30.12.10 12:38:47, Ingo Molnar wrote: > > * Robert Richter <robert.richter@amd.com> wrote: > > > On 29.12.10 11:37:43, Ingo Molnar wrote: > > > > > Hm, i'm not sure this fix is correct: > > > > > > static int op_amd_init(struct oprofile_operations *ops) > > > { > > > + /* > > > + * init_ibs() preforms implictly cpu-local operations, so pin this > > > + * thread to its current CPU > > > + */ > > > + preempt_disable(); > > > init_ibs(); > > > + preempt_enable(); > > > > > > If init_ibs() is indeed CPU local, then it needs to be called on all CPUs. Does > > > that happen and if not why not? AFAICS it's only called on one CPU. > > > > It is correct to run init_ibs() only on one cpu. It only checks the ibs > > capabilities and sets up pci devices (if necessary). It runs only on one cpu but > > operates with the local APIC and some MSRs, thus it is better to disable > > preemption. > > Ok, but in that case the prempt_disable()/enable() should be put into init_ibs(), > not be open-coded at the caller like that. > > The comment about its cpu-localness could move to init_ibs() as well. Ingo, the patch below addresses this. Please apply to tip/perf/urgent. Thanks, -Robert -- >From 41659787561d3b384dac0b8458de95e35d8f2a34 Mon Sep 17 00:00:00 2001 From: Robert Richter <robert.richter@amd.com> Date: Mon, 3 Jan 2011 10:36:53 +0100 Subject: [PATCH] arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU Disable preemption in init_ibs(). The function only checks the ibs capabilities and sets up pci devices (if necessary). It runs only on one cpu but operates with the local APIC and some MSRs, thus it is better to disable preemption. [ 7.034377] BUG: using smp_processor_id() in preemptible [00000000] code: modprobe/483 [ 7.034385] caller is setup_APIC_eilvt+0x155/0x180 [ 7.034389] Pid: 483, comm: modprobe Not tainted 2.6.37-rc1-20101110+ #1 [ 7.034392] Call Trace: [ 7.034400] [<ffffffff812a2b72>] debug_smp_processor_id+0xd2/0xf0 [ 7.034404] [<ffffffff8101e985>] setup_APIC_eilvt+0x155/0x180 [ 7.034413] [<ffffffffa002e168>] op_amd_init+0x88/0x2b0 [oprofile] [ 7.034420] [<ffffffffa0043000>] ? oprofile_init+0x0/0x42 [oprofile] [ 7.034425] [<ffffffffa0043315>] op_nmi_init+0x249/0x2af [oprofile] [ 7.034431] [<ffffffffa00430b4>] oprofile_arch_init+0x11/0x29 [oprofile] [ 7.034437] [<ffffffffa0043010>] oprofile_init+0x10/0x42 [oprofile] [ 7.034441] [<ffffffff810001e3>] do_one_initcall+0x43/0x170 [ 7.034445] [<ffffffff8108a52a>] sys_init_module+0xba/0x200 [ 7.034449] [<ffffffff8100285b>] system_call_fastpath+0x16/0x1b Addresses https://bugzilla.kernel.org/show_bug.cgi?id=22812 Reported-by: <atswartz@gmail.com> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Cc: Dan Carpenter <error27@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: <stable@kernel.org> [2.6.37.x] Signed-off-by: Robert Richter <robert.richter@amd.com> --- arch/x86/oprofile/op_model_amd.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c index a011bcc..8d7d883 100644 --- a/arch/x86/oprofile/op_model_amd.c +++ b/arch/x86/oprofile/op_model_amd.c @@ -630,7 +630,14 @@ static int __init_ibs_nmi(void) return 0; } -/* initialize the APIC for the IBS interrupts if available */ +/* + * check and reserve APIC extended interrupt LVT offset for IBS if + * available + * + * init_ibs() preforms implicitly cpu-local operations, so pin this + * thread to its current CPU + */ + static void init_ibs(void) { ibs_caps = get_ibs_caps(); @@ -638,13 +645,15 @@ static void init_ibs(void) if (!ibs_caps) return; - if (__init_ibs_nmi()) { + preempt_disable(); + + if (__init_ibs_nmi()) ibs_caps = 0; - return; - } + else + printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n", + (unsigned)ibs_caps); - printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n", - (unsigned)ibs_caps); + preempt_enable(); } static int (*create_arch_files)(struct super_block *sb, struct dentry *root); -- 1.7.3.2 -- Advanced Micro Devices, Inc. Operating System Research Center ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU 2011-01-03 11:15 ` [PATCH] arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU Robert Richter @ 2011-01-03 12:03 ` Ingo Molnar 2011-01-03 14:44 ` Robert Richter 0 siblings, 1 reply; 9+ messages in thread From: Ingo Molnar @ 2011-01-03 12:03 UTC (permalink / raw) To: Robert Richter Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net, Peter Zijlstra, Frédéric Weisbecker, atswartz, Rafael J. Wysocki, Dan Carpenter, Andrew Morton, stable * Robert Richter <robert.richter@amd.com> wrote: > static void init_ibs(void) > { > ibs_caps = get_ibs_caps(); this get_ibs_caps() call is percpu too - still it now runs with preempt off. > + printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n", > + (unsigned)ibs_caps); that cast looks ugly and unnecessary. I fixed both in the commit below. (not tested yet) Thanks, Ingo ---------------> >From c7c25802b39c443b3745cfa973dc49a97a3491f8 Mon Sep 17 00:00:00 2001 From: Robert Richter <robert.richter@amd.com> Date: Mon, 3 Jan 2011 12:15:14 +0100 Subject: [PATCH] arch/x86/oprofile/op_model_amd.c: Perform initialisation on a single CPU Disable preemption in init_ibs(). The function only checks the ibs capabilities and sets up pci devices (if necessary). It runs only on one cpu but operates with the local APIC and some MSRs, thus it is better to disable preemption. [ 7.034377] BUG: using smp_processor_id() in preemptible [00000000] code: modprobe/483 [ 7.034385] caller is setup_APIC_eilvt+0x155/0x180 [ 7.034389] Pid: 483, comm: modprobe Not tainted 2.6.37-rc1-20101110+ #1 [ 7.034392] Call Trace: [ 7.034400] [<ffffffff812a2b72>] debug_smp_processor_id+0xd2/0xf0 [ 7.034404] [<ffffffff8101e985>] setup_APIC_eilvt+0x155/0x180 [ ... ] Addresses https://bugzilla.kernel.org/show_bug.cgi?id=22812 Reported-by: <atswartz@gmail.com> Signed-off-by: Robert Richter <robert.richter@amd.com> Cc: oprofile-list@lists.sourceforge.net <oprofile-list@lists.sourceforge.net> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Rafael J. Wysocki <rjw@sisk.pl> Cc: Dan Carpenter <error27@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: <stable@kernel.org> [2.6.37.x] LKML-Reference: <20110103111514.GM4739@erda.amd.com> [ small cleanups ] Signed-off-by: Ingo Molnar <mingo@elte.hu> --- arch/x86/oprofile/op_model_amd.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c index a011bcc..7d90d47 100644 --- a/arch/x86/oprofile/op_model_amd.c +++ b/arch/x86/oprofile/op_model_amd.c @@ -630,21 +630,29 @@ static int __init_ibs_nmi(void) return 0; } -/* initialize the APIC for the IBS interrupts if available */ +/* + * check and reserve APIC extended interrupt LVT offset for IBS if + * available + * + * init_ibs() preforms implicitly cpu-local operations, so pin this + * thread to its current CPU + */ + static void init_ibs(void) { - ibs_caps = get_ibs_caps(); + preempt_disable(); + ibs_caps = get_ibs_caps(); if (!ibs_caps) - return; + goto out; - if (__init_ibs_nmi()) { + if (__init_ibs_nmi() < 0) ibs_caps = 0; - return; - } + else + printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n", ibs_caps); - printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n", - (unsigned)ibs_caps); +out: + preempt_enable(); } static int (*create_arch_files)(struct super_block *sb, struct dentry *root); ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU 2011-01-03 12:03 ` Ingo Molnar @ 2011-01-03 14:44 ` Robert Richter 0 siblings, 0 replies; 9+ messages in thread From: Robert Richter @ 2011-01-03 14:44 UTC (permalink / raw) To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net, Peter Zijlstra, Frédéric Weisbecker, atswartz@gmail.com, Rafael J. Wysocki, Dan Carpenter, Andrew Morton, stable@kernel.org Ingo, I tested your patch and it fixes the bug too. On 03.01.11 07:03:10, Ingo Molnar wrote: > > * Robert Richter <robert.richter@amd.com> wrote: > > > static void init_ibs(void) > > { > > ibs_caps = get_ibs_caps(); > > this get_ibs_caps() call is percpu too - still it now runs with preempt off. get_ibs_caps() uses the cpuid instruction and this is percpu. But mixed silicon support does not allow the use of different cpus with different cpuid features in one system, so it should be save to use it with preemption enabled. Also, since the check uses a combination of boot_cpu_has() and cpuid_eax(), disabling preemption would not help here. We would have to pin the init code to the boot cpu then. Suppose a boot cpu with ibs enabled and a secondary (init) cpu with ibs disabled. This will crash the system when accessing ibs msrs. Anyway, I am fine with your change. > > > + printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n", > > + (unsigned)ibs_caps); > > that cast looks ugly and unnecessary. Yes, this cast is unnecessary. > > I fixed both in the commit below. (not tested yet) Thanks for looking at this, -Robert -- Advanced Micro Devices, Inc. Operating System Research Center ^ permalink raw reply [flat|nested] 9+ messages in thread
* [GIT PULL] oprofile fixes for v2.6.37
@ 2010-10-29 10:04 Robert Richter
2010-10-29 10:57 ` Ingo Molnar
0 siblings, 1 reply; 9+ messages in thread
From: Robert Richter @ 2010-10-29 10:04 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net
Ingo,
please pull oprofile fixes v2.6.37:
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent
Thanks,
-Robert
The following changes since commit e25804a0327dad954f7d43803178fdef2fd35b4e:
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/urgent (2010-10-27 08:25:15 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git for-next
Santosh Shilimkar (1):
oprofile: Fix the hang while taking the cpu offline
Tejun Heo (1):
oprofile: Remove deprecated use of flush_scheduled_work()
drivers/oprofile/buffer_sync.c | 2 +-
drivers/oprofile/cpu_buffer.c | 10 +++++++---
drivers/oprofile/cpu_buffer.h | 1 +
drivers/oprofile/timer_int.c | 13 +++++++++++++
4 files changed, 22 insertions(+), 4 deletions(-)
--
Advanced Micro Devices, Inc.
Operating System Research Center
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [GIT PULL] oprofile fixes for v2.6.37 2010-10-29 10:04 [GIT PULL] oprofile fixes for v2.6.37 Robert Richter @ 2010-10-29 10:57 ` Ingo Molnar 0 siblings, 0 replies; 9+ messages in thread From: Ingo Molnar @ 2010-10-29 10:57 UTC (permalink / raw) To: Robert Richter Cc: linux-kernel@vger.kernel.org, oprofile-list@lists.sourceforge.net * Robert Richter <robert.richter@amd.com> wrote: > Ingo, > > please pull oprofile fixes v2.6.37: > > git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent > > Thanks, > > -Robert > > > The following changes since commit e25804a0327dad954f7d43803178fdef2fd35b4e: > > Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/urgent (2010-10-27 08:25:15 +0200) > > are available in the git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git for-next > > Santosh Shilimkar (1): > oprofile: Fix the hang while taking the cpu offline > > Tejun Heo (1): > oprofile: Remove deprecated use of flush_scheduled_work() > > drivers/oprofile/buffer_sync.c | 2 +- > drivers/oprofile/cpu_buffer.c | 10 +++++++--- > drivers/oprofile/cpu_buffer.h | 1 + > drivers/oprofile/timer_int.c | 13 +++++++++++++ > 4 files changed, 22 insertions(+), 4 deletions(-) Pulled, thanks Robert! Ingo ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-01-03 14:44 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-12-29 14:47 [GIT PULL] oprofile fixes for v2.6.37 Robert Richter 2010-12-29 16:37 ` Ingo Molnar 2010-12-30 13:08 ` Robert Richter 2010-12-30 17:38 ` Ingo Molnar 2011-01-03 11:15 ` [PATCH] arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU Robert Richter 2011-01-03 12:03 ` Ingo Molnar 2011-01-03 14:44 ` Robert Richter -- strict thread matches above, loose matches on Subject: below -- 2010-10-29 10:04 [GIT PULL] oprofile fixes for v2.6.37 Robert Richter 2010-10-29 10:57 ` Ingo Molnar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox