From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 E55F02E11AE for ; Mon, 11 Aug 2025 18:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754936257; cv=none; b=dmvG9P0epTOy98lF/YOKAek6xaCHvuu5snrGE6qTdG0Dww9A3dmxPzAgr26T4AJ7IGD28A8L68VKTdiSa0Ykr8+OnOJZgfwFMCF56OjTfIQCCzh79n0sJNUYY1QGD9ut+e5GZ7ORDICzEkge9ZMuxewxJ9OJeeQndufOQSrI9uQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754936257; c=relaxed/simple; bh=LtCIWxRjo81w25b5/equjWzNBh8gkG5EfSSMHGMzUKM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=okn1f2b3T3s4VVRE5wf1LrmOhDxIIhWgdZAQpPs5g8a6m4SJW2nQkVz4QD+tBtdmVy0bQJO19mD8r+2Kya3CRnElkYAARFX/EbE4ONseVssGwnJsxsNn6PgudTEZ77KVRTdDCeNxccZ/qTP5qMbQRrVVUW/CAIll+Jfk+/i2MII= 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=n2hJ7KQW; arc=none smtp.client-ip=198.175.65.13 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="n2hJ7KQW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754936256; x=1786472256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LtCIWxRjo81w25b5/equjWzNBh8gkG5EfSSMHGMzUKM=; b=n2hJ7KQWfAXfI2IHCjKNTHIu3l8U3l+kVilkY9zkXYOB61tXOZd1Q+6B FDbsPQOX+yWFSJmZSjzXAFURqWFTlTM2c281qbpQkYdEeJZoeRT4c8jsz 1oIjAFSu1r5NOAH8OJPLo6Ygod8XPmAm557Dy+0uuVFCki8E/lTmPYXUx InfF7awMkYya3+8MCWpjOQ/DG37p+HFO0DmRmujJO/QxYL6xZnhs+Z2E5 bJJHuL1K7E2R6GL+FAL6CioRI7QwdXhMnE7mUH65c0sadmGBXOtPARtu9 pz07xO8oqdyZ0mBJqfJK+qzY8a9zJBZWvIxbuUAwHfPhGssneshb+UyYj A==; X-CSE-ConnectionGUID: v7pTd2jwQMqn1erD7g++ww== X-CSE-MsgGUID: WjMKUOCxQm2/8h8Ukpvmgw== X-IronPort-AV: E=McAfee;i="6800,10657,11518"; a="68277353" X-IronPort-AV: E=Sophos;i="6.17,278,1747724400"; d="scan'208";a="68277353" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2025 11:17:26 -0700 X-CSE-ConnectionGUID: 4bXFEu6iROmp1QBhPDy8Gg== X-CSE-MsgGUID: SSa0qaHTSeWvG2kb1DlBDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,278,1747724400"; d="scan'208";a="196825627" Received: from puneetse-mobl.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.229]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2025 11:17:23 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v8 06/32] x86/resctrl: Move L3 initialization into new helper function Date: Mon, 11 Aug 2025 11:16:40 -0700 Message-ID: <20250811181709.6241-7-tony.luck@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250811181709.6241-1-tony.luck@intel.com> References: <20250811181709.6241-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit All resctrl monitor events are associated with the L3 resource, but this is about to change. To prepare for additional types of monitoring domains, move open coded L3 resource monitoring domain initialization from domain_add_cpu_mon() into a new helper l3_mon_domain_setup() called by domain_add_cpu_mon(). Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/core.c | 56 ++++++++++++++++++------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 420e4eb7c160..66270c230b4e 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -496,34 +496,13 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r) } } -static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) +static void l3_mon_domain_setup(int cpu, int id, struct rdt_resource *r, struct list_head *add_pos) { - int id = get_domain_id_from_scope(cpu, r->mon_scope); - struct list_head *add_pos = NULL; struct rdt_hw_mon_domain *hw_dom; - struct rdt_domain_hdr *hdr; struct rdt_mon_domain *d; struct cacheinfo *ci; int err; - lockdep_assert_held(&domain_list_lock); - - if (id < 0) { - pr_warn_once("Can't find monitor domain id for CPU:%d scope:%d for resource %s\n", - cpu, r->mon_scope, r->name); - return; - } - - hdr = resctrl_find_domain(&r->mon_domains, id, &add_pos); - if (hdr) { - if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, r->rid)) - return; - d = container_of(hdr, struct rdt_mon_domain, hdr); - - cpumask_set_cpu(cpu, &d->hdr.cpu_mask); - return; - } - hw_dom = kzalloc_node(sizeof(*hw_dom), GFP_KERNEL, cpu_to_node(cpu)); if (!hw_dom) return; @@ -558,6 +537,39 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) } } +static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) +{ + int id = get_domain_id_from_scope(cpu, r->mon_scope); + struct list_head *add_pos = NULL; + struct rdt_domain_hdr *hdr; + + lockdep_assert_held(&domain_list_lock); + + if (id < 0) { + pr_warn_once("Can't find monitor domain id for CPU:%d scope:%d for resource %s\n", + cpu, r->mon_scope, r->name); + return; + } + + hdr = resctrl_find_domain(&r->mon_domains, id, &add_pos); + if (hdr) { + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, r->rid)) + return; + cpumask_set_cpu(cpu, &hdr->cpu_mask); + + return; + } + + switch (r->rid) { + case RDT_RESOURCE_L3: + l3_mon_domain_setup(cpu, id, r, add_pos); + break; + default: + WARN_ON_ONCE(1); + break; + } +} + static void domain_add_cpu(int cpu, struct rdt_resource *r) { if (r->alloc_capable) -- 2.50.1