Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1837502iof; Tue, 7 Jun 2022 12:19:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZtVCO52Io6BZi0WDTI0nP+m4xmPE77L3qaRBsBzd9nfTJpt2l0xHlkog5Ln+GJfrP1qwF X-Received: by 2002:a17:906:c154:b0:711:ce44:a0a0 with SMTP id dp20-20020a170906c15400b00711ce44a0a0mr12313820ejc.420.1654629573422; Tue, 07 Jun 2022 12:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654629573; cv=none; d=google.com; s=arc-20160816; b=OmKTQ1jzseiketeouJNyTMeBCTZm2IMijDcY1ZZ3FZYCcragi/wjksGiiOH3KGQacB hNo1aSfD5qJ4gWekPxvoN/t8jbXVSCvzCs7WKR2lmamwDwhBrfnLgSFp6F5RLEnSQpfp Eu58oD+AHKM2v6FdZpHK1TUsHuIT22b3e3CPCnEXEYKUvm65l1smSbukst6cbGMj5PrG WN2xhaA/4aQ7VOQSR4Y5DPFei7K4lwjqSh+ANCOzZY/1v5bc54YhBoiRrPUHi/l3T5qh MTPoQClKMWOJz52GGYce0MHBlNkQrNBqubgeWrmmdEtPS0CTq77fvl4ZVLTzNQBORpwN 8TwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=La3yVDE5BOoBewCNvt5Jc0/5dmYuFjTOf5W0TFnSMKw=; b=wNLToMgUH8G1+eSSQ03O/gWojLCDg4xWaz3TnYa552xiCZIJsbDQ7a70pypQ/3nF88 3L/5D7UkIHUEOWw1m9NVLbUkoJ5XtpaZEPOJMLXlykxftV93Pu8wmDU6S95KpZJ5HS0Q +V02IjwwxWKx6N49erGpFajLkplfgADWA+H2QLJosvvX9vkb1hwOEloXCjwECEwqgZ0X Z/lbmWTWrtq0Juwxyrj8ge5MMgT+y7Iozt2qILxzKyTzQkgbRFzLtwkPT6SQvsVAaCYz +xSldSKs7ivahbkh0tTKNN9oOtq1RQcG5YpAqwIwD64XnamUjA3gZ5qfXlctQUGWuQsf W3yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kcdLAD9l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f22-20020a0564021e9600b0042be3591e27si23961449edf.509.2022.06.07.12.19.05; Tue, 07 Jun 2022 12:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kcdLAD9l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351643AbiFGSaQ (ORCPT + 99 others); Tue, 7 Jun 2022 14:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351394AbiFGSCB (ORCPT ); Tue, 7 Jun 2022 14:02:01 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD9C12E33D for ; Tue, 7 Jun 2022 10:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654623863; x=1686159863; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=dcjI6c1qBy+95NmJsucYe4f7ZIyMQ6H0lcQn32Io+mw=; b=kcdLAD9lfNKgPYw7HIbTpdHjUeLd+YnwyjK/iEqixt0qzlog8YKBNGxr /ew6zD2AJZxEWNIfcK7VrCwbBgPjVNdnDdMnhT3HjCI8bv5KYiWFEK8uW Zlz3uhY92Am2MXuYTQd1lS2TgtzZIo2HCmhs+qSDCDw/IEVW6wqjK4X9t kUCC6Ceq40ourys/Rop5gv+RqhQSy6P4HlVCWLjqJ6jOyB+dua9uOzxIr w+BEX7NwYdIxXXzZsDfxUKQg5v6aUYYZ2bF9nlSi7rGjfQ0XCz2i3jO/V HfO8Q8s+YDyO5zxM5Mc3z4iva2bPPZm4tkCVUKJJbrEsrZSkbReAoPxTd g==; X-IronPort-AV: E=McAfee;i="6400,9594,10371"; a="274267366" X-IronPort-AV: E=Sophos;i="5.91,284,1647327600"; d="scan'208";a="274267366" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 10:44:23 -0700 X-IronPort-AV: E=Sophos;i="5.91,284,1647327600"; d="scan'208";a="609291334" Received: from schen9-mobl.amr.corp.intel.com ([10.251.8.166]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 10:44:22 -0700 Message-ID: <35202f2acb9367b926b2066af3f7f4731a9c5f47.camel@linux.intel.com> Subject: Re: [PATCH] x86: topology_update_package_map function doesn't use the return value From: Tim Chen To: Li kunyu , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, rafael.j.wysocki@intel.com, tony.luck@intel.com, tim.gardner@canonical.com, boris.ostrovsky@oracle.com Cc: peterz@infradead.org, ray.huang@amd.com, paulmck@kernel.org, ionela.voinescu@arm.com, linux-kernel@vger.kernel.org Date: Tue, 07 Jun 2022 10:44:22 -0700 In-Reply-To: <20220606122316.291022-1-kunyu@nfschina.com> References: <20220606122316.291022-1-kunyu@nfschina.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2022-06-06 at 20:23 +0800, Li kunyu wrote: > topology_update_package_map function could remove the return value, and > it could remove the BUG_ON check. > > Signed-off-by: Li kunyu As far as I can tell, topology_update_package_map() should always succeed and return 0. Either there is an existing mapping of the physical package to a logical package id and we don't have to do anything, or we assign a new logical package id to this physical package id that doesn't have a mapping. So I agree that checking for the failure and non-zero return of topology_update_package_map() is useless. Likewise, I think topology_update_die_map() should always succeed and we can remove checking of its return value. Reviewed-by: Tim Chen > --- > arch/x86/include/asm/topology.h | 6 +++--- > arch/x86/kernel/cpu/common.c | 2 +- > arch/x86/kernel/smpboot.c | 3 +-- > 3 files changed, 5 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h > index 458c891a8273..eabfb44b63ed 100644 > --- a/arch/x86/include/asm/topology.h > +++ b/arch/x86/include/asm/topology.h > @@ -136,7 +136,7 @@ static inline int topology_max_smt_threads(void) > return __max_smt_threads; > } > > -int topology_update_package_map(unsigned int apicid, unsigned int cpu); > +void topology_update_package_map(unsigned int apicid, unsigned int cpu); > int topology_update_die_map(unsigned int dieid, unsigned int cpu); > int topology_phys_to_logical_pkg(unsigned int pkg); > int topology_phys_to_logical_die(unsigned int die, unsigned int cpu); > @@ -144,8 +144,8 @@ bool topology_is_primary_thread(unsigned int cpu); > bool topology_smt_supported(void); > #else > #define topology_max_packages() (1) > -static inline int > -topology_update_package_map(unsigned int apicid, unsigned int cpu) { return 0; } > +static inline void > +topology_update_package_map(unsigned int apicid, unsigned int cpu) { } > static inline int > topology_update_die_map(unsigned int dieid, unsigned int cpu) { return 0; } > static inline int topology_phys_to_logical_pkg(unsigned int pkg) { return 0; } > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c > index c296cb1c0113..22d19a1feafd 100644 > --- a/arch/x86/kernel/cpu/common.c > +++ b/arch/x86/kernel/cpu/common.c > @@ -1673,7 +1673,7 @@ static void validate_apic_and_package_id(struct cpuinfo_x86 *c) > pr_err(FW_BUG "CPU%u: APIC id mismatch. Firmware: %x APIC: %x\n", > cpu, apicid, c->initial_apicid); > } > - BUG_ON(topology_update_package_map(c->phys_proc_id, cpu)); > + topology_update_package_map(c->phys_proc_id, cpu); > BUG_ON(topology_update_die_map(c->cpu_die_id, cpu)); > #else > c->logical_proc_id = 0; > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index 5e7f9532a10d..20c67cca245b 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -327,7 +327,7 @@ EXPORT_SYMBOL(topology_phys_to_logical_die); > * @pkg: The physical package id as retrieved via CPUID > * @cpu: The cpu for which this is updated > */ > -int topology_update_package_map(unsigned int pkg, unsigned int cpu) > +void topology_update_package_map(unsigned int pkg, unsigned int cpu) > { > int new; > > @@ -343,7 +343,6 @@ int topology_update_package_map(unsigned int pkg, unsigned int cpu) > } > found: > cpu_data(cpu).logical_proc_id = new; > - return 0; > } > /** > * topology_update_die_map - Update the physical to logical die map