From patchwork Mon Feb 19 18:37:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 203207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1467068dyc; Mon, 19 Feb 2024 10:38:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVB3Qk8ldcH2BGyYJnSm/l/ynBAEoNwlOmx0/aAcRWAWSn06903nJhWSX3VtcVtvxowJZK9QXjDnFlOa+UgS8LQCujCJA== X-Google-Smtp-Source: AGHT+IHo3IKFF2VCo4U+bLM2GHnzNO6sxcq972/mO9FVEYYmbUk4YRpmbEgwjIlPJDY0yMZwENl8 X-Received: by 2002:a17:903:2310:b0:1db:c6ff:974d with SMTP id d16-20020a170903231000b001dbc6ff974dmr10148350plh.45.1708367921917; Mon, 19 Feb 2024 10:38:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708367921; cv=pass; d=google.com; s=arc-20160816; b=lxbMQIWGEQadEO29fmFi2SR4Y+59bqt3RwLiD8PwE0bLTEx8eiYDmKO2wjAKorZHq3 qFe8W/M2Q3RuwZjITPS3W7ImRvSI13x8LFD2BmSEkEa0P6eutFbAm8JUrVzXt1rSPULG yXjUp5x/J0tNfnY1ph2oOMolWhrJJKxnrqTGU0Ee0+mTOa27KW+uhXEn4dlngin8Lb2Q onoXJd7p7kYptV5ZO5Is784ZrxRCFYj8QMMNKfYUXn7STMOUWQRiMnIxdzHe5yRSpp8o CaBhsvxWf0AlIPbXmbz5W7ZqgieTPVcYVtvOZYxPTntRURXSQ0OBihwD7BkGBO583OrF Z80Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=R+1C2Zt8CnH0iCo7ZJRja2DS3pesy6U/jvuaPwN0/HM=; fh=n4H4sG50U6DIdypz596/kRWdpMDl152Oh9U3Sp1nb/I=; b=YVSyl2auQgpE7FLKfbFzLm/NGh6uJtU93envTdKtlQPu1Oy5fVbQgltzPE9RCUXvWO qEAnQDdhMXwl5/JU7sTA6guegzeGEeVJMy8dhg7H/GqkKwsJVWWtLakkZTp7RWCncZ6S TRl68xVTnxlzXxrQID5gfpfKztjw1LWlmUgtMyg2Wt1TL3M4K/2WwxX3GHc9Oe8KNhzJ KGIwKRm7xD95KIm6X4jLgwORws8fSuTKYFKdgJXyGS3X7UBEaiSRHUmzlRXupRO1/tnQ 1byrMDh7sRa30vMPI/VppXZCvhOwCuU/JYpqn1gIp8JWjlgFkvBOO4TfyLaf20J3z3tV Ok8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=b1dwxeR+; 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-71814-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71814-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id iw20-20020a170903045400b001d7391219bcsi4783316plb.255.2024.02.19.10.38.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 10:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71814-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=b1dwxeR+; 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-71814-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71814-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4994AB235E9 for ; Mon, 19 Feb 2024 18:38:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16D5F495D6; Mon, 19 Feb 2024 18:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="b1dwxeR+"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CuerjmFu" 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 E4ED92E3F1; Mon, 19 Feb 2024 18:37:25 +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=1708367847; cv=none; b=bfwmPp0mCooe/lSEoZoaSNKKYxnCn5JLPeDhUMchG4geBv5dXLm4D+zyklkpHJpR/KvoAQDuFGzzBZxyq965M+BaHzjPjT9IVkYUfhbBR09QAVNTCiiFXqpSJm7qbBx3sIedlFmhS3dErsCMTXlv+d6ENH20E5yJqua+6B8xjDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367847; c=relaxed/simple; bh=Luj1MF9VR1EItf/KkQIMsU5Rre93ssXek9Hhh7nL2yw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=mjFL4NpSmRnUYAwvVKiYBdyuVEWPDSMJK5gFKRj1BAVc5En7XmYwvJL/3yUanWQrEhygvFJbAPxQADNmvAe5Q497umcRXFi+D0PMXDP9t4+pa2Q/p+ZZaTDyREfL++o+3zyD+57k3JEalGkjTsCkmaa6ntcKAOgc40yQ8QWFvC4= 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=b1dwxeR+; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CuerjmFu; 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 Date: Mon, 19 Feb 2024 18:37:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708367844; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R+1C2Zt8CnH0iCo7ZJRja2DS3pesy6U/jvuaPwN0/HM=; b=b1dwxeR+V8DFS3RPg0rRMjOMApxn48Xst7q611ppsAzGlmCPgkuBmIVJQf+dkYtGMZuLKD Mp8VTVHkyqCZiuANWyrk8O28QYHYIpjApIY9E0m7zQGyuI2VtGdFi6qi/iVW3v8SXEagtV fSFet0DEselkxfYNobEpjGR3sveWBFBoBKb0iMk/Yqi2aFtd+eqjGsECF/IrYLKNHFggDw 6ZgqMbkBbjQ2+Rx3ql7YLzlJWN9kYn4PY+Vlh3DfN8CzSJ/IlCwWAFZrmaPAO9sZgiChv/ 1b2S1doZBSHeQ3ATKn0RcQtkDRrtSsy63cakMYb49PcAzHhAiKDVR5jya9c8gQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708367844; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R+1C2Zt8CnH0iCo7ZJRja2DS3pesy6U/jvuaPwN0/HM=; b=CuerjmFuYozV8xT6VntgMJuHCrKD8HWq+x2du8Ye9QsPEE5sdKi4I/cnhwihOm/dKAMFdp HBirXDqhaV8MS2Dg== From: "tip-bot2 for James Morse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Add CPU offline callback for resctrl work Cc: James Morse , "Borislav Petkov (AMD)" , Shaopeng Tan , Reinette Chatre , Babu Moger , Peter Newman , Carl Worth , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240213184438.16675-23-james.morse@arm.com> References: <20240213184438.16675-23-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170836784318.398.13490664857150950536.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790810775887414856 X-GMAIL-MSGID: 1791353602181655103 The following commit has been merged into the x86/cache branch of tip: Commit-ID: 258c91e84fedc789353a35ad91d827a9111d3cbd Gitweb: https://git.kernel.org/tip/258c91e84fedc789353a35ad91d827a9111d3cbd Author: James Morse AuthorDate: Tue, 13 Feb 2024 18:44:36 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 16 Feb 2024 19:18:33 +01:00 x86/resctrl: Add CPU offline callback for resctrl work The resctrl architecture specific code may need to free a domain when a CPU goes offline, it also needs to reset the CPUs PQR_ASSOC register. Amongst other things, the resctrl filesystem code needs to clear this CPU from the cpu_mask of any control and monitor groups. Currently, this is all done in core.c and called from resctrl_offline_cpu(), making the split between architecture and filesystem code unclear. Move the filesystem work to remove the CPU from the control and monitor groups into a filesystem helper called resctrl_offline_cpu(), and rename the one in core.c resctrl_arch_offline_cpu(). Signed-off-by: James Morse Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger Tested-by: Shaopeng Tan Tested-by: Peter Newman Tested-by: Babu Moger Tested-by: Carl Worth # arm64 Link: https://lore.kernel.org/r/20240213184438.16675-23-james.morse@arm.com Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/resctrl/core.c | 25 +++++-------------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 24 ++++++++++++++++++++++++- include/linux/resctrl.h | 1 +- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 55322ba..4aedefa 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -625,31 +625,15 @@ static int resctrl_arch_online_cpu(unsigned int cpu) return 0; } -static void clear_childcpus(struct rdtgroup *r, unsigned int cpu) +static int resctrl_arch_offline_cpu(unsigned int cpu) { - struct rdtgroup *cr; - - list_for_each_entry(cr, &r->mon.crdtgrp_list, mon.crdtgrp_list) { - if (cpumask_test_and_clear_cpu(cpu, &cr->cpu_mask)) { - break; - } - } -} - -static int resctrl_offline_cpu(unsigned int cpu) -{ - struct rdtgroup *rdtgrp; struct rdt_resource *r; mutex_lock(&rdtgroup_mutex); + resctrl_offline_cpu(cpu); + for_each_capable_rdt_resource(r) domain_remove_cpu(cpu, r); - list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) { - if (cpumask_test_and_clear_cpu(cpu, &rdtgrp->cpu_mask)) { - clear_childcpus(rdtgrp, cpu); - break; - } - } clear_closid_rmid(cpu); mutex_unlock(&rdtgroup_mutex); @@ -971,7 +955,8 @@ static int __init resctrl_late_init(void) state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/resctrl/cat:online:", - resctrl_arch_online_cpu, resctrl_offline_cpu); + resctrl_arch_online_cpu, + resctrl_arch_offline_cpu); if (state < 0) return state; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index f5688c7..5bd3d8f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4017,6 +4017,30 @@ void resctrl_online_cpu(unsigned int cpu) cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); } +static void clear_childcpus(struct rdtgroup *r, unsigned int cpu) +{ + struct rdtgroup *cr; + + list_for_each_entry(cr, &r->mon.crdtgrp_list, mon.crdtgrp_list) { + if (cpumask_test_and_clear_cpu(cpu, &cr->cpu_mask)) + break; + } +} + +void resctrl_offline_cpu(unsigned int cpu) +{ + struct rdtgroup *rdtgrp; + + lockdep_assert_held(&rdtgroup_mutex); + + list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) { + if (cpumask_test_and_clear_cpu(cpu, &rdtgrp->cpu_mask)) { + clear_childcpus(rdtgrp, cpu); + break; + } + } +} + /* * rdtgroup_init - rdtgroup initialization * diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index ccbbbe5..270ff1d 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -226,6 +226,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d); void resctrl_offline_domain(struct rdt_resource *r, struct rdt_domain *d); void resctrl_online_cpu(unsigned int cpu); +void resctrl_offline_cpu(unsigned int cpu); /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid