Re: [Regression, post-2.6.34-rc1][PATCH] x86 / perf: Fix suspend to RAM on HP nx6325

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 20 March 2010, Linus Torvalds wrote:
> 
> On Sat, 20 Mar 2010, Peter Zijlstra wrote:
> >  
> >  	cpuhw = &per_cpu(cpu_hw_events, cpu);
> > +	if (!cpuhw)
> > +		return;
> 
> How can an address-of expression be NULL?
> 
> Yes, 'per_cpu()' is magic, but it shouldn't be possible to be _that_ 
> magic. It's rather against the whole C model.

Yeah.

A field in the object pointed to by it can be NULL, though.

The appended patch fixes the breakage for me too.

Rafael

---
From: Rafael J. Wysocki <rjw@xxxxxxx>
Subject: x86 / perf: Fix suspend to RAM on HP nx6325

Commit 3f6da3905398826d85731247e7fbcf53400c18bd
(perf: Rework and fix the arch CPU-hotplug hooks) broke suspend to
RAM on my HP nx6325 (and most likely on other AMD-based boxes too)
by allowing amd_pmu_cpu_offline() to be executed for CPUs that are
going offline as part of the suspend process.  The problem is that
cpuhw->amd_nb may be NULL already when amd_pmu_cpu_offline() is called, so the
function should make sure it's not NULL before accessing the object pointed to
by it.

Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>
---
 arch/x86/kernel/cpu/perf_event_amd.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: linux-2.6/arch/x86/kernel/cpu/perf_event_amd.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/perf_event_amd.c
+++ linux-2.6/arch/x86/kernel/cpu/perf_event_amd.c
@@ -348,11 +348,15 @@ static void amd_pmu_cpu_offline(int cpu)
 
 	raw_spin_lock(&amd_nb_lock);
 
+	if (!cpuhw->amd_nb)
+		goto unlock;
+
 	if (--cpuhw->amd_nb->refcnt == 0)
 		kfree(cpuhw->amd_nb);
 
 	cpuhw->amd_nb = NULL;
 
+ unlock:
 	raw_spin_unlock(&amd_nb_lock);
 }
 
_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux