Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 288D5C61DA4 for ; Mon, 6 Mar 2023 11:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjCFLeP (ORCPT ); Mon, 6 Mar 2023 06:34:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbjCFLeN (ORCPT ); Mon, 6 Mar 2023 06:34:13 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 33BED252B7 for ; Mon, 6 Mar 2023 03:34:00 -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 53C7312FC; Mon, 6 Mar 2023 03:34:43 -0800 (PST) Received: from [10.1.196.177] (eglon.cambridge.arm.com [10.1.196.177]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 884DB3F5A1; Mon, 6 Mar 2023 03:33:57 -0800 (PST) Message-ID: Date: Mon, 6 Mar 2023 11:33:54 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v2 09/18] x86/resctrl: Allow resctrl_arch_rmid_read() to sleep Content-Language: en-GB To: Peter Newman Cc: x86@kernel.org, linux-kernel@vger.kernel.org, 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, tan.shaopeng@fujitsu.com, xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao References: <20230113175459.14825-1-james.morse@arm.com> <20230113175459.14825-10-james.morse@arm.com> From: James Morse In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, On 23/01/2023 15:33, Peter Newman wrote: > On Fri, Jan 13, 2023 at 6:56 PM James Morse wrote: >> MPAM's cache occupancy counters can take a little while to settle once >> the monitor has been configured. The maximum settling time is described >> to the driver via a firmware table. The value could be large enough >> that it makes sense to sleep. > > Would it be easier to return an error when reading the occupancy count > too soon after configuration? On Intel it is already normal for counter > reads to fail on newly-allocated RMIDs. For x86, you have as many counters as there are RMIDs, so there is no issue just accessing the counter. With MPAM there may be as few as 1 monitor for the CSU (cache storage utilisation) counter, which needs to be multiplexed between different PARTID to find the cache occupancy (This works for CSU because its a stable count, it doesn't work for the bandwidth monitors) On such a platform the monitor needs to be allocated and programmed before it reads a value for a particular PARTID/CLOSID. If you had two threads trying to read the same counter, they could interleave perfectly to prevent either thread managing to read a value. The 'not ready' time is advertised in a firmware table, and the driver will wait at most that long before giving up and returning an error. Clearly 1 monitor is a corner case, and I hope no-one ever builds that. But if there are fewer monitors than there are PARTID*PMG you get the same problem, (you just need more threads reading the counters) Thanks, James