Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp107570rdh; Tue, 13 Feb 2024 10:45:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWlcgv7zaOMeSY9kPNUSZglD4R1meiCICvIE3Nx01V7G7YMRCYRhBqHU2QiFdGBLmqmRKRGUQddAwbGDjJHBkB4Rbj+wRe0IObt/MN7pQ== X-Google-Smtp-Source: AGHT+IFt7oi3O/pkwD8ONNmB8YWglWOWFNCm97UEyXsxkk2sDHRiTF7pR74cHtQlKSOrBf0Jd1T0 X-Received: by 2002:aa7:cb5a:0:b0:562:1016:3cb9 with SMTP id w26-20020aa7cb5a000000b0056210163cb9mr358412edt.33.1707849956273; Tue, 13 Feb 2024 10:45:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707849956; cv=pass; d=google.com; s=arc-20160816; b=vxeOHaXnRtMmzYOGSTKC5QUnS+yzKO2H+3N5R13LZxbPm8slvPVDokpxVnqyDha5L9 pOoyc03Zep+jXpECEZ44aAnjRuHmbjXm1U68W/vO4X0xdEa9Q+un3bI9NMRwsAh7+kF5 rBKtfnr86ogdsrC2gAOpLebbXDuP67WnG4zcPfHWFv1PnZU4d50WsSXOBu31cdvAYNzw spn37Eq0iysK9BQaY1LmnNLKqWz4ysuV+S47R6Vwp92Tg85TQlxmy7ZW2UlgjBMSTzhQ z/Z80Tal89reBuwSMrg0+AN+JaZqOAUdumnWF5DB7YMm/cGYB0en98HE8F1gf2tPaxhx imRw== 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=i/PWf0O7w77zQqYguicZljE1MqS+U4xfA2ohOvgrMKc=; fh=UgpXzbwgLTie1jRLqUp0T8qfq+/bxD+r6smmAZA03+8=; b=tVxCxyMbRl3YHIUDpi4ia8vavMjTLAdE0fDRCO347Gem63NDu1zN4nc9xpJmDZpsYT ZTt5jGxlA++f2VpCp86xQ5O2k9PqrtTceaF99TfVbBN9uhZ57Pol01cKHslcSMCXnq7d HFqTaKD0fiGldAZKyqJnu0NmvXdOHcKZ26Qbgau4E9+ivRr0Tx4a5mhYUYDe3HsNqmRP oLuo/UKXj9j1m48I2j7CaDRAujSgAXvu2zQ8bUUjelPlHVQvcynoRtpjECXCc67Hz0ck kiRGCFmxM+Dd6QgrYLFKpEBgUVpzKtxdg/rt2z3PVmTOwMBEGyR2HMl+aEJOTb9ruom0 B+vA==; 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-64094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64094-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; AJvYcCVf/77a617oAq+jdrdCKQpPWvCT7DcqAqh+P0YyMUo2N2ASx4x9ml17scT/3eBtJPJHImB5gM1a8R5tekWB1mR3EEzdy+ByrojJii0iCg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m8-20020a056402430800b00561d07b6898si1663266edc.96.2024.02.13.10.45.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:45:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-64094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64094-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0C4931F249B4 for ; Tue, 13 Feb 2024 18:45:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75BB56088C; Tue, 13 Feb 2024 18:45:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E93C60881 for ; Tue, 13 Feb 2024 18:45:12 +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=1707849914; cv=none; b=i+kyYcLScuE5xclZK28AYW0lmYje+C3JBL5JxGBMQzB7cZt+efSsJmOmhj5G0mht7m5MBFT9YMWjbGXaeBdDFdesCa42OGhrfJGQSNSdavdhbZbZYRja1uERBDnCiiKFQO7YH6uXRqEwoX5siruBIC3qzGEJMWmnch6ADRaVZTs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707849914; c=relaxed/simple; bh=e9JWYiCmeFsWinCmEWYZOTDNfITJiLE8EatsPyrLEfU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=e21cLK1Uef0QuLrhhti6QXmCdrlXaco+v6R5BI0p2zZw7Q15L1p/B+rEh5psyCpQ7nDX95HshEp08xA8GI3wsb5FMpNIGhhVYIcXfPQ9oxg6bpQuyo25GSwN0RXSHPKb+7EmyeioJudr9OM0dQSk1UEB0gkLAFqhwo/TNc7Y0b4= 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 2FE2F1042; Tue, 13 Feb 2024 10:45:53 -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 AB1CB3F766; Tue, 13 Feb 2024 10:45:08 -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 , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v9 03/24] x86/resctrl: Create helper for RMID allocation and mondata dir creation Date: Tue, 13 Feb 2024 18:44:17 +0000 Message-Id: <20240213184438.16675-4-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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: Peter Newman Tested-by: Shaopeng Tan Tested-by: Babu Moger Tested-by: Carl Worth # arm64 Reviewed-by: Shaopeng Tan Reviewed-by: Ilpo Järvinen Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger --- Changes since v4: * Fixed typo in commit message, moved some words around. --- 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 aa24343f1d23..4ea5a871be49 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3288,6 +3288,30 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp) 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); -- 2.39.2