lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sat,  2 Jun 2012 13:37:54 -0400
From:	Prarit Bhargava <prarit@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Prarit Bhargava <prarit@...hat.com>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org
Subject: [PATCH] Fix booted_cores calculation in set_cpu_sibling_map()

git commit 316ad248307fba13be40f01e92a22b89457c32bc changed
 set_cpu_sibling_map() to a single loop.

On a 2 socket system with 4 nodes, with 8 cores/socket top of tree
now shows

.> cat /proc/cpuinfo | grep cores
cpu cores	: 2
cpu cores	: 4
cpu cores	: 5
cpu cores	: 6
cpu cores	: 7
cpu cores	: 8
cpu cores	: 9
cpu cores	: 10
cpu cores	: 2
cpu cores	: 4
cpu cores	: 5
cpu cores	: 6
cpu cores	: 7
cpu cores	: 8
cpu cores	: 9
cpu cores	: 10
cpu cores	: 15
cpu cores	: 15
cpu cores	: 13
cpu cores	: 11
cpu cores	: 9
cpu cores	: 7
cpu cores	: 5
cpu cores	: 3
cpu cores	: 15
cpu cores	: 15
cpu cores	: 13
cpu cores	: 11
cpu cores	: 9
cpu cores	: 7
cpu cores	: 5
cpu cores	: 3

This is wrong.  The kernel should show

cpu cores	: 8

for each entry.

set_cpu_sibling_map() must be two separate loops, the first which
calculates the cpu's sibling_maps and the second which determines
how many cores have been booted.  The code does a check on
(cpumask_weight(cpu_sibling_mask(cpu)).  The problem is that
the sibling_mask may not be fully populated by the time this
value is checked resulting in incorrect booted_cores values.

I've found this broken and tested the fix on both AMD multi-socket and Intel
multi-socket systems (as well as single socket single node systems).
-----8<-----

The code in set_cpu_sibling_map() checks the value of
cpu_sibling_mask(cpu) before the mask is fully populated.  This results in
an incorrect calculation of each cpu's booted_cores.  Move back to a two
pass mechanism to properly calculate booted_cores.

Signed-off-by: Prarit Bhargava <prarit@...hat.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: x86@...nel.org
---
 arch/x86/kernel/smpboot.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index f56f96d..019248e 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -381,6 +381,10 @@ void __cpuinit set_cpu_sibling_map(int cpu)
 
 		if ((i == cpu) || (has_mc && match_llc(c, o)))
 			link_mask(llc_shared, cpu, i);
+	}
+
+	for_each_cpu(i, cpu_sibling_setup_mask) {
+		o = &cpu_data(i);
 
 		if ((i == cpu) || (has_mc && match_mc(c, o))) {
 			link_mask(core, cpu, i);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ