From patchwork Fri May 12 21:07:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 93374 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5391604vqo; Fri, 12 May 2023 14:09:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7cBu85sXu9udk7f5DGmkaHZL1Kg1MyYBV0AZqGDmsii4omeVd0q8j2Nhwf2eltgmPIwTG5 X-Received: by 2002:a17:903:1c5:b0:1ac:8ee4:5e1b with SMTP id e5-20020a17090301c500b001ac8ee45e1bmr19365837plh.14.1683925739754; Fri, 12 May 2023 14:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683925739; cv=none; d=google.com; s=arc-20160816; b=AwcLM07o2bVyOpCvKiDBpRAoe9xIhDozlGx4WjKmtE8bOKrM5CR6vvAztHv/mh0UqD lRbBomr1i8eTSqQZ929YYGsIXm/E6Va5Yram3viyYZwrNBGCVLQrigAKlc6wu+qu4w8M 57nXlSLhMD3r8QPImPtB+0wznOz4Fl7Sr+6Rajh6WTkNG309L2KBV5ebwnO3Ne88EnAR lPqr79w+0wyuS8epeH+jWXiybmO/WAcht47ltIk4/E1rsIcLMPJTtg4Dq0Y2Y4nbh/Qf YetQvkqCwMQ904LIm95XH7dzfl/Pgb6cVOBdzAJd5byosdJOyQr0mqeOsQF9JEa465aD v/yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=eF12ofNTJSRvTVUxVjnfh7vrXqrzAu3KwLqma5Svbqk=; b=byuLbuw6RescdwJu6Oqpzh7pIOQP8OkorBsMKlgys6aldZUNcemSijm+OBZdY8dwZn T83KLYiRmBDyXs4HJtyETSukTv9/Z+fjIE+MRM2Ls/cGN+QWAa4jTexXY50yEQaoT1rq 69DO+PMVg+ymsIWBpa7OxzZtO67fsNcpw4vynFKbmJ1JkqaE9s3gCSdzJzjKv055tVdy TE1ITMiW/LeNGCHvptDF7cw6GbreFWt8JhB4NhaGUX5krNCUi8mAYpeWVcERLNTPnmx5 3YYGypCmeNJvEWOOWMwJaqxtGFz0Ppes6Ui4XxaBWghF5zeNa81DNBdOUUPHw2yQ75Ac zDuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UCtRDgTY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=JUU+NLGE; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a170902758200b001a9581bfb91si9175578pll.543.2023.05.12.14.08.47; Fri, 12 May 2023 14:08:59 -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=@linutronix.de header.s=2020 header.b=UCtRDgTY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=JUU+NLGE; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239824AbjELVII (ORCPT + 99 others); Fri, 12 May 2023 17:08:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239649AbjELVHf (ORCPT ); Fri, 12 May 2023 17:07:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90464D851; Fri, 12 May 2023 14:07:16 -0700 (PDT) Message-ID: <20230512205256.035041005@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1683925635; 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=eF12ofNTJSRvTVUxVjnfh7vrXqrzAu3KwLqma5Svbqk=; b=UCtRDgTYjJ+kttYU7M2mEpsUrBis05axy9leXWtF3JfKsHzJdY7XDzWQPHnc/2SfbSgxN3 8m5ad//4LAOnFAOL/Bgz84MaRBcO8q4cF80CAbsgBeiJOqNvHtlhaoNC/64M0YgHrD7WZF m7FV4aKz3m5h6Cp6yr8xhr2AsQLLE9oZWQrHYW7hmApYt9s+zdNMxCD8Sk8khgr3V7jlH9 24gCCAqrup+dWEuJ3AbsClaZO7eYMsrW2hnkYlv3wZF2rR4sXKxZwEhr7++CGNWie8aJ7i WfiNAqAgMWsw6ewnu1bT4mVJ2qzYDEvD4Kt4UFMTRKFhnF6SyLakq+SftbvVqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1683925635; 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=eF12ofNTJSRvTVUxVjnfh7vrXqrzAu3KwLqma5Svbqk=; b=JUU+NLGEbC5VmebxGTxNM/TRbUGPyU8jXOJXmTvwOZyX3Vb6ZSwKxKk/9v+Ol3pfmA4OJd pwHgp2Bl/LROYvCg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, David Woodhouse , Andrew Cooper , Brian Gerst , Arjan van de Veen , Paolo Bonzini , Paul McKenney , Tom Lendacky , Sean Christopherson , Oleksandr Natalenko , Paul Menzel , "Guilherme G. Piccoli" , Piotr Gorski , Usama Arif , Juergen Gross , Boris Ostrovsky , xen-devel@lists.xenproject.org, Russell King , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Guo Ren , linux-csky@vger.kernel.org, Thomas Bogendoerfer , linux-mips@vger.kernel.org, "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , linux-riscv@lists.infradead.org, Mark Rutland , Sabin Rapan , "Michael Kelley (LINUX)" , Ross Philipson Subject: [patch V4 11/37] x86/cpu/cacheinfo: Remove cpu_callout_mask dependency References: <20230512203426.452963764@linutronix.de> MIME-Version: 1.0 Date: Fri, 12 May 2023 23:07:14 +0200 (CEST) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765724116676413681?= X-GMAIL-MSGID: =?utf-8?q?1765724116676413681?= From: Thomas Gleixner cpu_callout_mask is used for the stop machine based MTRR/PAT init. In preparation of moving the BP/AP synchronization to the core hotplug code, use a private CPU mask for cacheinfo and manage it in the starting/dying hotplug state. Signed-off-by: Thomas Gleixner Tested-by: Michael Kelley --- arch/x86/kernel/cpu/cacheinfo.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -39,6 +39,8 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t /* Shared L2 cache maps */ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_l2c_shared_map); +static cpumask_var_t cpu_cacheinfo_mask; + /* Kernel controls MTRR and/or PAT MSRs. */ unsigned int memory_caching_control __ro_after_init; @@ -1172,8 +1174,10 @@ void cache_bp_restore(void) cache_cpu_init(); } -static int cache_ap_init(unsigned int cpu) +static int cache_ap_online(unsigned int cpu) { + cpumask_set_cpu(cpu, cpu_cacheinfo_mask); + if (!memory_caching_control || get_cache_aps_delayed_init()) return 0; @@ -1191,11 +1195,17 @@ static int cache_ap_init(unsigned int cp * lock to prevent MTRR entry changes */ stop_machine_from_inactive_cpu(cache_rendezvous_handler, NULL, - cpu_callout_mask); + cpu_cacheinfo_mask); return 0; } +static int cache_ap_offline(unsigned int cpu) +{ + cpumask_clear_cpu(cpu, cpu_cacheinfo_mask); + return 0; +} + /* * Delayed cache initialization for all AP's */ @@ -1210,9 +1220,12 @@ void cache_aps_init(void) static int __init cache_ap_register(void) { + zalloc_cpumask_var(&cpu_cacheinfo_mask, GFP_KERNEL); + cpumask_set_cpu(smp_processor_id(), cpu_cacheinfo_mask); + cpuhp_setup_state_nocalls(CPUHP_AP_CACHECTRL_STARTING, "x86/cachectrl:starting", - cache_ap_init, NULL); + cache_ap_online, cache_ap_offline); return 0; } -core_initcall(cache_ap_register); +early_initcall(cache_ap_register);