Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp304699lqo; Wed, 15 May 2024 15:26:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXb5Un609azey5B94eLwUZpCov11EP6pvFXO2IuACpr6kyn5BzjxEf/hZIGs0EYTWgF0jTKA1wbFRZralchZgBkIOcmg8NoHKYszLHBrA== X-Google-Smtp-Source: AGHT+IGjuua/gVRlr2MBdp4FKmJ1ad8eJuW5EB68NMyormC3h7N3CGQIUHxzi6y9Ya4pcYSXuGaZ X-Received: by 2002:ac2:43ca:0:b0:522:386:cea6 with SMTP id 2adb3069b0e04-5220fc7ad54mr10068266e87.27.1715811965372; Wed, 15 May 2024 15:26:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715811965; cv=pass; d=google.com; s=arc-20160816; b=QAWSyQ4DJfb93SdFZgn3VnMULbJ7n8izpkCTYdn59nAXZSgQ8U3IJmudCgMKqgKYhH coREj5ZNAyja+kaN6xW+EsTqmbWSKnzC2Hi2i5PBtZ8PD5gmWluVoTqNU5eK4YggF7nn uUItine/JaicmZckQR/A93ghqi7/tbfccdzhXtu4LKQs7Ra6SvXP3AOPeGbuEWysPH7Q tZ/YgidvLxouk+nBUhuzyXSc9vFSAJA/rpQHT+u12zAr5TYIWmj5420dGSMoAv18o3An qM8ay6tr0WugF5payHH1rVN+fuSuja6HpRZM9JAV8Kdxgx5yuDf87NDW401a73U9MvVl ISOg== 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=CmZBlOAYJ74h96cAYKM4a7o+VEI1LqX5qsHCK7XDEIc=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=u17rIW7ksELCe/dVeDUbZkYkteM0PG/RI4CxEXl9jOmSjote48qUiCKOvGu5r+eyX9 scOBtYoIL9o4SpusIYBD7gGKlCFvGkSnC3omPvruowNnQ13KHNpVsfFSikjLhSKpbh4q Xvl2+Bo2fzq6eYbns+8/MHGP7dXhbN/R1Th9cXIsukgR6s46uJSuQ9EosOhn7rsfuiWU Ewx653GaDvmW5/9BqHAYyKIkXSpqc6r5/xpiRJhqUKHgHx9H6oKXHriSe6Mhrtff8h38 BxEppC4f/u3tD4QDFvVbImZ8B9eKnR2CNYNkdMtc0rICw6wjcYng4ClHYImG6RpDPx0r JFsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AVfpRoSg; 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-180439-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17ba57d7si738147966b.656.2024.05.15.15.26.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 15:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180439-linux.lists.archive=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=@intel.com header.s=Intel header.b=AVfpRoSg; 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-180439-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180439-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1E8661F23EAF for ; Wed, 15 May 2024 22:26:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8EC5A15D5D6; Wed, 15 May 2024 22:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AVfpRoSg" 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 7FEF515F3F6 for ; Wed, 15 May 2024 22:23:44 +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=1715811826; cv=none; b=BF/Al9NhJfqKNp6UT/OSAe+/y4yh+VqfO86XZsjz/jkeQbeMQ06J2G2c9qsTyVLJXMgQYsshRDlbC/V5iIDO25iXlVqvWRnPS9AtNHvABek9zLOmVwb2M8VO+SH6Cb8rd/WbSQs15ya4IW6GtjdDIxFMhy/W58NAuwxz/0+0BVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715811826; c=relaxed/simple; bh=xZjqBCuTBBldbea6pHTW+ptVpegP77hRi5Pdpchcfvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nhGdMQDZvbqf2ZMsSQ/LJK4/Y/I+HMlSWu4qV+/uymAOU7YqrFhQITnkGmksVBx83y/kIOBJiksue281121Ye6LlQjiPvfol5GpyIkBfHvUJNBbPMP8cTaanEn6APJa0PmyH5q2tr9/jAW/ssdYrxN2xWmm9Iu1C57vrpNbgk0M= 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=AVfpRoSg; 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=1715811824; x=1747347824; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xZjqBCuTBBldbea6pHTW+ptVpegP77hRi5Pdpchcfvs=; b=AVfpRoSgMLT8d6WrTovlHXu3XflzhYYgAoYqbd/CjUXEP1tQANaDWDdh EOI9I6s1OhW8flobcc/q9PM2pqSbfnja6LJEXtt82PwBpDcCzJCOHq1ym iSC6dBpdgOhNGKmh5P1mzSw7PaWCX4KMyEvNZ6mhr+JomEOh++PzilTUX nIThm3LWCJS1cH5DI+RIDgJbh7nOmqrXATsX4VD8C8zwb2EoNgl6UU7XO He56QY0TAt0hLMP7497aaYTn3c3vkh5GTO9+J1lVqVRmLnsk0Sy+Kw1QK tbSbRn72MXnTa7S4umn0cJw2ZBW+xraFsPOQ1yhjVIEi6EKzkbshW8xV3 g==; X-CSE-ConnectionGUID: 1ea8WIsjTly1ZitNMJPLug== X-CSE-MsgGUID: 6rlaIDJuQr22NbpoirlZqw== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="15671728" X-IronPort-AV: E=Sophos;i="6.08,162,1712646000"; d="scan'208";a="15671728" 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:37 -0700 X-CSE-ConnectionGUID: lBBOznPzRu2o2+Nwf8Hq/Q== X-CSE-MsgGUID: XKlPT9SwSiurhNppnPBdgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,162,1712646000"; d="scan'208";a="35989193" 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:37 -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 15/17] x86/resctrl: Fix RMID reading sanity check for Sub-NUMA (SNC) mode Date: Wed, 15 May 2024 15:23:23 -0700 Message-ID: <20240515222326.74166-16-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 The sanity check that RMIDs are being read from a CPU listed in the the cpu_mask for the domain is incorrect when summing across multiple SNC domains. It is safe to read the RMID from any CPU that shares the same L3 cache instance. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/monitor.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index 668d2fdf58cd..e4b92c7af71d 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -15,6 +15,7 @@ * Software Developer Manual June 2016, volume 3, section 17.17. */ +#include #include #include #include @@ -281,8 +282,18 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d, resctrl_arch_rmid_read_context_check(); - if (!cpumask_test_cpu(smp_processor_id(), &d->hdr.cpu_mask)) - return -EINVAL; + if (r->mon_scope == r->mon_display_scope) { + if (!cpumask_test_cpu(smp_processor_id(), &d->hdr.cpu_mask)) + return -EINVAL; + } else { + /* + * SNC: OK to read events on any CPU sharing same L3 + * cache instance. + */ + if (d->display_id != get_cpu_cacheinfo_id(smp_processor_id(), + r->mon_display_scope)) + return -EINVAL; + } ret = __rmid_read(rmid, eventid, &msr_val); if (ret) -- 2.44.0