From patchwork Tue Feb 13 18:44:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 200560 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp740468dyb; Tue, 13 Feb 2024 10:50:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWNT48Zxl7NQjtEcGJqbCq1XtPjZd/90h5GIbpxVu7cwbNPVh0IueSAffQxz7GAmc85qLDA980fkwkO0dmnPyxj88cF4Q== X-Google-Smtp-Source: AGHT+IHuNGeg3q9nJuzLo4ZhTlxi6QshaDa7ZQMXkIPclXezuysAAHeKnWW8OJx8jbbKXhDEZpOo X-Received: by 2002:a17:903:2284:b0:1d9:6063:89ce with SMTP id b4-20020a170903228400b001d9606389cemr4380372plh.31.1707850215241; Tue, 13 Feb 2024 10:50:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707850215; cv=pass; d=google.com; s=arc-20160816; b=YFB/ZasCMvE2qjPrsh0kuu7LaujX8VtqW5G4VekvTFkzfQbq60pEWi/NHouEO3SaV3 Htdcmh8tOwrir0CXJQHfzJSvcfrpQeUbFe1eBep6tEMF9fEDKYcTeX9X2gnzc6N4i02F t4MxVE300GfWVv1UAKN5mK/Xiekxjc5dkGFKnSMLZuX4bSfqf1Y2RehhxRrr6DDh7/Uf aQp2dyTONj7dgHPgB+pJxJEbWLvx4W/a+0KrP2QFc++aPKRV4mRkfsJR4txcJuMM78Zo h7aU5cyNOUjlJ2fSsMfZhOGi3JNukxdtfRlqg+Oz7OiqgyfOZd3lWGcJBjHqjPMGVEFX TIOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=F90YUNjz9EenpVEYCt+7SQWg4jTdf2x1VJplA11wTRw=; fh=dax1g7XTFfJLj00JREuJ7zWiJmQ7UDIdZSL00KcC16s=; b=Cv7PTbUuq54aUyEjYQzTYcMj03gg/jUi9+Jacwk1zK4/3omEY7LpvvBa8jnHfaogsD /InYDoNTE0Bm3pbszLYfBZc6h9DZLcKbjQqgm0OlyS6KX/lRDYFjAozBZ7s92L5NDZtO qsmtPX6/TKuTCuqlr3hs4SSTECmaNZYharCygOpYI6DgIoxSITWQdhaRBbD/mwNKgMBY LfjKNzdu2N/RUlVL3utVfzRY+R7rsERBlHuE/Wu2KfPHVTPJI7q8N27H4GOxphyeyTLT TiLtao5VoBrUcUlVFP7zDR5j76KF/8lQjEf7o2r/xVRLQOHNmt2JnXT8K++af0qIFnxi pxbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-64111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64111-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCURIErx8unQrpvaWm+uQ3rgQUko8BTP4gPwAWHSXyHwM9i5HI1FNo+9LOrmN/9CFhjoRlsnCg8BvnukZr3oHzcbMEQiiw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w26-20020a63af1a000000b005dc488101casi2313156pge.341.2024.02.13.10.50.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:50:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-64111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64111-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 D8AC7290624 for ; Tue, 13 Feb 2024 18:50:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69CD0626A4; Tue, 13 Feb 2024 18:46:12 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 557E360B8B for ; Tue, 13 Feb 2024 18:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707849970; cv=none; b=SvsU3LtYZHGs6xmMZmKEyq9zplT1JPClYKDe5K1YsaQNjm3kZyh4e7hOZWzD7/yRxLAFeeyK20enlfJs5x67ri4NpyTAFB3XXEOJgpdHEn3NvZpNR145VZizsslozwxK04ujut1qE6rM37Zag9B2HXj76EHgI5Ohhiy78FsKMUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707849970; c=relaxed/simple; bh=LMKCBuYvFmeGar0ZaGdEj75Qzv9aXDJQEL9P02vZS08=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AxvXy0EQh70BNGYz9SCaLsJwUhW5JOAX6JlzMBK1aQibkUVmzyh9zIc2Y8E/kbnbBxfRPkjo54zBTFqsyiUg22LKmZbhxQr+IZz1GkZPZAtKI4wvWTKms09ewGhkJTjTGQB6Yi5bZjuqVYDZ4rYjwCWVp1xm2lmBTbTjQev9WP4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 18B781576; Tue, 13 Feb 2024 10:46:50 -0800 (PST) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B41CC3F766; Tue, 13 Feb 2024 10:46:05 -0800 (PST) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Babu Moger Subject: [PATCH v9 20/24] x86/resctrl: Add CPU online callback for resctrl work Date: Tue, 13 Feb 2024 18:44:34 +0000 Message-Id: <20240213184438.16675-21-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240213184438.16675-1-james.morse@arm.com> References: <20240213184438.16675-1-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790810747007900117 X-GMAIL-MSGID: 1790810747007900117 The resctrl architecture specific code may need to create a domain when a CPU comes online, it also needs to reset the CPUs PQR_ASSOC register. The resctrl filesystem code needs to update the rdtgroup_default CPU mask when CPUs are brought online. Currently this is all done in one function, resctrl_online_cpu(). This will need to be split into architecture and filesystem parts before resctrl can be moved to /fs/. Pull the rdtgroup_default update work out as a filesystem specific cpu_online helper. resctrl_online_cpu() is the obvious name for this, which means the version in core.c needs renaming. resctrl_online_cpu() is called by the arch code once it has done the work to add the new CPU to any domains. In future patches, resctrl_online_cpu() will take the rdtgroup_mutex itself. Signed-off-by: James Morse Tested-by: Shaopeng Tan Tested-by: Peter Newman Tested-by: Babu Moger Tested-by: Carl Worth # arm64 Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger --- Changes since v3: * Renamed err to ret Changes since v4: * Changes in capitalisation. Changes since v5: * More changes in capitalisation. * Made resctrl_online_cpu() return void. --- arch/x86/kernel/cpu/resctrl/core.c | 8 ++++---- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++++++ include/linux/resctrl.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index d1dc80a21ea9..4627d447bc3d 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -606,16 +606,16 @@ static void clear_closid_rmid(int cpu) RESCTRL_RESERVED_CLOSID); } -static int resctrl_online_cpu(unsigned int cpu) +static int resctrl_arch_online_cpu(unsigned int cpu) { struct rdt_resource *r; mutex_lock(&rdtgroup_mutex); for_each_capable_rdt_resource(r) domain_add_cpu(cpu, r); - /* The cpu is set in default rdtgroup after online. */ - cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); clear_closid_rmid(cpu); + + resctrl_online_cpu(cpu); mutex_unlock(&rdtgroup_mutex); return 0; @@ -967,7 +967,7 @@ static int __init resctrl_late_init(void) state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/resctrl/cat:online:", - resctrl_online_cpu, resctrl_offline_cpu); + resctrl_arch_online_cpu, resctrl_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 ed5fc677a99d..38d3b19a3aca 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4007,6 +4007,14 @@ int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) return 0; } +void resctrl_online_cpu(unsigned int cpu) +{ + lockdep_assert_held(&rdtgroup_mutex); + + /* The CPU is set in default rdtgroup after online. */ + cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); +} + /* * rdtgroup_init - rdtgroup initialization * diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index bf460c912bf5..4c4bad3c34e4 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -223,6 +223,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type type); 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); /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid