From patchwork Tue Feb 13 21:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 200652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp815061dyb; Tue, 13 Feb 2024 13:21:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXktms+sYMn2QXZGQxFefQadtDJBFH+K6JzhrL0YkWsieQDkJIGoMhIz1rQlyZ3cr9BePdMPtDwcHSub93Zb3uTzO7vwA== X-Google-Smtp-Source: AGHT+IEx7rHDd4xcqxn+WhXQVq7C2QfhLSpk7e3oGSwCoPsYqrK7hThwV3DCxaIeWOur2k7DtQZ8 X-Received: by 2002:a05:6a21:3941:b0:19e:b534:1bcb with SMTP id ac1-20020a056a21394100b0019eb5341bcbmr1026386pzc.23.1707859269704; Tue, 13 Feb 2024 13:21:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707859269; cv=pass; d=google.com; s=arc-20160816; b=vMkaXE4N2xRfSejERk+sq7wnwCLDOJq9LxinO6bd9lG/AuF5aK5qRPcYt+Uhsq6Jb0 9/T28ZsM4WMuylNVzNsjew6rQ+ky07DXwYPyyuTUh9dZEwesCYVsbjxI9exc7IzQHpjf uMzqfK8W1EFNQb+kxWe8UgHbGcou2tgELTVO4iC1KMvaDnT3/AgqKNnq3iaZvDPfcXWc b7dcr5AqtjszpDSo51mjGJuxbrwR4od3rIR0zp3u5Tfdn0d2smKrDdoC8dLFyXVcYMw8 Xh3M+AtrxIOXRgAbb+PBDfGcY/HYvtrohtvy2+SOEbppckUtlAhk+KQj7OoqwC8eyqKc jzew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=h5Fk2rHdvsa9daqL+lfmpiGhGHrHMczyPypdwtxy44M=; fh=eaVFucfPFUjUGRzl0JMqcKA+44zc/f1jq3yvA2f87Ww=; b=C4vZ0/mkCXtJtxiKEq96/W/qy5Ic57BhdYg5YNGLfqTpqOABEaUZZmi5f1Ig+xNh2T gtWiXkB8dx6c9/YHBs8FrlWoE7tQRKffWHAWilUUyotBRB22b1z3pAT6wbrzsqkNHl++ Un6s+aoRxEIrd/ER0HYA/LswUMJqOdoQZ9K0WpheNv/+sOFrVLJwcG2U9vfnI+eLdL8U Kro7Ae8RwEZeLrtBzzZG/TtD+8MPseWZbs8ASchdFxbczE8PAnghAAAnv7AjryZQtHD/ kf+Hg10HUI5yUd+xJstkhmjTPifQObDIv8SKSByQ4ZZD4o7UhzwlATM3mekRwIagBIje 4C9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oPx1XJxS; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64309-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64309-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCUKAMCxMvg34hOmyy0wsfi3ZFCWavxKqaL6A4q6UEE4xorcuUL9iC5znaBGtUfYAh926sCx42zk1H0r7vzYqLgaHbWPBw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o30-20020a63731e000000b005d8c1d4553bsi2564317pgc.894.2024.02.13.13.21.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:21:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64309-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oPx1XJxS; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64309-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64309-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AB9C328D5AA for ; Tue, 13 Feb 2024 21:20:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 652C78594E; Tue, 13 Feb 2024 21:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oPx1XJxS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hmRhfhej" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E82D8527D for ; Tue, 13 Feb 2024 21:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858369; cv=none; b=eF5Nm7Kj3oIvvyr4ifqLlsUuSLkkldcSduHWLtddrCb/LUb0T8KSFEWlkXF7Wj4ki/pIcyhndikW7C1JtnlPtaYmxFrQJYnE+RSc9t6BOmjuZD33flFtefn5DJKRhpMezhyvyUROeOg+CLcCEZWdIWkwXKGHohR87fv8wvJGrTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858369; c=relaxed/simple; bh=GELcpW9HVBoRzmyXJvaQUEiRKMX+NhRhw6z94yRJV98=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=ZJoXhSBxUa33Rx6G1hKbJc5fRdFMSzuO5Vh83ZKddrtbRqflvMH0DTA/3dEpwHZKDUikG0rrccSUu9AqPpP1+z1kYFHOnyckSJJC26ksol7BFSgfu2rX/ONEVHl5Yb5R0TwNTqCbU1jUU4/77POZKtfOkGetYqQ+EdTGdhCxeac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oPx1XJxS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hmRhfhej; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240213210252.791176581@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707858366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=h5Fk2rHdvsa9daqL+lfmpiGhGHrHMczyPypdwtxy44M=; b=oPx1XJxS1VsEi9t/HVHvfVMWijw/db3doezwnh5CP26KnNRz4mcL+nH+zhg7LlksM40fDM Nf8nOn8W5hdxTf0BGzqCof/j6aa5m3z9lv7kpPQS01RAbHUBMhuY5ai1Iy9OXmUk/2PsrQ o7s7cHIOv85SM2wY6TDOuaG+4+OT4JjcZFpj5+PKHgsiC1ih1dsie+6mk3gRgYUjmSlHEs TcFnSITavX9Ip/wwxAaY2NhkPqR1JxfTrSL+RSiff81gIQ5gP4rW0IuvMR79za2j8bGfLS fWAMn3N1fxJZ5m+2fgTpfh/NFZlq6NJ2BmCXVThNn2MK3uKqVey45h89I24TjQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707858366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=h5Fk2rHdvsa9daqL+lfmpiGhGHrHMczyPypdwtxy44M=; b=hmRhfhejWNIOcYm5dSBmxst5vZzsUvoD3B4sy5hx/yqg361s9+Yuwi8/9NHytueP6Lt2z0 fM/5cYIra2odj2AQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Sohil Mehta , K Prateek Nayak , Kan Liang , Zhang Rui , "Paul E. McKenney" , Feng Tang , Andy Shevchenko , Michael Kelley , "Peter Zijlstra (Intel)" Subject: [patch 23/30] x86/cpu/topology: Simplify cpu_mark_primary_thread() References: <20240213205415.307029033@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 13 Feb 2024 22:06:06 +0100 (CET) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790820241681753739 X-GMAIL-MSGID: 1790820241681753739 From: Thomas Gleixner No point in creating a mask via fls(). smp_num_siblings is guaranteed to be a power of 2. So just using (smp_num_siblings - 1) has the same effect. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/topology.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -76,10 +76,7 @@ bool arch_match_cpu_phys_id(int cpu, u64 #ifdef CONFIG_SMP static void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid) { - /* Isolate the SMT bit(s) in the APICID and check for 0 */ - u32 mask = (1U << (fls(smp_num_siblings) - 1)) - 1; - - if (smp_num_siblings == 1 || !(apicid & mask)) + if (!(apicid & (smp_num_siblings - 1))) cpumask_set_cpu(cpu, &__cpu_primary_thread_mask); } #else