From: Andre Przywara <andre.przywara@arm.com>
To: Borislav Petkov <bp@suse.de>, Sudeep Holla <sudeep.holla@arm.com>
Cc: linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org
Subject: Re: [PATCH RFT v2] x86: move cacheinfo sysfs to generic cacheinfo infrastructure
Date: Sun, 1 Mar 2015 22:39:24 +0000 [thread overview]
Message-ID: <1425249564-28347-1-git-send-email-andre.przywara@arm.com> (raw)
In-Reply-To: <20150224175749.GC3575@pd.tnic>
On Tue, 24 Feb 2015 18:57:49 +0100, Borislav Petkov wrote:
> On Mon, Feb 23, 2015 at 06:14:25PM +0000, Sudeep Holla wrote:
>> - Rebased on v4.0-rc1
>> - Fixed lockdep warning reported by Borislav
> You probably have fixed the lockdep splat but not the NULL pointer
> dereference which was there in the first mail I sent you. I'd suggest
> you find an AMD box with an L3 and do some testing yourself before
> sending out another version.
So I gave that a spin on my old PhenomII X6 box, and indeed there is a
NULL pointer dereference. I tracked it down to
__cache_amd_cpumap_setup(), where the sibling map for the L3 is
populated. When the function is called for the first CPU, subsequent
CPU's cacheinfo structures obviously haven't been initialized yet, so
the struct cpu_cacheinfo we obtain for the other CPUs is empty
(num_levels and num_leaves are 0). Dereferencing info_list + index is
then a bad idea.
I fixed it by simply skipping the sibling map setup in this case (see
the patch below). Later we revisit this code path because the most
outer loop iterates over all CPUs anyway, so the fields are valid then
and the sibling map is build up properly. Not sure if that is a proper
fix (should we check for info_list being NULL?, is num_levels the
right value?), but I don't feel like looking into this code deeper
than I already did (Sudeep should be decorated for doing that!).
Boris, can you try this on a Bulldozer class machine?
Sudeep, if Boris acknowledges this, can you merge those two lines (or
something similar) in your patch and repost it? I can give it a try
then again.
>
> Also, when testing, do a snapshot of the sysfs cache hierarchy by
> doing:
>
> grep . -EriIn /sys/devices/system/cpu/cpu?/cache/*
> before your changes and after and check for differences.
>
> We can't allow ourselves any differences because this is an API.
But as Sudeep mentioned, this is an orthogonal issue not directly
related to this patch.
Indeed I see a regression between 3.19.0 and a clean 4.0.0-rc1 in this
respect, the diff is like:
-cpu5/cache/index3/shared_cpu_map:00000000,0000003f
+cpu5/cache/index3/shared_cpu_map:3f
(for each cpu and index)
Can someone confirm (and investigate) this?
Cheers,
Andre.
---
arch/x86/kernel/cpu/intel_cacheinfo.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 5f3059c..1f69ce7 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -836,6 +836,8 @@ static int __cache_amd_cpumap_setup(unsigned int cpu, int index,
} else if (index == 3) {
for_each_cpu(i, cpu_llc_shared_mask(cpu)) {
this_cpu_ci = get_cpu_cacheinfo(i);
+ if (index >= this_cpu_ci->num_levels)
+ continue;
this_leaf = this_cpu_ci->info_list + index;
for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) {
if (!cpu_online(sibling))
--
1.8.4
next prev parent reply other threads:[~2015-03-01 22:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-08 7:50 [PATCH RFT] " Sudeep Holla
2015-01-23 13:55 ` Thomas Gleixner
2015-01-23 18:15 ` Borislav Petkov
2015-02-23 16:36 ` Sudeep Holla
2015-02-23 18:14 ` [PATCH RFT v2] " Sudeep Holla
2015-02-24 7:58 ` Ingo Molnar
2015-02-24 9:30 ` Sudeep Holla
2015-02-24 17:57 ` Borislav Petkov
2015-02-24 18:09 ` Sudeep Holla
2015-02-24 18:58 ` Borislav Petkov
2015-03-01 22:39 ` Andre Przywara [this message]
2015-03-02 10:17 ` Sudeep Holla
2015-03-03 18:45 ` Borislav Petkov
2015-03-03 18:53 ` Tejun Heo
2015-03-03 18:57 ` Borislav Petkov
2015-03-04 11:15 ` Sudeep Holla
2015-03-04 11:27 ` Borislav Petkov
2015-03-04 11:35 ` Sudeep Holla
2015-03-04 9:52 ` Sudeep Holla
2015-03-04 12:00 ` [PATCH v3] " Sudeep Holla
2015-03-04 12:27 ` Borislav Petkov
2015-03-05 8:16 ` Borislav Petkov
2015-03-05 9:28 ` Sudeep Holla
2015-03-10 11:37 ` Borislav Petkov
2015-03-10 11:53 ` Sudeep Holla
2015-03-10 14:22 ` Sudeep Holla
2015-03-10 14:26 ` Borislav Petkov
2015-03-10 14:35 ` Sudeep Holla
2015-03-11 13:36 ` Borislav Petkov
2015-03-11 15:44 ` Sudeep Holla
2015-03-11 20:23 ` Borislav Petkov
2015-03-09 14:46 ` [tip:x86/cpu] x86/cacheinfo: Move cacheinfo sysfs code to generic infrastructure tip-bot for Sudeep Holla
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=1425249564-28347-1-git-send-email-andre.przywara@arm.com \
--to=andre.przywara@arm.com \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sudeep.holla@arm.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®