Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp123633rdh; Tue, 13 Feb 2024 11:15:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVy+f8QOZ4tgzBzWwN7CWSy/G0NtvPirIwk0ARuJwf6nxt0PWSciJQp8C+jZQdMpJQydNYizUAttXg9B4elAejwguhqSuv5WKuKWY+S0Q== X-Google-Smtp-Source: AGHT+IEGZi6zTt/KkpRse/U4xY9PNZdF+cBIF3d2H+EHms3YZDWVBp4NW+Klqj4KVXM7RrMU5TTD X-Received: by 2002:a05:6a20:94c9:b0:19e:9728:f4a2 with SMTP id ht9-20020a056a2094c900b0019e9728f4a2mr5265044pzb.7.1707851701465; Tue, 13 Feb 2024 11:15:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707851701; cv=pass; d=google.com; s=arc-20160816; b=CQq2fWDvE4cs7Cie2UUei+YS1RtK8QXbrOVJv1yZHlehHhn0ea9Hw7w8HDg6r3lp4F BdW0Dfe1ytMMVzXXqchFrMOkmqNhyGi9IXWH3A07KTBsABG5pFGtllbXjQk5QFEa6Bwx OQKXrjEXEl1bovBNjXDgcwsM2KDMjZNT011H5qnV8TTq66FlH8CpIXNyxNx86aR2RV2J mqpSgRPw8E8xR/RlneLNeqdt//I0Kp3Y5lwOnPGfvdANS3OCcCFjTpLlKm1W16/FHjaz 72tsC/htBkq7x75TJA8KQOLch9W1cFR4hEXM//Ve6JAstaC/74dlkgsmjtnu11eZR5do qmxg== 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=SCW+R8ShWCIRcGvZ9dEncLHo5ZrKmnhnv0NnfQjEvLs=; b=bm5LdgVRd05FERIfSul/7/A0963XbdjjfUm96Yot5KR7YeQHmBnKGIXlCJNZBzM41I Bv3r7KbBAsfMR3Zyl00cMpKErpLKDyfAaO7tE+O45JfbwZBI6Ssbuzc6uPnUGr8x/ZjC P7BwXIin5rNatYr1eVQzr7NpvP39Giy5lFgJJs24QRR2ejOfQGaD0pHN/4ObNIznYQjb 4Fk5AgRjE5FCzcZG4F3hRtwLGThFM4896ikJMze9jMTYNVsZiONZ0qZ0XpJtcfA9e5Md rLZTNAAMQ7ZT23N/dn93Gx9QvFJ9EnvuN/MqV0t7D7DpeazU0t9Wk1cqkeeUpbQTanP3 xW1Q==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXRh7fYSya6sjtQvMbyxGHkD2uzXmlsFJ+P//ugu31QfMqBUsmcSTuwHg+mtcDyy0rl7OENiJNTSXEevyWq/kGZO2c0tRawMkF01FAMuQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id cd24-20020a056a02079800b005cdfd6f30a0si2370759pgb.748.2024.02.13.11.15.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 11:15:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64111-linux.lists.archive=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; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-64111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64111-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 03431B23895 for ; Tue, 13 Feb 2024 18:50:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6889F6216F; Tue, 13 Feb 2024 18:46:11 +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 Content-Transfer-Encoding: 8bit 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 -- 2.39.2