From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757479AbcCRPIR (ORCPT ); Fri, 18 Mar 2016 11:08:17 -0400 Received: from [198.137.202.9] ([198.137.202.9]:52151 "EHLO bombadil.infradead.org" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753585AbcCRPIO (ORCPT ); Fri, 18 Mar 2016 11:08:14 -0400 Message-Id: <20160318150538.482393396@infradead.org> User-Agent: quilt/0.61-1 Date: Fri, 18 Mar 2016 16:03:46 +0100 From: Peter Zijlstra To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, bp@alien8.de, aherrmann@suse.com, peterz@infradead.org, jencce.kernel@gmail.com Subject: [PATCH 1/3] x86/topology: Fix logical pkg mapping References: <20160318150345.146716865@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-x86-fix-logical-pkg.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org That first branch testing pkg against __max_logical_packages is wrong, because if the first pkg id is larger, then the find_first_zero will find us logical package id 0. However, if the second pkg id is indeed 0, we'll again claim it without testing if it was already taken. Also, it fails to print the mapping. Cc: Ingo Molnar Cc: Borislav Petkov Cc: Thomas Gleixner Cc: Andreas Herrmann Reported-by: Xiong Zhou Fixes: 1f12e32f4cd5 ("x86/topology: Create logical package id") Signed-off-by: Peter Zijlstra (Intel) Link: http://lkml.kernel.org/r/20160317095220.GO6344@twins.programming.kicks-ass.net --- arch/x86/kernel/cpu/amd.c | 8 ++++---- arch/x86/kernel/smpboot.c | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -274,11 +274,6 @@ int topology_update_package_map(unsigned if (test_and_set_bit(pkg, physical_package_map)) goto found; - if (pkg < __max_logical_packages) { - set_bit(pkg, logical_package_map); - physical_to_logical_pkg[pkg] = pkg; - goto found; - } new = find_first_zero_bit(logical_package_map, __max_logical_packages); if (new >= __max_logical_packages) { physical_to_logical_pkg[pkg] = -1;