Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2742303rda; Wed, 25 Oct 2023 10:57:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoobWXc3sNTZliu5QH6SaclTWZPShdb3tqxdRGnqBfU7A+YC3wqsW2wIzS53HbkWKfeqQG X-Received: by 2002:a81:eb04:0:b0:5a7:a896:3f54 with SMTP id n4-20020a81eb04000000b005a7a8963f54mr488125ywm.26.1698256632738; Wed, 25 Oct 2023 10:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698256632; cv=none; d=google.com; s=arc-20160816; b=PYVJvS02lCZ6MmEb5MIjFy+GcHOYXMBHo6t96uWVg4ax01mb0Ov+R9Zjc+pBi//8Sr 7GlIOOr7VvXnA/qA7vrm32b9DdwqZTmbdw1VnUFPVQwoSu57waw+PK9deIHCng2Jiq/E GwZ0k5rQYcANHCHc9CLHcHAcHiVOp5n1pt+rsk3/c+t8uAhfljURo8ZxqHVsRm60MLZD zUZ6fsBTd2vjvuhufSEpkXiDMFiAunxc/1jVvCTJkFaRTPhG9gzCy7F3snMT0+/azGim Ied0xCxRJE5FhCvtxmFtvpA1nYAX4W108+EBnrKozzA4YqbjlTVA01Wqj7MGskscuW4n YB1A== 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=A9xci2hhEr4fl43o0IITeT4LCuq9KNbHBxWbceeS2Ag=; fh=VuurgKOz/iYGqMeXCSXbmd1sqeKGCB6wb7SlBMhYtIk=; b=u9eRNrBmcN1lSUcgxi6943xR1iVzVeGuvIN/w9ns19R4mbArIxdkOuOkZApx1xIowc 3wa0+WhaJuf6RzjxcrmcEVYb0Foq/qnFb3pcYTbBgP4BQ0AUrW/DaftB6rG3FQUa274R aEs1vfrLSPfihhCOsuloDwLIXuAzuj4dg/wvR30Lf/Z+TNcN+zbqbYxdzgjmLlK7BN5A 371RZhxZYisxaiPHhOw5pL5k/YXo17SrPQN4bwt2HmzY13BGxOldFN8EYy2j+kihRGxv Q+BE0CZjWOqPzqqruxei1XR7iLS8j5QfYTcigsS1QExxEc4ymXJ7nXGl5Ty7cjWWZt6A 23QA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id u13-20020a81840d000000b0058d2f9bd3c3si11935188ywf.57.2023.10.25.10.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 10:57:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 5793E803E5A6; Wed, 25 Oct 2023 10:57:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234338AbjJYR5C (ORCPT + 99 others); Wed, 25 Oct 2023 13:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233233AbjJYR47 (ORCPT ); Wed, 25 Oct 2023 13:56:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 058351A7 for ; Wed, 25 Oct 2023 10:56:55 -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 4DFA51474; Wed, 25 Oct 2023 10:57:37 -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 25E2D3F738; Wed, 25 Oct 2023 10:56:53 -0700 (PDT) Message-ID: Date: Wed, 25 Oct 2023 18:56:47 +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 13/24] x86/resctrl: Queue mon_event_read() instead of sending an IPI 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, 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-14-james.morse@arm.com> <57554be0-5be8-ee03-a9dc-88deaac43453@intel.com> From: James Morse In-Reply-To: <57554be0-5be8-ee03-a9dc-88deaac43453@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Wed, 25 Oct 2023 10:57:09 -0700 (PDT) Hi Reinette, On 03/10/2023 22:17, Reinette Chatre wrote: > On 9/14/2023 10:21 AM, James Morse wrote: >> diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c >> index b44c487727d4..bd263b9a0abd 100644 >> --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c >> +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c >> @@ -19,6 +19,7 @@ >> #include >> #include >> #include >> +#include >> #include "internal.h" >> > > Please keep the empty line between groups of header files. (in this case, adding one, but sure) >> @@ -520,12 +521,24 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of, >> return ret; >> } >> >> +static int smp_mon_event_count(void *arg) >> +{ >> + mon_event_count(arg); >> + >> + return 0; >> +} >> + >> void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, >> struct rdt_domain *d, struct rdtgroup *rdtgrp, >> int evtid, int first) >> { >> + int cpu; >> + >> + /* When picking a CPU from cpu_mask, ensure it can't race with cpuhp */ > > This comment is not accurate at this point. It should accompany the code it applies to. > >> + lockdep_assert_held(&rdtgroup_mutex); This refers to the d->cpu_mask calls further down this function. These are written to by the cpuhp callbacks, rdtgroup_mutex is what prevents the cpuhp callback from running at the same time as mon_event_read(). If that mutex weren't held, you could pick an offline CPU. Patch 24 changes this to be lockdep_asser_cpus_held(), as the mutex is no longer used for this purpose. This got added here instead of patch-24 because I've added additional use of d->cpu_mask, these things serve to document how that is safe. If you prefer I'll leave it unsaid here, and add it with all the others in patch24. Thanks, James