Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp276902lqb; Tue, 28 May 2024 15:32:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX128O5Cqn+l1YwQP7txBqywe8o3rG4isFDyLFOQvuBHsXGic2+YhzTExPQ3fpMFvdsr600xbCu9uWK8EBBzOG7K5kfHT4EetzsazMz1Q== X-Google-Smtp-Source: AGHT+IFg1zbeOQP/UwocIiFM7WjvJPWPHbOhSTYg6OjogpK09Te1jzIN4Okp5fkYGvdRoFh3mG1y X-Received: by 2002:a05:6a00:408d:b0:6ec:fe26:4ec1 with SMTP id d2e1a72fcca58-6f8f42b8e1amr13569367b3a.22.1716935576095; Tue, 28 May 2024 15:32:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716935576; cv=pass; d=google.com; s=arc-20160816; b=s8tjkdRtm1c4BY47LHbzMMejBX0v1+RwIeMx8OWbIAaDSxUxtViYs19Gr1nFVgq8Xr QtObIRiRF69VuNjHnIfMz9X7uT2fHe102Q2ml56A7Zcs964cBRtVTsgghbSuemju4r1X eJ56rVZqPYsE9komu1tNaH6Vcua2JDucIbSkmWkv+Fh3xhDdHU7UmxfiA8wy9Zeh9S5Z pPZry5TUzczz9xBrAJa79XPcVMgjREletxkuYnbAL2nlOdripQMlDyiFv7WabNWxl2p7 1pnn1cVk/Gg25NDCZaW86kfLvbOAUXCtvIqmStCqTthVydniaRaFos1efiHpLyHmxCNP J6ug== 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=Vc89xXXoHU9rUlObF2ZeNHsd5klbeRr7/u7sDS9idDg=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=pUPBljKcxse1k+6OJsapMxtEPG1gyVhvwB3qnQv5fBqVprk6cJS2Fdf2RycEgFU75H mnDXLptan8oLVwOqzXWaCZE4e9D0tDUsIFS7F8MK6S11wyrnNu8gTHrWsyj4EcvYh1rZ Lxrdpogwz/aEVizAcEqT0QWSoVgu66Wb8RQkCChXmoqtavmjnXxiICzjakhbDRaCTXxb K4INOzlS3unpVs4jhPC6Kml9Iye8hGvcHfSiX79Q4DWEG/qX8TgJPuw4vUQhvI3Ox5JV JKuIMFPnfegxVUjFbDOY2lxIsYlmarHHN3eJTXjrdQdtKDsWCeDdw3ehJfQvxsDZ8exi v0oA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H18qe2s+; 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-193171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193171-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822ae57900si8887275a12.811.2024.05.28.15.32.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 15:32:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H18qe2s+; 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-193171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193171-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 C9ED8289439 for ; Tue, 28 May 2024 22:22:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A26AB145345; Tue, 28 May 2024 22:20:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="H18qe2s+" 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 BA28A143754 for ; Tue, 28 May 2024 22:20:27 +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=1716934829; cv=none; b=kZgHZCjScjXQACNJn93LWBgTi/3RgSiQY9LR8Mxqv99h4K3fezOQIIHoU7WgaREwxVd33ztR5EN0axyLD3rQM/l5EboWjlOGM5tPDs503KcUxnk5DXa0pJ7viShpRDpQ/QMWOqn3ibsUkzWJ0JKc6eCNpAuUmXgG3ZDVEuxH4VM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716934829; c=relaxed/simple; bh=ae2net2an2bG2zA//O2uZIIe0Gsj90vooANwSwQeDp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qDi0n18UOOQKwpMqXKBE5vISY+hPLL21x0sXAgRawiMRfwyHeEfAaPnBScfjOCXrbUotHR43UHryQmyA6S1AmNAkE1qGjtHi52aTua8MsEwJwGjKvMMogz1sVG2/s5sz089jpoXhtgCjGRkkzNE8y8hBZ35PRNpyeNzWXMPQCgM= 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=H18qe2s+; 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=1716934828; x=1748470828; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ae2net2an2bG2zA//O2uZIIe0Gsj90vooANwSwQeDp0=; b=H18qe2s+HPeMwv+pu72wa/kVE0f8qaoTG/uiH2p3ub26RW2r6ptvbZXz 9SfJYIfipC8Uc82sE8pCw9GtmYWml15MmAzxi159utnBV4aS0QjFxEkLg PK/NFbE3Z6y4fAMKPzHdM5PM6GkR4ovhG8gU/p7jxymwPofm4aHG5sO87 Ww/RjSHimQ987l7S56Q8rBt0hTd27X5ShaekQoYXHRGxNMRV5QSdLF0Oh mtnKCKm4qXg2y9vPrm5rI6O4xd8osYcuO23w/IfeCBIJ7RcYqZ8pAZ1ak /H+Tbx3b5sq4ilp3ox+DwL+HwQv+lR1WYhgVaDIpXJuTpPsL2qjbnjiIj w==; X-CSE-ConnectionGUID: 5tn2roWBTmWGmtMGa7RMUw== X-CSE-MsgGUID: 6IaNmqx3Tp+svNdFesGIJA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="30812254" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="30812254" 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:20 -0700 X-CSE-ConnectionGUID: QD3PTiOTSc2KlcgwAcUijA== X-CSE-MsgGUID: 7T08vKT8SCKRDTa9rx+H2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="40090773" 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:19 -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 17/20] x86/resctrl: Update CPU sanity checks when reading RMID counters Date: Tue, 28 May 2024 15:20:02 -0700 Message-ID: <20240528222006.58283-18-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 When reading from a single domain the existing check that current CPU is in the domain is accurate. But when summing across multiple domains that share an L3 cache instance it is sufficient to run on any CPU in the shared_map for that cache. Split the check into the two separate cases. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/monitor.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index c9dd6ec68fcd..e7a8e96821e5 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -308,9 +308,6 @@ static int resctrl_arch_rmid_read_one(struct rdt_resource *r, struct rdt_mon_dom resctrl_arch_rmid_read_context_check(); - if (!cpumask_test_cpu(smp_processor_id(), &d->hdr.cpu_mask)) - return -EINVAL; - ret = __rmid_read(cpu, rmid, eventid, &msr_val); if (ret) return ret; @@ -338,8 +335,15 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d, int ret; *val = 0; - if (!sum) + if (!sum) { + if (!cpumask_test_cpu(cpu, &d->hdr.cpu_mask)) + return -EINVAL; + return resctrl_arch_rmid_read_one(r, d, cpu, rmid, eventid, val); + } + + if (!cpumask_test_cpu(cpu, &ci->shared_cpu_map)) + return -EINVAL; list_for_each_entry(d, &r->mon_domains, hdr.list) { if (d->ci->id != ci->id) -- 2.45.0