Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp444667rdb; Thu, 5 Oct 2023 10:17:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5ryvGS7UjGQBNQFgj1wyYSuw8gevB6efQ0mK6OAVBA8bRc8NvS/14H8E24n60BlSfdAIc X-Received: by 2002:a05:6808:ab6:b0:3a7:5cc1:69b0 with SMTP id r22-20020a0568080ab600b003a75cc169b0mr5991919oij.7.1696526220894; Thu, 05 Oct 2023 10:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696526220; cv=none; d=google.com; s=arc-20160816; b=sqllIjKJYVAvZB/EqyT6WipHT+QSbsjEtRMe+aQrw8glvMc6dbsopYLl5M2oB96nou dKbCJGxc89K4/Vmav67a2yT1C/At4KrMwZLYmKwn2zGLE4i/7GMP/RtATG+cGihHVhCK ulbCdAq/wID6Kj/KMl6qskpvOwIgpgSiS415XtpSx//YpGvZ6mLrQGq8AMDIDTMFp3lC PSxIGUABlF21gJBPJnD2C2FyoPYzap3gi23st14WJrSlY0XvznpI0R3YW5KaqfFQ84bP oC20jxJ0jRq4WSDh3n/7o4fi4h4jzmM/Tci0CO07+vL2Z2k9/3t18zr+XUcJARqT79Rx Nnyw== 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=Z3uBjEMg4tnYqfEio+iAaWRRE/jgYzawKTaJ+0p1i4g=; fh=V3EXrfhtPXQ8VZs+995Yo8T+zOpBnshrD4ANVkhZrjM=; b=xAJR7N5XdH4KE6YJ0aaF+EzXPQk7RoxVv4eMcRRbyqDFe39GfyblfWc6cRIXGKSz9v K1Xww1XfOFlWZfqqQ9YrwA4Xpb2PsQoo4eehxS197rbRmOE1Qfmn8tE8igEgHse3LUFW SARvm7zuRmp2Fk37/w5gHQ9PZVJCC5fPmj6V0IXOzZpKB9jNI+GTH9Eo7zfCQP4T0712 COFv81zx1RWBGzHAFwgMtmsbTiMu5JLG1I/1mGQXT9L6IFSWbvkwlEkYC+xqV1nQUfBw yU8WxitSc1vf5QO/10SrzeWvzFrajVtnRe8f7xdAL4Ja36JbLC54KsqS8uN/A8EuTuvs 66gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id bx42-20020a056a02052a00b00578b8016c3esi2002428pgb.138.2023.10.05.10.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:17:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id CF5968047057; Thu, 5 Oct 2023 10:16:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231325AbjJERQB (ORCPT + 99 others); Thu, 5 Oct 2023 13:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbjJERPE (ORCPT ); Thu, 5 Oct 2023 13:15:04 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F1A873A92 for ; Thu, 5 Oct 2023 10:07:06 -0700 (PDT) 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 6823CC15; Thu, 5 Oct 2023 10:07:45 -0700 (PDT) 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 467CC3F5A1; Thu, 5 Oct 2023 10:07:04 -0700 (PDT) Message-ID: Date: Thu, 5 Oct 2023 18:07:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v6 08/24] x86/resctrl: Track the number of dirty RMID a CLOSID has Content-Language: en-GB To: Reinette Chatre , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , 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, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com References: <20230914172138.11977-1-james.morse@arm.com> <20230914172138.11977-9-james.morse@arm.com> <3f448b5e-de75-35fa-02ab-7cbd37389227@intel.com> From: James Morse In-Reply-To: <3f448b5e-de75-35fa-02ab-7cbd37389227@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 10:16:35 -0700 (PDT) Hi Reinette, On 03/10/2023 22:13, Reinette Chatre wrote: > On 9/14/2023 10:21 AM, James Morse wrote: >> @@ -796,13 +817,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)) { >> + int *tmp; >> + >> + tmp = kcalloc(num_closid, sizeof(int), GFP_KERNEL); > > Shouldn't this rather be sizeof(unsigned int) to match the type it will store? It matches the type of tmp... I'll change both closid_num_dirty_rmid and tmp to a u32 *, and this sizeof() to be sizeof(*tmp). >> + if (!tmp) { >> + err = -ENOMEM; >> + goto out_unlock; >> + } >> + >> + closid_num_dirty_rmid = tmp; >> + } >> >> rmid_ptrs = kcalloc(idx_limit, sizeof(struct rmid_entry), GFP_KERNEL); >> - if (!rmid_ptrs) >> - return -ENOMEM; >> + if (!rmid_ptrs) { >> + kfree(closid_num_dirty_rmid); >> + err = -ENOMEM; >> + goto out_unlock; >> + } >> >> for (i = 0; i < idx_limit; i++) { >> entry = &rmid_ptrs[i]; >> @@ -822,13 +860,21 @@ static int dom_data_init(struct rdt_resource *r) >> entry = __rmid_entry(idx); >> list_del(&entry->list); >> >> - return 0; >> +out_unlock: >> + mutex_unlock(&rdtgroup_mutex); >> + >> + return err; >> } >> >> void resctrl_exit_mon_l3_config(struct rdt_resource *r) >> { >> mutex_lock(&rdtgroup_mutex); >> >> + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { >> + kfree(closid_num_dirty_rmid); >> + closid_num_dirty_rmid = NULL; >> + } >> + >> kfree(rmid_ptrs); >> rmid_ptrs = NULL; >> > > Awaiting response on patch #2 related to above hunk. It's the same story here. CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID makes this behaviour visible to the filesystem code, which means the filesystem code can do the alloc/free of this array. All this eventually moves out to /fs/. This is all because the RMID allocation is dependent on the limbo list that resctrl manages, and for MPAM the CLOSID is too. I'm sure its simpler to expose this MPAM behaviour to resctrl - and in a way that the compiler can remove if its not needed. The alternative would be to duplicate the allocators on each architecture. I don't think MPAM is different enough to justify this. Thanks, James