Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp272444lqb; Tue, 28 May 2024 15:21:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTDhK8IGscCvhFSXZa14FL4O2gYhs1dy7Vo17Y773uykY09HYeBIQGnjL/WmEWGfhmRZvLUOmj47pFgC83DtbEriERxj2hcUvQtNPiPw== X-Google-Smtp-Source: AGHT+IEc5KOaIdFuLlExh9ZrOqXM5IC63wvwtUie1qt/4JkA9ECIo7S7MZQMrcXYNN376f2ZDp2E X-Received: by 2002:a17:902:ec84:b0:1f4:a43b:ee62 with SMTP id d9443c01a7336-1f4a44b3543mr85652995ad.4.1716934907346; Tue, 28 May 2024 15:21:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716934907; cv=pass; d=google.com; s=arc-20160816; b=s74iQU4upaVtE8HApEYQx1AWXMQSHX/mLFXnoK2SZELUfW4VvEYesft05g35LoFifG K26c1EMjUb5mhpeMKCy9gpUuVWPip6QbMSByuTLL51bFyeNRqVntEEopZTmRFMqt1TmE 1Ogd78AIbNN9yRHYztBvcJyC6flg9nGBNG2yNLjxWy4IAkA02claQHu+SZ6lwAmh798D J51OPPdRRJs91CKvyKIPbSY5zkYr8rkfJ3VKt8IzekFR5SeovolpItVMzK2aztdUoqHT B6shVXwFcM7p9SuKUObhR7tCmoDgLmg8gKbMHzjRm60ykyJmjdTeA+JwyxZRpE19JaF3 DSRg== 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:dkim-signature; bh=oajeB2vc0aJvUKVzXZ/9TPhfeTUX+3akXJU/K9xK1D8=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=tuWNOn/iWcmFVbdt7FgLTMoF+NEfbhFqWvmf9X1pYCr3jsBkVX/S9G0O2vZ2T33+7T qbNcewzR2fIJEcyu4BR+QLzJhfBpNGJhAdS+Do8w9Dz9eQspVPiEiR298pfv3KtRoT+E SvlbrpfIaumikr1aGNXDrCL3+2OjE5feOiLfEC1hmG04FGFrD0GC7A98VqCp6mGSyqgJ QGJmeS3lVelH3CDAwFeCJ6V+vEDXtU/svSuBnU0biSrvzIAS+QVuMVj+rzI3YMsa3eSu EvA/HHgwZKLZGtLOqjC767+TMXh6yz4qBnOV1JwwlyUu9D4e0rgHyIl9CSQZfnYIU/mC kTyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UOkkLx8p; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193164-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c785b86si85434635ad.88.2024.05.28.15.21.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 15:21:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193164-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UOkkLx8p; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193164-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 AC8AC287664 for ; Tue, 28 May 2024 22:21:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 004DE1411CE; Tue, 28 May 2024 22:20:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UOkkLx8p" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 3242713F43C for ; Tue, 28 May 2024 22:20:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716934824; cv=none; b=BbFfJRlpLQjrmSt3KrbUO1YpS2/457mmWJ+R5cL09XI5XAmD4AeR8Yq3rsNqZscCgAF/Qp/Yt/j6u9qE8QUeHpXkEfh/cG1vHZ/JOMFsGD2dFw9MJpbPYXyiICK72cGJpw+y1CO6exZkuVfEtoW/xqMycrA/in2NGXR55Fc7h70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716934824; c=relaxed/simple; bh=toe5dfGHlUZUs5KALimRrGwBstUTM/xEsWdx/zsWdgE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZbO6qyzsiF2Dz2msYrnQVtJV5uxZtZP3pOm8Z9kWsrWqH6ZlyX2CyKnNzX7sSO/dvvOF1fEiv9NrVIryEfThRP6kUqwIgzp1A4mfP0QdlzZaFCSVUmf01yaXqbyuL00e5Xkeuq7eteGQpV3pV/poBmWwzfxjrFi9BkFP0HqAI4I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UOkkLx8p; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716934824; x=1748470824; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=toe5dfGHlUZUs5KALimRrGwBstUTM/xEsWdx/zsWdgE=; b=UOkkLx8ppFJYvA1LE0mrZhcgQ52Gq1vumo3z4/RWxvqGWdMDUXzoIbjr civW6GcWeT//ZE72wqUBvsV0/qHJPStqgyr1pcCo155XrpHGKuQ2p1Nia hhN4hHTO3Q4no88PQzHfA9/cUVi/lll612q37XzOEfkdIKJEBgDnhO45H xyutTDGAxWc8A8bo1mZtGYY8uxNpNZ8KNtFRDx+N0qB1nsXBB0nq5y6hP dmsZsT6YfsejT5lwqNMAaO+gdezJtaF/8z3EYd8XK8jimSPWfoZL+4FGn s2LRVoy4Ly+dEAlU1Y/SrKLJSTvMXifo9wotcNjiEoOUwO+1IbfW981ec g==; X-CSE-ConnectionGUID: Qy7R7BazQAidueiO7v3YEA== X-CSE-MsgGUID: 54On5gvzTQSMhPfzIH/PiA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="30812205" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="30812205" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 15:20:18 -0700 X-CSE-ConnectionGUID: TbZ4eCTbSX2gVQXLPsQPBw== X-CSE-MsgGUID: H/8pPVi9SoGghi2BnwPLjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="40090740" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 15:20:17 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v19 10/20] x86/resctrl: Refactor mkdir_mondata_subdir() with a helper function Date: Tue, 28 May 2024 15:19:55 -0700 Message-ID: <20240528222006.58283-11-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240528222006.58283-1-tony.luck@intel.com> References: <20240528222006.58283-1-tony.luck@intel.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 In Sub-NUMA Cluster (SNC) mode Linux must create the monitor files in the original "mon_L3_XX" directories and also in each of the "mon_sub_L3_YY" directories. Refactor mkdir_mondata_subdir() to move the creation of monitoring files into a helper function to avoid the need to duplicate code later. No functional change. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 45 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 13f93f2a55b3..dd386ad9458a 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3025,14 +3025,37 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, } } +static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d, + struct rdt_resource *r, struct rdtgroup *prgrp) +{ + union mon_data_bits priv; + struct mon_evt *mevt; + struct rmid_read rr; + int ret; + + if (WARN_ON(list_empty(&r->evt_list))) + return -EPERM; + + priv.u.rid = r->rid; + priv.u.domid = d->hdr.id; + list_for_each_entry(mevt, &r->evt_list, list) { + priv.u.evtid = mevt->evtid; + ret = mon_addfile(kn, mevt->name, priv.priv); + if (ret) + return ret; + + if (is_mbm_event(mevt->evtid)) + mon_event_read(&rr, r, d, prgrp, mevt->evtid, true); + } + + return 0; +} + static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, struct rdt_mon_domain *d, struct rdt_resource *r, struct rdtgroup *prgrp) { - union mon_data_bits priv; struct kernfs_node *kn; - struct mon_evt *mevt; - struct rmid_read rr; char name[32]; int ret; @@ -3046,22 +3069,10 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, if (ret) goto out_destroy; - if (WARN_ON(list_empty(&r->evt_list))) { - ret = -EPERM; + ret = mon_add_all_files(kn, d, r, prgrp); + if (ret) goto out_destroy; - } - priv.u.rid = r->rid; - priv.u.domid = d->hdr.id; - list_for_each_entry(mevt, &r->evt_list, list) { - priv.u.evtid = mevt->evtid; - ret = mon_addfile(kn, mevt->name, priv.priv); - if (ret) - goto out_destroy; - - if (is_mbm_event(mevt->evtid)) - mon_event_read(&rr, r, d, prgrp, mevt->evtid, true); - } kernfs_activate(kn); return 0; -- 2.45.0