From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
pm list <linux-pm@lists.linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [Regression, post-2.6.34-rc1][PATCH] x86 / perf: Fix suspend to RAM on HP nx6325
Date: Sun, 21 Mar 2010 21:51:51 +0100 [thread overview]
Message-ID: <201003212151.51383.rjw@sisk.pl> (raw)
In-Reply-To: <alpine.LFD.2.00.1003211029480.18017@i5.linux-foundation.org>
On Sunday 21 March 2010, Linus Torvalds wrote:
>
> On Sat, 20 Mar 2010, Rafael J. Wysocki wrote:
> >
> > The appended patch fixes the breakage for me too.
>
> Please don't use a 'goto' for something like this.
>
> > 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);
> > }
>
> Just do
>
> raw_spin_lock(&amd_nb_lock);
> if (cpuhw->amd_nb) {
> if (!--cpuhw->amd_nb->refcnt)
> kfree(cpuhw->amd_nb);
> cpuhw->amd_nb = NULL;
> }
> raw_spin_unlock(&amd_nb_lock);
>
> instead. Much more readable.
>
> Let's keep 'goto' for cases where we have error returns that we don't want
> to nest, not trivial stuff like this.
OK
Rafael
---
From: Rafael J. Wysocki <rjw@sisk.pl>
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, 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@sisk.pl>
---
arch/x86/kernel/cpu/perf_event_amd.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
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,10 +348,12 @@ static void amd_pmu_cpu_offline(int cpu)
raw_spin_lock(&amd_nb_lock);
- if (--cpuhw->amd_nb->refcnt == 0)
- kfree(cpuhw->amd_nb);
+ if (cpuhw->amd_nb) {
+ if (--cpuhw->amd_nb->refcnt == 0)
+ kfree(cpuhw->amd_nb);
- cpuhw->amd_nb = NULL;
+ cpuhw->amd_nb = NULL;
+ }
raw_spin_unlock(&amd_nb_lock);
}
prev parent reply other threads:[~2010-03-21 20:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-20 14:07 [Regression, post-2.6.34-rc1][PATCH] x86 / perf: Fix suspend to RAM on HP nx6325 Rafael J. Wysocki
2010-03-20 17:36 ` Peter Zijlstra
2010-03-20 17:47 ` Linus Torvalds
2010-03-20 20:48 ` Rafael J. Wysocki
2010-03-21 1:10 ` Peter Zijlstra
2010-03-21 17:31 ` Linus Torvalds
2010-03-21 20:51 ` Rafael J. Wysocki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201003212151.51383.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox