Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp304610lqo; Wed, 15 May 2024 15:25:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQBPm/d6byHGDC/OFcOZ30QMw4Fy80pNSXkIKSdORfp3uO+YK0STbUKRcoZm34lIokj3qh2Eiik27ki89Uzb/aipVuwqHjLYaI/aSulg== X-Google-Smtp-Source: AGHT+IFKD3X4DR8p9nS2l8yOgozoRcYmnrInbbdrlxGqgdI+1AhoACiJbpQ4of+JzaG7m74bGX0T X-Received: by 2002:a17:902:aa92:b0:1eb:2fa0:fe22 with SMTP id d9443c01a7336-1ef4405952dmr155649085ad.65.1715811949974; Wed, 15 May 2024 15:25:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715811949; cv=pass; d=google.com; s=arc-20160816; b=DdL5wa7p0bbmoKCKhuBQjSDtvg/YMTl3CM9M7vCxUxUvz7MnhQADfDx8CUc82M0CHs 9XLcEcNw2lj5n6W9WnoyH55VceOSCKNjBtcACMEYTUXc5kJQIkb5nbVsdGvBK27BAto9 Hw2c0gr4mnrY1/joVb5F3syxf35CuxpxAi+10BAmRdZnSHgVcnyYxgm/BXkOZ4Om3aps O2jnO7l3CLLLwSSTPxTJb9+B8bYWEybjivjJq+TdB2iHZe43+fFlHrmrYWglETAc+dL9 VkwiW1pla4xpNDEQwNSAVyEKSisKY3XIfASJoY5RZpzVxSXZoz3e7WkfgScrrl0m09sX qDjA== 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=EZ/JicqHS1YAzMsIXy4YTTfG99FPmKESl2IHUwfZi9s=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=E2JMXOrAKkNqfbiw1kvyAbNWhJ4nnnu8Hra2kHOQBLq+ySEhehWO1hKX/ouXmnTe3S pM9VOFd5vm4/vnbZt52p4W/8/hIMW8rAYkWHib5U/d2qTdRMq1BleuWqQ2nudUHdBCKS 5sodV+7M3dg9TEVo3M0neyQoUWn2PqXl4grA2TQCm1udmjNwMYcLFnqPWK1PUxe7Kahr JkRIjxLB7V+w/2rXPL7VRdtmzeLGmQXn1S85+ZCE7B3s6pvEd5fq3v2OuQUw/T5zbepi /+78lUdjKUfz2yBYxt77u0pAzyVUab+/j4LhKNw7GpuwXS1YC0tvQh2x3U58k6LN9AMF G4Ug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d9d2z5qK; 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-180435-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180435-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-1ef0bf32dc4si146375485ad.244.2024.05.15.15.25.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 15:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180435-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=d9d2z5qK; 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-180435-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180435-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 33FAF284522 for ; Wed, 15 May 2024 22:25:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13F6015B97B; Wed, 15 May 2024 22:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="d9d2z5qK" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 AE1B015D5D1 for ; Wed, 15 May 2024 22:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715811824; cv=none; b=VKMRbWBBhkO4VDHsfMm26fAyvW3wC58IZN1ex8IX1SXPoZvNRcfzNX1aEKHbn4HNk1MWawVaUDY29qJDuimcydDF4au3/GogZUUfrJz6Nf5XY0J2b4krEdJ8rbMMr9OQCJD5v4W4J3emhWes1NNmAp3iGqkjDokG+VwIXxBmC64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715811824; c=relaxed/simple; bh=soQkrx+91u7qTspgGFOcYDqwxHpz6MbduDMvA+P81gI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rmb9On0pkA+N4dCZ2EyGwTBGv01oswlgsr2I8GMpyXPOkvWxXHsFcWbglE2vgGt3PRFfhmAbIJdL2VCgfmB2pG6eFrBQd553+cpEPN52Gjgt43gSgNz+GrfMttYdYbw22kYVmquFwOFeuayiRNXNBn1ZWyADUVYok+FCuSNfwkM= 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=d9d2z5qK; arc=none smtp.client-ip=198.175.65.15 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=1715811822; x=1747347822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=soQkrx+91u7qTspgGFOcYDqwxHpz6MbduDMvA+P81gI=; b=d9d2z5qK3jGHdzJBjSDL9OogQIoflvuGGS4AOE28VHZTC2pokQubaz2e jt4infAXLeVASgrO5RyruDznDIuDgNljHZkwhQDyQo1Y2iv77O/M2YDU+ +OE0QuNs/C61oNhBnxfqYAQIeRy0jMqeoHxaoFwHUJ1cdvRSDX7yvBWU7 +DlWaFoz50uTwJowAo73WbRL78kkBtu28I7UBJts3jnM05xKZ+Q043udU 2yvJdDqFd27XClU0goAjuojCggcznKZBucGPoZGS2nG0YfPuFjxh3ODxs easC2qYQqI0HNuRn1Zu9VfsA6PdgWmlcFq6UgQldevH4ZiafJNT9M+0PE A==; X-CSE-ConnectionGUID: W2ZM2BckR2Ww9+7Ba4v3yw== X-CSE-MsgGUID: WGxnx3XDR1+8Wdw0pebmOA== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="15671669" X-IronPort-AV: E=Sophos;i="6.08,162,1712646000"; d="scan'208";a="15671669" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 15:23:35 -0700 X-CSE-ConnectionGUID: hZsTzADGQKSMzu+SEDWKPg== X-CSE-MsgGUID: dldCONw5T/+FkIHM2sqj1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,162,1712646000"; d="scan'208";a="35989176" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 15:23:35 -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 v18 10/17] x86/resctrl: Refactor mkdir_mondata_subdir() with a helper function Date: Wed, 15 May 2024 15:23:18 -0700 Message-ID: <20240515222326.74166-11-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240515222326.74166-1-tony.luck@intel.com> References: <20240515222326.74166-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 Move the creation of monitoring files into a helper function. 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 0923492a8bd0..7a6c40aefdcc 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.44.0