Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2742521rda; Wed, 25 Oct 2023 10:57:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKXIi8h8cnc5a7DN55b3AAb9H+xVQ7bSigx3oNMjkejwml63Z38WlcYwI9socdVNrEXdst X-Received: by 2002:a25:4dc2:0:b0:d9a:6669:68ce with SMTP id a185-20020a254dc2000000b00d9a666968cemr15079962ybb.32.1698256663314; Wed, 25 Oct 2023 10:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698256663; cv=none; d=google.com; s=arc-20160816; b=wDPKVPxdHde8lqQyHYv4vq5ZFzTWmEQGDMPlIrsiPr+jVgHcjmbCErDNQkjGlXnp4F peFDCRtrzdtsJYyMUIFnhoJo0wQtyYIMgPaNLmp1onaGbvIDY+92AK46LLzYFrVt5/bW XZEJa4qNPpjgpttu3gGXaPZyjV/2x+jQJJaHXsbMJvZ+ZxnyPOGI3RxSDuQwoHKGMvv7 LcUSIGHtrJpCmsi3XlhIgo+q8elGgheBYPreLGO7/z+2enSlUCcrGu2J0o4afWgCzsHX xOvPJroGP9s8JwFoW72Tw+K0AB3LrbL+Kcd6lsd4eST2xx2zS/RIbfFP3C1MR5iw/NNt geVQ== 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=YaKWfYdwS80Diy4Xq4yIhQCRXlqRO1DsTW6x2Y/cxCY=; fh=VuurgKOz/iYGqMeXCSXbmd1sqeKGCB6wb7SlBMhYtIk=; b=q7K49XsOPQyrPySor2bEDSYjW/FnBgPI7hpjzBfRicEopnANgpaeqJmELsEKKn7mzY Thkak/XQOaEw2EFqjZUIQLHg2YYAbYTv/YDkZkHB8IQbHAgGUvcFw/cScyPSsoznMM9J NnUpYecmx4zt0VXXUj64WdkI1DNIJrr9MK9+dIaCpKTLJbI9rjNZhN3ZHp71hkWZlLYo bMXNP5XrEFzBiz2S8zvdD3r/eI0xfZztgncGM4QW5+1pDs7RfqiPEQP0eU0vWH8OCPuT z8kWngiOw75OavCt+AUdD/PD8aOyrtMxiqk+sHuYRi4+gEVrVL4HEVR4M+5wRbS6h93k IhqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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. [23.128.96.36]) by mx.google.com with ESMTPS id l131-20020a25cc89000000b00da064559bd1si3931900ybf.436.2023.10.25.10.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 10:57:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 EEF9B8135BEB; Wed, 25 Oct 2023 10:57:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234415AbjJYR5a (ORCPT + 99 others); Wed, 25 Oct 2023 13:57:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjJYR52 (ORCPT ); Wed, 25 Oct 2023 13:57:28 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C6F318C for ; Wed, 25 Oct 2023 10:57:25 -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 71E9F1477; Wed, 25 Oct 2023 10:58:06 -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 B6ADE3F738; Wed, 25 Oct 2023 10:57:19 -0700 (PDT) Message-ID: <5f8c45cc-780e-92ca-4b99-6dcfd6db4d01@arm.com> Date: Wed, 25 Oct 2023 18:57:17 +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 21/24] x86/resctrl: Allow overflow/limbo handlers to be scheduled on any-but cpu 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-22-james.morse@arm.com> From: James Morse In-Reply-To: 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 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, 25 Oct 2023 10:57:38 -0700 (PDT) Hi Reinette, On 03/10/2023 22:22, Reinette Chatre wrote: > On 9/14/2023 10:21 AM, James Morse wrote: >> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h >> index c54fa86e4ef9..bd7f60bf49fe 100644 >> --- a/arch/x86/kernel/cpu/resctrl/internal.h >> +++ b/arch/x86/kernel/cpu/resctrl/internal.h >> @@ -60,11 +60,15 @@ >> * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that >> * aren't marked nohz_full >> * @mask: The mask to pick a CPU from. >> + * @exclude_cpu:The CPU to avoid picking. >> * >> - * Returns a CPU in @mask. If there are housekeeping CPUs that don't use >> - * nohz_full, these are preferred. >> + * Returns a CPU from @mask, but not @exclude_cpu. If there are housekeeping >> + * CPUs that don't use nohz_full, these are preferred. Pass >> + * RESCTRL_PICK_ANY_CPU to avoid excluding any CPUs. >> + * Returns >= nr_cpu_ids if no CPUs are available. > It may be helpful to add that the function can only fail if exclude_cpu is > *not* RESCTRL_PICK_ANY_CPU. That helps to understand the sparse error checking. Assuming you don't give it an empty mask, that should be true ... but I've missed a difference between the two helpers use of cpumask_any() when combining them.... It now looks like this: |/** | * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that | * aren't marked nohz_full | * @mask: The mask to pick a CPU from. | * @exclude_cpu:The CPU to avoid picking. | * | * Returns a CPU from @mask, but not @exclude_cpu. If there are housekeeping | * CPUs that don't use nohz_full, these are preferred. Pass | * RESCTRL_PICK_ANY_CPU to avoid excluding any CPUs. | * | * When a CPU is excluded, returns >= nr_cpu_ids if no CPUs are available. | */ |static inline unsigned int |cpumask_any_housekeeping(const struct cpumask *mask, int exclude_cpu) |{ | unsigned int cpu, hk_cpu; | | if (exclude_cpu == RESCTRL_PICK_ANY_CPU) | cpu = cpumask_any(mask); | else | cpu = cpumask_any_but(mask, exclude_cpu); | | /* If the CPU picked isn't marked nohz_full, we're done */ | if (cpu <= nr_cpu_ids && !tick_nohz_full_cpu(cpu)) | return cpu; | | /* Try to find a CPU that isn't nohz_full to use in preference */ | hk_cpu = cpumask_nth_andnot(0, mask, tick_nohz_full_mask); | if (hk_cpu == exclude_cpu) | hk_cpu = cpumask_nth_andnot(1, mask, tick_nohz_full_mask); | | if (hk_cpu < nr_cpu_ids) | cpu = hk_cpu; | | return cpu; |} This also has to check cpu is in range before passing it to tick_nohz_full_cpu(). >> @@ -73,6 +77,9 @@ static inline unsigned int cpumask_any_housekeeping(const struct cpumask *mask) >> return cpu; >> > > It is not obvious from this hunk but I cannot see how this would work > on a system without any nohz_full CPUs. > > At this point the function looks like: > > cpu = cpumask_any(mask); > if (!tick_nohz_full_cpu(cpu)) > return cpu; > > I expected exclude_cpu to be taken into account. If I understand correctly > exclude_cpu can be picked by cpumask_any() and as long as it is not > a nohz_full CPU it would be returned. Yup, I missed this when combining the functions, fixed as above... >> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c >> index 9c6d4b0970e2..208e46ba7368 100644 >> --- a/arch/x86/kernel/cpu/resctrl/monitor.c >> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c >> @@ -807,22 +808,31 @@ void cqm_handle_limbo(struct work_struct *work) >> __check_limbo(d, false); >> >> if (has_busy_rmid(d)) { >> - cpu = cpumask_any_housekeeping(&d->cpu_mask); >> + cpu = cpumask_any_housekeeping(&d->cpu_mask, RESCTRL_PICK_ANY_CPU); >> schedule_delayed_work_on(cpu, &d->cqm_limbo, delay); >> } >> >> mutex_unlock(&rdtgroup_mutex); >> } >> >> -void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms) >> +/** >> + * cqm_setup_limbo_handler() - Schedule the limbo handler to run for this >> + * domain. >> + * @delay_ms: How far in the future the handler should run. >> + * @exclude_cpu: Which CPU the handler should not run on, >> + * RESCTRL_PICK_ANY_CPU to pick any CPU. >> + */ > arch/x86/kernel/cpu/resctrl/monitor.c:824: info: Scanning doc for function cqm_setup_limbo_handler > arch/x86/kernel/cpu/resctrl/monitor.c:832: warning: Function parameter or member 'dom' not described in 'cqm_setup_limbo_handler' What tool outputs this? I've run 'make ARCH=x86 htmldocs', which outputs a tonne of stuff, but I've never found lines about resctrl in there: | morse@eglon:~/kernel/mpam/build_x86_64$ make ARCH=x86 htmldocs &> tee output.log | morse@eglon:~/kernel/mpam/build_x86_64$ cat output.log | grep resctrl | morse@eglon:~/kernel/mpam/build_x86_64$ Thanks, James