From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 12 Jun 2018 20:02:14 -0000 Received: from aserp2120.oracle.com ([141.146.126.78]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fSpUa-0003X1-KR for speck@linutronix.de; Tue, 12 Jun 2018 22:02:13 +0200 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5CJuOBD038602 for ; Tue, 12 Jun 2018 20:02:04 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2jgecxjv58-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 12 Jun 2018 20:02:04 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5CK2398005726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 12 Jun 2018 20:02:04 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5CK236x013714 for ; Tue, 12 Jun 2018 20:02:03 GMT Date: Tue, 12 Jun 2018 16:02:02 -0400 From: Konrad Rzeszutek Wilk Subject: [MODERATED] Re: [patch V2 02/12] x86/smp: Provide topology_is_primary_thread() Message-ID: <20180612200202.GQ2462@char.us.oracle.com> References: <20180606192714.754943543@linutronix.de> <20180606192807.093672737@linutronix.de> <20180611193245.GB25607@char.us.oracle.com> <1fce67a1-7eb8-7d08-6d0c-e97309cb5fff@citrix.com> MIME-Version: 1.0 In-Reply-To: <1fce67a1-7eb8-7d08-6d0c-e97309cb5fff@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Tue, Jun 12, 2018 at 11:31:50AM +0100, speck for Andrew Cooper wrote: > On 12/06/18 09:05, speck for Thomas Gleixner wrote: > > On Mon, 11 Jun 2018, speck for Konrad Rzeszutek Wilk wrote: > >> On Wed, Jun 06, 2018 at 09:27:16PM +0200, speck for Thomas Gleixner wrote: > >> Anyhow if we did have four siblings, the mask would end up with 11b > >> (see below): > >> > >> smp_num_siblings fls -1 1<< -1 > >> 1 (001b) 1 0 1 0 > >> 2 (010b) 2 1 2 01b > >> 4 (100b) 3 2 4 11b > > That's what I intended :) > > > >>> + return !(apicid & mask); > >> So with an normal 2-sibling, say APICID 0x76 and 0x77 with mask 1b: > >> > >> 0x76 01110110b & 01 -> !0 -> return 1 > >> 0x77 01110111b & 01 -> !1 -> return 0 > >> > >> that looks good. > >> > >> If this is a 4 thread. APICID 0x4, 0x5, and 0x6 > >> > >> 0x4 0100 & 11b -> 00 -> !0 -> return 1 > >> 0x5 0101 & 11b -> 01 -> !1 -> return 0 > >> 0x6 0110 & 11b -> 10 -> !1111..1101 -> return 0xffff..which cast to bool is 'true' [BAD] > >> > >> That is the 3rd sibling would be incorrectly identified as primary thread. > >> > >> I think? I would welcome somebody checking my logic over, but then > >> perhaps this is non-issue-b/c-we-don-do more than 2 so go away. > > You are somehow confusing '!' and '~' Um, moving right along.. Reviewed-by: Konrad Rzeszutek Wilk > > The original logic looks correct to me, and matches my equivalent in Xen. > > ~Andrew