Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5492614rdb; Wed, 13 Dec 2023 10:06:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8Zkl3kgbl8utHpOE0T7AWgxYnzRCXD9GdnNxCbU+gEecSxHpzg1+4ki0qukNCXls4RwJQ X-Received: by 2002:a05:6a20:748f:b0:18c:f734:64e5 with SMTP id p15-20020a056a20748f00b0018cf73464e5mr4651979pzd.44.1702490761858; Wed, 13 Dec 2023 10:06:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490761; cv=none; d=google.com; s=arc-20160816; b=qjbe1fSW4XO9JKJPDX94LCcijoV5YT+SbOLf0DrpS9nCYSAzsyZunPNfj9ugbxKa/l KJP4BwAdE95ZisLCg/PcUPiNNtez956a9Gvtye0l4BCVY+m4EbsAE3eF3Of/ebDWItHU xiu6NQxv876Sfp8nCUVz/lMrIOFN5D3kToNFWgKLXrYwCjriiRXL5ztJtkIRi2Xvbsg3 uwZ2s5XqY5zC3mG2yD2SMZTNiZwjGpLbTVRdr9bfyCj7dgMw3dAC/R2rnLMipf8tT9KC uOi4mGvToOvSbN5W4C5xIPriRhJFxgcUR+5SLF86ImcMiQ2haUISTQ3xBDyCLIw+v+qS G8OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=6uEIqF4JR0wOCNlkd3H5TAZJmPQGHxncRm7hFOHl1Dw=; fh=HBNJCb1O5m4cQgWGcwqoKY3KTbKsr5rANYvH6uVWzvA=; b=ALkzJrMj2pa9EuOYjydIcMuwgGeFLOcB6lwFuxrxDjuQMILYZQdqEO7MuSG+ZhkTPc mYnxV8Mj/ztwEFMaehieTKKPLGJIr8ngEVUMNMXghPkBGNmnHgaQ33GKo4BEzQjR4BAO KvyORwCYIcu+rkqMPMs82Khd10x7uliboULp4H7nJWm91UJoLqD1eFTLto1CV2ZJfCwA IS9pD9kG4jdIxv7npyQE/I14Sk2ki0/TL1f1csnsAcp0mLGSSRts1okWRLwEvIcuCFgS +KmrD+1z3ri1uLtzAxPgSqbIJmdytNIIEzRJmGNmzYUaaKXPpt3fdbmanmukfvfkJZBF ke9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id q27-20020a63f95b000000b005be344b48dasi9789092pgk.805.2023.12.13.10.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:06:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D9E52807FD73; Wed, 13 Dec 2023 10:05:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235169AbjLMSE6 (ORCPT + 99 others); Wed, 13 Dec 2023 13:04:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbjLMSE5 (ORCPT ); Wed, 13 Dec 2023 13:04:57 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D681109 for ; Wed, 13 Dec 2023 10:05:03 -0800 (PST) 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 94934C15; Wed, 13 Dec 2023 10:05:48 -0800 (PST) Received: from [10.1.197.60] (eglon.cambridge.arm.com [10.1.197.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BFB003F762; Wed, 13 Dec 2023 10:04:59 -0800 (PST) Message-ID: <66bb7953-5186-c303-6b47-0f5dcf0ec3ff@arm.com> Date: Wed, 13 Dec 2023 18:04:53 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v7 08/24] x86/resctrl: Track the number of dirty RMID a CLOSID has Content-Language: en-GB To: babu.moger@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , 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 References: <20231025180345.28061-1-james.morse@arm.com> <20231025180345.28061-9-james.morse@arm.com> <17055477-d381-41e2-86a8-b27f871cba3e@amd.com> From: James Morse In-Reply-To: <17055477-d381-41e2-86a8-b27f871cba3e@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:05:15 -0800 (PST) Hi Babu, On 09/11/2023 20:38, Moger, Babu wrote: > On 10/25/23 13:03, James Morse wrote: >> MPAM's PMG bits extend its PARTID space, meaning the same PMG value can be >> used for different control groups. >> >> This means once a CLOSID is allocated, all its monitoring ids may still be >> dirty, and held in limbo. >> >> Keep track of the number of RMID held in limbo each CLOSID has. This will >> allow a future helper to find the 'cleanest' CLOSID when allocating. >> >> The array is only needed when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID is >> defined. This will never be the case on x86. >> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c >> index 3c9343dffdf7..9a07707d3eb4 100644 >> --- a/arch/x86/kernel/cpu/resctrl/monitor.c >> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c >> @@ -794,13 +815,30 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms) >> static int dom_data_init(struct rdt_resource *r) >> { >> u32 idx_limit = resctrl_arch_system_num_rmid_idx(); >> + u32 num_closid = resctrl_arch_get_num_closid(r); >> struct rmid_entry *entry = NULL; >> + int err = 0, i; >> u32 idx; >> - int i; >> + >> + mutex_lock(&rdtgroup_mutex); >> + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { >> + u32 *tmp; >> + >> + tmp = kcalloc(num_closid, sizeof(*tmp), GFP_KERNEL); >> + if (!tmp) { >> + err = -ENOMEM; >> + goto out_unlock; >> + } >> + >> + closid_num_dirty_rmid = tmp; >> + } > > Any reason tmp variable required here? Line length barking from checkpatch, the resulting newlines and indentation were hard to read, I figured this was more readable. >> rmid_ptrs = kcalloc(idx_limit, sizeof(struct rmid_entry), GFP_KERNEL); >> - if (!rmid_ptrs) >> - return -ENOMEM; >> + if (!rmid_ptrs) { >> + kfree(closid_num_dirty_rmid); > > Should there be check here while feeing? > > if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) Not for the sake of kfree(), which is quite happy with NULL. But it looks like it is needed for the compiler to realise that closid_num_dirty_rmid isn't used at all, and can be optimised out - which was my intention. Thanks, I'll add that. >> + err = -ENOMEM; >> + goto out_unlock; >> + } >> >> for (i = 0; i < idx_limit; i++) { >> entry = &rmid_ptrs[i]; Thanks, James