From patchwork Mon Feb 19 18:37:24 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: 203208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1467224dyc; Mon, 19 Feb 2024 10:39:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWVLnzYD5DCmCS3YjrKH3DgRpc7iZ3uqsh/8EgthDyNw3C/P5oeXhD+GCeiw5nEIOsn0+inbmTQWTKJoBTFb1ubWljR5Q== X-Google-Smtp-Source: AGHT+IF0e+/IDwhN8EtcEjzG2DMp7xM0ls5zzZGlnGlHQ+KD1PmmnSFbGNHS2vDKQyQSj1G78DZP X-Received: by 2002:a17:902:d511:b0:1db:cf8c:d3c1 with SMTP id b17-20020a170902d51100b001dbcf8cd3c1mr9472402plg.57.1708367952091; Mon, 19 Feb 2024 10:39:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708367952; cv=pass; d=google.com; s=arc-20160816; b=Zoi51qQIvx5Qf465lDYr5p9Z9/n5S7yX1K7SS2dQ8lJFhO2jvjq5QJt45kmexgiIuS fV6HUdRDyZZiU+CyhxtmJm4WgTikZgqtg2aqiACqpkfiwmxbPzKzCLqNN+LkROiY6pf5 uaPQSv0DtoV/XLcG98G486kF+zAciLPaU2x8IGPraNc7Qs8kzC67oGkXHoTnG2HiVeCE Lt05lXO3yXE2YsCBSHJKMSbJ8MtBzCxtaVIsbVFypXh4yyyvznUOiYVryu9SV1Is87xA 1trGzcOcGkA3KF5HpyMWUJK9akfQJ7g7cFVIb1jo3h9SEnf0S0UAlr6QlaUcVA39+a8o LeBA== 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=im4eTnxYe/dWpIGVIntP3uihfKLk3cmjCJyiwPazH7I=; fh=n4H4sG50U6DIdypz596/kRWdpMDl152Oh9U3Sp1nb/I=; b=JYiMKh4nF7NKnegvBdByKJHIBBaCWi4M33C9gUsqYvx+qC3C2M+j6jhPe3QKjPOB5/ VYz+1Xd71BXzLmRdkhooXQD37BmekAR3Lih3zuez4o9r15Ynxee1wksXOK34fQX2Vd/w Cs9Aa4BiinELg7ohT61le6JypMlCkG3UvRfUmUX80dE8h6mqsIZfAn1LwST3YyhOlul9 UIAN2lq58OpvHZ3kajG517pcYtIVfUtpy/SNCQqUzR0XCokO9GYeuPK0AIAhDn8uA/xj 9AmShm/Iu3/0bbv+kskVwx/3k8Crptp/sXay4QEIn4RkXHbZEZ2wnQeJJrkUzBGPqX9E 7cxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jo3USZYp; 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-71816-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71816-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 n17-20020a170902e55100b001db729bd8d2si4786841plf.318.2024.02.19.10.39.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 10:39:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71816-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=jo3USZYp; 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-71816-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71816-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 98B8EB22847 for ; Mon, 19 Feb 2024 18:38:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E1784C3D2; Mon, 19 Feb 2024 18:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="jo3USZYp"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1Eq2INjj" 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 790E54205E; Mon, 19 Feb 2024 18:37:27 +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=1708367849; cv=none; b=hC9wMo804oBScwPvHB+OVtoZbUhIjnD8Ggjn9pGdbmHBCFLHx56K8a9haHc88qn8F/mLeUtLH3DSQJYQY1ucwot+ggZiN9XwtA4dgXad/fkD32wHVtRtkxnTu2r4jxRio6y/kL/TH74Rz/r0jb78hUX7DWZG/9NA2JwXx8fosAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367849; c=relaxed/simple; bh=B8IFfRq58UyVjexHBkD0EypTaxsVDPPKe/vxth21M5k=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=Y2LuQoAzoo3xO58aruFXr902EOjOSS9vmAfkSdDhTR8VZaW0OG5b/6ScsIDbDrUy+AB9+Klr3lKf3u9F6KcqEVvD2dGa7SwQghbg6YigXYSEs51rqpdM1lqP1h+L87bEHR4xaIT8GXyGIYI3WQrWKM4k9wlYttpixzzugMur44k= 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=jo3USZYp; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=1Eq2INjj; 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:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708367845; 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=im4eTnxYe/dWpIGVIntP3uihfKLk3cmjCJyiwPazH7I=; b=jo3USZYp6hviOrlZGAXqA6q2+IsvVEx7jQbsGEixQoEe9HHL5yYYDyuuIe/cg8g+uNooWl FWj+GBMWda4rgZQ+X02vGtJVsN2u/jFihO2Gjio1PHGxKeWss9drSHWQIXtyjmqLf8RYfA tN/vlpVYM63wr+Eu2JNCrbQERjv8BsS4qW+hxSS120eZ4ffPLQ+/97Px4gexjGOkkkRRNS 1wMWpza9qnGaJTIsnVhv2odtJziNPa93m+e6EKE/JIC+ZsEqZWA9ABWx/sF+FkktAa7eyx jaP9rsgQR9krbaQeV7aW6AIsAkCqJYLMQPzXZxVIkKKjcfIYvMkshy2AEFpecw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708367845; 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=im4eTnxYe/dWpIGVIntP3uihfKLk3cmjCJyiwPazH7I=; b=1Eq2INjjahEyWU1h1nPmj8PaQNwfrP5215KKjVsExucdSqwtLns+6QniatncqlmCKuAb69 nQRB7inyHdpvGtDg== 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 online 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-21-james.morse@arm.com> References: <20240213184438.16675-21-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: <170836784496.398.6142470608838836705.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: 1790810747007900117 X-GMAIL-MSGID: 1791353633537649965 The following commit has been merged into the x86/cache branch of tip: Commit-ID: 1b3e50ce7f5001f1e0edaf7d6abea43b264db7ee Gitweb: https://git.kernel.org/tip/1b3e50ce7f5001f1e0edaf7d6abea43b264db7ee Author: James Morse AuthorDate: Tue, 13 Feb 2024 18:44:34 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 16 Feb 2024 19:18:33 +01:00 x86/resctrl: Add CPU online callback for resctrl work 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(). It 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 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-21-james.morse@arm.com Signed-off-by: Borislav Petkov (AMD) --- 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 d1dc80a..4627d44 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 ed5fc67..38d3b19 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 bf460c9..4c4bad3 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