Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp602400lqp; Thu, 21 Mar 2024 09:59:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+QTKZcDL4R+RsvOXpMB4A2q/r8ZO808ykhR4k/Oj0/J+t/0SWp2QvneqqyYyWNrDZkkkpTxVt+1stx7fMrRsYfNK68b6qLOKrMZ3SRA== X-Google-Smtp-Source: AGHT+IH8XOd1swWfL7YQS4Zew2de5ud5CdeM4aDlI7RSbOY6QdEtttBIEKuI+BScgU63N4XEO/80 X-Received: by 2002:a50:8d4a:0:b0:568:9ba8:8f1a with SMTP id t10-20020a508d4a000000b005689ba88f1amr2273084edt.7.1711040339865; Thu, 21 Mar 2024 09:58:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711040339; cv=pass; d=google.com; s=arc-20160816; b=tRpdFx5HDZmsVFwB2RrFcs+VVcYgKApKYvnJoCcZqvdlJw0e5EEJowZ10BHg4bP52h 7QN/pan4zxBIaBk6PzxjK32kRE3Ye69PI1M1aQ/EzoNYHkdc/rTTKMv1hsOyAUOUjTT0 37G1rYkF57ptCe2x7WJeoBOTBfooh1Dhh7zrN5QY7JIbS7ZjgwAidjW0pQpmhOsTBUFX OtkrzzOj2jhX3RG8Trcpgn5roXfRDgIzL82xTMjoc9Pq8H8SJWJRifZ800RBzQp+MHSM s6xA8FMsBP07SlLYazAA7R3wL2Gj2R4ISzj0kXR9N/JAW7eLONMCg1ujtoWQLJf31HA8 I1Pg== 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=/wvcEbkhO5FcRCbSBtHnU+2aa2nhArE8k+6Msb6pQf4=; fh=knouHfhWmUABu+sT2q0nnGKUzC7/WRiZH1KSpGv7uFs=; b=Hl5djSgTEgAW9GuNkg61VsbvheOcmBvD0CD1Tht7LCXhH8eOlEHtf/mQSjIJzDloFz CsNViftnqngUdIADjrvOzT2gw0jBUFufqynJX+V5Ko2x7+miqQ/UAaZr3TbLaEhTBdKo FP6nSBvmhwx73HmzeCtwewFfJf++IjgTyZP8/mTclxQcerapuST9pkSiJ8UazQoQlwt6 8C2rgFBL3Gr3hCNTI5Zrj4ok/BtNnddu8GNnQLJGFKvNRqJXFvcjZJZM/Bc4z6zQmiNN enQpEfi+e6RCSxZLUfL68HySbzyS0fU7HVVVlISJwOG0vo9CfIxRouhmTIKfI1LlAh8C L2kg==; 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-110417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110417-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u21-20020a056402065500b0056b97044aadsi58576edx.511.2024.03.21.09.58.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 09:58:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-110417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110417-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8AAFC1F22996 for ; Thu, 21 Mar 2024 16:58:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96AE7137C5A; Thu, 21 Mar 2024 16:51:35 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 422F6137C57 for ; Thu, 21 Mar 2024 16:51:33 +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=1711039895; cv=none; b=TdOeNHbewGgjPqgq5Cnq1UexTDS3iLIJrfoZ2kFV1Y46GTRFA1Rd9p6XSOeRhsrV4JDPYKdYR3yXNdChMkW7vYLqrb/mnKOzeHDCTkw1NPxrpd11fcqP3VE9nx0DEz+saRUgehf8ccniGETlzSTyGqITSxLd6ucLWy9ujrT4hlI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039895; c=relaxed/simple; bh=yC6zOImDq9iw6uZjNylTu1AfBJHJqq8+WJQD0nOtrvo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RnPlHoCFFs424V4W0B9O9xWCJ1LoUPTfgibichoYj2TTVnEynXadWsfn1MAgPp8fut0PNQ0ArR42QBJ4utMJ8SNfxwv1ingFygS/wwy8iWu/EP5MNYH0omtn4jVcVail8gw1A9jACkMhsp53bZuJonmtZhuu0u6aWncucRsytqg= 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 E5AA81063; Thu, 21 Mar 2024 09:52:06 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A70F33F67D; Thu, 21 Mar 2024 09:51:29 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Rex Nie , Dave Martin Subject: [PATCH v1 01/31] x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors Date: Thu, 21 Mar 2024 16:50:36 +0000 Message-Id: <20240321165106.31602-2-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240321165106.31602-1-james.morse@arm.com> References: <20240321165106.31602-1-james.morse@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 commit 6eac36bb9eb0 ("x86/resctrl: Allocate the cleanest CLOSID by searching closid_num_dirty_rmid") added a Kconfig option that causes resctrl to search for the CLOSID with the fewest dirty cache lines when creating a new control group. This depends on the values read from the llc_occupancy counters. 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. Signed-off-by: James Morse --- 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.39.2