Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2742844rda; Wed, 25 Oct 2023 10:58:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHT4wgccSJo+rliFiL6HhgADuxNWnFts6P4vpGkp/kV/cildYSoebLQikpmRL7DcfFdZpKn X-Received: by 2002:a5b:f47:0:b0:d9a:ba25:d1f9 with SMTP id y7-20020a5b0f47000000b00d9aba25d1f9mr15829065ybr.9.1698256706168; Wed, 25 Oct 2023 10:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698256706; cv=none; d=google.com; s=arc-20160816; b=XotBwKJLEiNOH/XELH5QTwXdQl7Uuq/3riMxzXcYlgpjyhWLg3ODNBlUTfF1uJLuit Tk2roRY8C7bqx58OLqtR+TdxkAVcQuTwV2+SnVwKCTJjjgxeKfRFElxtbCsPweMvK+BO liiXPAtlAFRj5cxi14Yiw99wDX4DZR7LbFgeIWEL7nM0QSUGVW3k/pbMwTFDsC8uNSHG 4zZ2RMGsNp8hJRAmCiamXfgmM1X1SyUMlVJHjBSollEmtXvjzp9kf9De0mdqo+byV4AX pS/yb0XifkV94xZ6FLstPp8zAk06HoFPgnTw9AXMnhnAsp445JHkNVXnb2ySrpCM93Tw UhiQ== 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=8KZtWoeix0D+6Xza4zrXf+HsRJIhpH4sRe6GcQcqAAU=; fh=9O97hdzEezSdAQ/hEUF6K6/7TfN/3Uf0QBPpPtoaJ2Y=; b=X7U/y7pnHI8wmktO60vlTG3t0w0MBB10VSG7Sy3I51gMFtE1fZpJ/Ak6bJAAbsm5cR QJd3HNEO4zBcp14o8WWSTskdCPzz3S5kyNpkWd9zeqtOirTpB/p0IiOUh8DSoiKZMBqj nr3x/F26LNP4N2TjH9lYEkOBD5y4nzobjmiIt450lHtYjfs7ZI5QeQc2IkuYp8VtR6YP Ot2lE9Xbf/X5leT4Jx8PawCT3S94elQwqQ/pSthZxJtTZ6/S8a0dd1YWkthf5LfELDxn eyKyfWipRzuuHvNb1PggIkGJ4qRdam9rkdV3T/R5LSvfsfkDqcQI7WkmYqza65QrtKwe Wh+w== 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 v127-20020a252f85000000b00da0352438dbsi5506764ybv.590.2023.10.25.10.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 10:58:26 -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 B317C811F134; Wed, 25 Oct 2023 10:58:23 -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 S234591AbjJYR6V (ORCPT + 99 others); Wed, 25 Oct 2023 13:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233862AbjJYR6U (ORCPT ); Wed, 25 Oct 2023 13:58:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C8CB0191 for ; Wed, 25 Oct 2023 10:58:16 -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 838B81516; Wed, 25 Oct 2023 10:58:57 -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 3B9093F738; Wed, 25 Oct 2023 10:58:11 -0700 (PDT) Message-ID: Date: Wed, 25 Oct 2023 18:58:09 +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 15/24] x86/resctrl: Allow arch to allocate memory needed in resctrl_arch_rmid_read() 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, xingxin.hx@openanolis.org, 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-16-james.morse@arm.com> <14289ca5-5e33-6cfc-fe65-e5fd9651ed99@amd.com> From: James Morse In-Reply-To: <14289ca5-5e33-6cfc-fe65-e5fd9651ed99@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 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]); Wed, 25 Oct 2023 10:58:23 -0700 (PDT) Hi Babu, On 05/10/2023 22:46, Moger, Babu wrote: > On 9/14/2023 12:21 PM, James Morse wrote: >> Depending on the number of monitors available, Arm's MPAM may need to >> allocate a monitor prior to reading the counter value. Allocating a >> contended resource may involve sleeping. >> >> add_rmid_to_limbo() calls resctrl_arch_rmid_read() for multiple domains, >> the allocation should be valid for all domains. >> >> __check_limbo() and mon_event_count() each make multiple calls to >> resctrl_arch_rmid_read(), to avoid extra work on contended systems, >> the allocation should be valid for multiple invocations of >> resctrl_arch_rmid_read(). >> >> Add arch hooks for this allocation, which need calling before >> resctrl_arch_rmid_read(). The allocated monitor is passed to >> resctrl_arch_rmid_read(), then freed again afterwards. The helper >> can be called on any CPU, and can sleep. >>   diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h >> index f7311102e94c..5e4b4df9610b 100644 >> --- a/include/linux/resctrl.h >> +++ b/include/linux/resctrl.h >> @@ -235,6 +235,9 @@ void resctrl_offline_domain(struct rdt_resource *r, struct >> rdt_domain *d); >>    * @rmid:        rmid of the counter to read. >>    * @eventid:        eventid to read, e.g. L3 occupancy. >>    * @val:        result of the counter read in bytes. >> + * @arch_mon_ctx:    An architecture specific value from >> + *            resctrl_arch_mon_ctx_alloc(), for MPAM this identifies >> + *            the hardware monitor allocated for this read request. >>    * >>    * Some architectures need to sleep when first programming some of the counters. >>    * (specifically: arm64's MPAM cache occupancy counters can return 'not ready' >> @@ -248,7 +251,7 @@ void resctrl_offline_domain(struct rdt_resource *r, struct >> rdt_domain *d); >>    */ >>   int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, >>                  u32 closid, u32 rmid, enum resctrl_event_id eventid, >> -               u64 *val); >> +               u64 *val, void *arch_mon_ctx); > Just wondering.. Have you thought about passing rmid_read structure to this function? I did, but I'd prefer to leave that as private to resctrl as the proposed PMU driver ends up using this API too. > Because most of the information is already inside the rmid_read structure. We can avoid > passing 7 parameters. We'd end up passing all these parameters via memory ... but the compiler knows when it has to do this, and when it doesn't. For example on aarch64 the compiler knows it can pass all seven of these arguments in registers. On x86_64 it looks like 6 arguments can be passed, and the last one is never used on x86 so it never needs reading off the stack. (all this feels like micro-optimisation!) Thanks, James