From patchwork Mon Feb 19 18:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 203212 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1468667dyc; Mon, 19 Feb 2024 10:42:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWx+K7TGOrCYkw/Amde4BQ4i9PIMC5r12NEcoYWGvMHyA/0r2HSVoWD8qwk5UqBgwhhVrUFFX5ORil+VXRUuxezdEjn9g== X-Google-Smtp-Source: AGHT+IFE1RUb6SGN9qEfhCGrYlp+S3YzNM54kVwfpQjcZOJrNg7aTwIaatR1XNVwy5fY92P8pH7o X-Received: by 2002:a17:906:1cd3:b0:a3e:e04c:457 with SMTP id i19-20020a1709061cd300b00a3ee04c0457mr593577ejh.19.1708368158754; Mon, 19 Feb 2024 10:42:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708368158; cv=pass; d=google.com; s=arc-20160816; b=sTign6CWu6ZSBEs8FyZ6ZYPSnQ0RNDId22wYpDhzjAYVf1PCDQ1kvAAMihJBmckqmh 7yPuKGLAGggV2bfFq/u6K0zhug9apmB69cSkknUTBAmuUaCeOHa9gJJLVDGpoXA8tyGv /qzmpFeQzD/lM7Jy7D7cp9JFW6DvY4SIBU1KerHlwsDi8JbtYvIQzLtStTV4L2N6S9D1 tJId+nAlLp4AEGUWkLFqgHYTdOm6JExQiVgt2Q1lt1K1cawOGzbw73o8TgZWcPnEVQCn YCDf0D4/96vsm0HO5D8Gb8Sq3YsoPfjjMP8Mv9+D04VDOPeqvA+a7rj/sq1QaiiDNZoB +Ctg== 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=P8uQUEP7sHBDAE6xDrwE50fmOGZvNATtQCG6BlfpgkI=; fh=2Nokia4usuJZL0LYFy9hPoTAf1yv1JmL+nIzz3SoQTw=; b=nBGjG8EhFxZjd9aVukRIjvcRaGwpA+KQuwirBkj2YmejE8RGK0IoLRZoaT+MgTRaVL 65psFaYxIMoKip0aKJdz+ZqHBHTYgssBIpoJZaxboaaN6ZrUSuqaOeaH0ixc48OONlCI 7VlpjF6t8ahzIyc6Fo67BfUdNzcg5/Xm3kiU4E5ATJ1NZ5xWDtY3LAyYfBLAX31vU077 et/KsneKGgVsrTAYuJkUbqWspd7Jt8nXINy7449Eco2ejePK7yd7xk7A2lWeS3hdtuM/ 98s/VME5C+4yJsPddKRIABTW/Vm8Alnbaf5i+LYus03VUn1a0cvZqGURwLdZuQyNDTbw vnnA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ITcQVtQu; 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-71833-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71833-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q12-20020a170906770c00b00a3dd8442e14si2645007ejm.508.2024.02.19.10.42.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 10:42:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71833-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ITcQVtQu; 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-71833-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71833-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 61D3F1F23668 for ; Mon, 19 Feb 2024 18:42:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5200556752; Mon, 19 Feb 2024 18:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ITcQVtQu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="r9r6QyGj" 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 63F0853805; Mon, 19 Feb 2024 18:37:42 +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=1708367864; cv=none; b=Wcwhh2k1TNsejuIwGY09yDqsrE5QWR494OvsL+yLJ+hJTy/XrmW2uYq+zmvjWNLcihQGdnrJNkeYbUhCysYDmkagz2xkrEH5rDLan6fJE0tcaBLM3wW+ujoFFlIMrp+0W/G0lOxbMzaXkvZLYZJFjzpxnmC5m7+xpo6MIvech0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367864; c=relaxed/simple; bh=WCORwWdgbnnKQewSn/5SZtw1kNBcXmb3yv93ydSiP5Q=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=bFV+5jQ1GUmLy8BIO1IrRMUE1RNIPUUtVE/oJHoe1qGLUtbCVez4oHjfaKoZR1Ch/K0TC5H6VpEGTRi24GLiU+QXBvZTyX+Q0h1nlcC0P3Cd7uSBCBeVQmXwkTQKRWKcd0gNsBL8O0heczwaNxi8HCH/JNPsLDDzdJovTvb/UMs= 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=ITcQVtQu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=r9r6QyGj; 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:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708367860; 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=P8uQUEP7sHBDAE6xDrwE50fmOGZvNATtQCG6BlfpgkI=; b=ITcQVtQuZQBtY+EWvSyp5Xrssk2bEtYhnU+7iKivsTzKQ6opuBZgjtSVsarIVpFRvFo4Jd kLcanE8j/XOPHhrN+X7cGiQdSqWVxJRaCnNO4ucMtb33bpVhaCyF3nyPqNpfhAdsuwSl1o 2aVfMC3QUc1BJ7hXtmPsr7p51rhWiI7o+KDsOmISmcBSPeJe5plzx2xF/xXvE3ekqaCI5R ELIOeqKHMCEa9atv9J5sLyEj9d6+f+lpeJ/RDB6EVFslPzbdm/FPc4mr4Khx2dLhoYaRlG Otd45aRs+cGSXfr6fDQQCod9kHr/o+92vDtVm6xKwlJ4GltM7q3vgKFNSbLncg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708367860; 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=P8uQUEP7sHBDAE6xDrwE50fmOGZvNATtQCG6BlfpgkI=; b=r9r6QyGjR085Snx1JxAdIRfoM/FlHXVV1XdBp7/Wfw301CRnAntYJZb8Gf+TKWyvqx4k+8 WFliF8xhZbdphgDg== 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: Create helper for RMID allocation and mondata dir creation Cc: James Morse , "Borislav Petkov (AMD)" , Shaopeng Tan , ilpo.jarvinen@linux.intel.com, Reinette Chatre , Babu Moger , Peter Newman , Carl Worth , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240213184438.16675-4-james.morse@arm.com> References: <20240213184438.16675-4-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: <170836785987.398.10687382192378795242.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: 1790810482892951971 X-GMAIL-MSGID: 1791353850674166078 The following commit has been merged into the x86/cache branch of tip: Commit-ID: b1de313979af99dc0f999656fc99bbcb52559a38 Gitweb: https://git.kernel.org/tip/b1de313979af99dc0f999656fc99bbcb52559a38 Author: James Morse AuthorDate: Tue, 13 Feb 2024 18:44:17 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 16 Feb 2024 19:18:31 +01:00 x86/resctrl: Create helper for RMID allocation and mondata dir creation When monitoring is supported, each monitor and control group is allocated an RMID. For control groups, rdtgroup_mkdir_ctrl_mon() later goes on to allocate the CLOSID. MPAM's equivalent of RMID are not an independent number, so can't be allocated until the CLOSID is known. An RMID allocation for one CLOSID may fail, whereas another may succeed depending on how many monitor groups a control group has. The RMID allocation needs to move to be after the CLOSID has been allocated. Move the RMID allocation and mondata dir creation to a helper. Signed-off-by: James Morse Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Shaopeng Tan Reviewed-by: Ilpo Järvinen Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger Tested-by: Peter Newman Tested-by: Shaopeng Tan Tested-by: Babu Moger Tested-by: Carl Worth # arm64 Link: https://lore.kernel.org/r/20240213184438.16675-4-james.morse@arm.com Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 42 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index aa24343..4ea5a87 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3288,6 +3288,30 @@ out: return ret; } +static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp) +{ + int ret; + + if (!rdt_mon_capable) + return 0; + + ret = alloc_rmid(); + if (ret < 0) { + rdt_last_cmd_puts("Out of RMIDs\n"); + return ret; + } + rdtgrp->mon.rmid = ret; + + ret = mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn); + if (ret) { + rdt_last_cmd_puts("kernfs subdir error\n"); + free_rmid(rdtgrp->mon.rmid); + return ret; + } + + return 0; +} + static int mkdir_rdt_prepare(struct kernfs_node *parent_kn, const char *name, umode_t mode, enum rdt_group_type rtype, struct rdtgroup **r) @@ -3360,20 +3384,10 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn, goto out_destroy; } - if (rdt_mon_capable) { - ret = alloc_rmid(); - if (ret < 0) { - rdt_last_cmd_puts("Out of RMIDs\n"); - goto out_destroy; - } - rdtgrp->mon.rmid = ret; + ret = mkdir_rdt_prepare_rmid_alloc(rdtgrp); + if (ret) + goto out_destroy; - ret = mkdir_mondata_all(kn, rdtgrp, &rdtgrp->mon.mon_data_kn); - if (ret) { - rdt_last_cmd_puts("kernfs subdir error\n"); - goto out_idfree; - } - } kernfs_activate(kn); /* @@ -3381,8 +3395,6 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn, */ return 0; -out_idfree: - free_rmid(rdtgrp->mon.rmid); out_destroy: kernfs_put(rdtgrp->kn); kernfs_remove(rdtgrp->kn);