Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp36855lqg; Fri, 26 Apr 2024 08:09:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW5OKBnySf1jE6d2ZgolV9nvjr8QMBTwC4GUIWZcYEDHxSl+E6FV8YMXWYYZxdOY6j/6KHQvuE2Jv8JC/TN6FjlJeoE+yG+0wpjErFizw== X-Google-Smtp-Source: AGHT+IENqKpWrbp/VIdejaQqCo7x84ArAfZacmRmNRONl4+0+WONPof+NtIxaQiCqVZXafrt8XEE X-Received: by 2002:a67:ee41:0:b0:47b:a44a:baeb with SMTP id g1-20020a67ee41000000b0047ba44abaebmr2839093vsp.31.1714144195454; Fri, 26 Apr 2024 08:09:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714144195; cv=pass; d=google.com; s=arc-20160816; b=gwFguVbeINWhcY+nD1WxeMMm0deuCf6ACHku3M480E2LDPkHh6fXozshPEP0g36EF7 sHEF+1m54EHiJfP9U+SpPfmga/tPgjHRwQci3Xz0Lzw7/ZhhzGP/2zfZlxtblY+zBgrC zjknRF1sJUAF/d7gezdbahKtlFTeYmayTQyeaM4LZJ6D/pVIa5/GqALbHdir+k+HTPu6 2xX+Ik3uzVPcllmoyqtswxd9kDb8UGbpwhYjzafiB1bft+ds3s8iGDVu6/61f33j4O9q mr0vIhLydSkKyYl+Z/WK3SwiBJod1U4ZkJaClfFNSyjboY/+Qvw/dC2x7okk6YdajEgb L8pA== 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; bh=lbYse5TZMbhkKZzb1gGjFQ0YOgG+LHSq+lss5yulB3Y=; fh=Vo4MxA0u7CmSKYL/GjcyKHwusyvU+nKR43bqJem+vcY=; b=OxF22dMnUHzrck6RfgFxDLRky9FKS2Aa/7tJGaHCf44z56VE8n2iwpC8DE2fx+87kW ZWyVh1hYLhxbRgw2H+006adH4gAvTqtnoSVBtgRUR+ZYqvx370kaGzIUO63hfwj3xagD gwD9lDN8IlADeBzsVPoP9W7coaHX/vIBjnF/F/ph7n847xCxjL3iFEZFeqnyZeyFiBPq pOCNm81zEoJ3h8MIIG3HfAbqKhW0PAUZlbE1dFxzM5Y/MBouMgP2BpYou+X0ZRzMiANb JpI0sJ1XJXREMP9vEIsaxBH6lVt/MllisDmX0QF4nS5KRPue74RVE0hpESXq86xY2Ytr rVcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-160217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s14-20020a67e34e000000b00476b88504c6si3273309vsm.585.2024.04.26.08.09.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:09:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-160217-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160217-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3E54A1C246F5 for ; Fri, 26 Apr 2024 15:09:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C2AB148FF6; Fri, 26 Apr 2024 15:09:17 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CFB3148FE1 for ; Fri, 26 Apr 2024 15:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714144157; cv=none; b=t0zP/l83mNAjKIkwUN/oyD2ACYy9XOzxCDnCw7hmyTEXH7l5ik20eKbdGq2saJrh1aXzwafTMj6vzFnSG7W+btJxPn5L8iq2BgEemCdii9RvWjYvYQOVBLHwt5VOd1zyYK/k+fwElfJ6JOg41MHeFWUDt1iVd97OXnEBHVP3u28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714144157; c=relaxed/simple; bh=i8DtAAr+DpyLdUOjSTjC5bTWalOOizbXnAWVd2L0Q6E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Le6J6H0So2f3YGSsBmeU5sW7klQJsoBeQAtXq56yzxs/d/nUR/RZznwh1KZF+Rjagmk1vyAzpJ5TTWbo+s4MYJblpuuTcJZvQmW/vYNb2LvaY4xg/fd0qp2tDjNJj3EWbCQ7Czfe8Q+7zG4XCp4yoKcnMrkS7hPZzHMn+O1FTo8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 074841596; Fri, 26 Apr 2024 08:09:43 -0700 (PDT) Received: from e133380.cambridge.arm.com (e133380.arm.com [10.1.197.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 229323F73F; Fri, 26 Apr 2024 08:09:12 -0700 (PDT) From: Dave Martin To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: James Morse , Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, "Shaopeng Tan (Fujitsu)" , baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , Peter Newman , dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Rex Nie Subject: [PATCH v2 01/35] x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors Date: Fri, 26 Apr 2024 16:08:30 +0100 Message-Id: <20240426150904.8854-1-Dave.Martin@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240426150537.8094-1-Dave.Martin@arm.com> References: <20240426150537.8094-1-Dave.Martin@arm.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 From: James Morse commit 6eac36bb9eb0 ("x86/resctrl: Allocate the cleanest CLOSID by searching closid_num_dirty_rmid") added logic that causes resctrl to search for the CLOSID with the fewest dirty cache lines when creating a new control group, if requested by the arch code. This depends on the values read from the llc_occupancy counters. The logic is applicable to architectures where the CLOSID effectively forms part of the monitoring identifier and so do not allow complete freedom to choose an unused monitoring identifier for a given CLOSID. This support missed that some platforms may not have these counters. This causes a NULL pointer dereference when creating a new control group as the array was not allocated by dom_data_init(). As this feature isn't necessary on platforms that don't have cache occupancy monitors, add this to the check that occurs when a new control group is allocated. The existing code is not selected by any upstream platform, it makes no sense to backport this patch to stable. Fixes: 6eac36bb9eb0 ("x86/resctrl: Allocate the cleanest CLOSID by searching closid_num_dirty_rmid") Signed-off-by: James Morse Reviewed-by: David Hildenbrand --- Changes in v2: * [Commit message only] Reword the first paragraph to make it clear that the issue being fixed wasn't directly associated with addition of a Kconfig option. (Actually, the option is not in Kconfig yet, and gets added later in this series.) --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 011e17efb1a6..1767c1affa60 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -149,7 +149,8 @@ static int closid_alloc(void) lockdep_assert_held(&rdtgroup_mutex); - if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID) && + is_llc_occupancy_enabled()) { cleanest_closid = resctrl_find_cleanest_closid(); if (cleanest_closid < 0) return cleanest_closid; -- 2.34.1