From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E96A2CD128A for ; Wed, 3 Apr 2024 11:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NlVpt9faleXKvTRD2G5WBd1A13EO1/8MCnIsuV1SQaI=; b=S+jlMCyrDhSWep K8lzy59nRQbkDDURd+e+98je4qD0lr5jJlb0BCjqPQD+Xwuomz5vlLjHTDcAlYWmdOfdgl7GAAPCE SY5kRu9Oizo8jCFKNd8WNU3WCd9YlCpE1RadMDO5UIrzjqxY8RbGXnVpyZzH5eJG+KP9OpH70eNIU eQg5pdgWD1Vp9DqJcTE34YzQEQA5R29p7W7BPL6vlVpHcCTS5YN4phlpLdjjpPCvjpw1N0yzA3i5E z7giBFn1IyiT8634ZI0hX8dgDZGM6va8UUUnPnNoA7q9Yydjjx6eKGMlT1vj/czG9q3L/x+QeU85w RinjFzFhDjMs2sQhbfcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rryWM-0000000FinZ-0jS8; Wed, 03 Apr 2024 11:11:10 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rryWK-0000000Fimm-0ZHB for linux-arm-kernel@lists.infradead.org; Wed, 03 Apr 2024 11:11:09 +0000 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 95C4A1595; Wed, 3 Apr 2024 04:11:38 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.16.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 874A53F64C; Wed, 3 Apr 2024 04:11:05 -0700 (PDT) Date: Wed, 3 Apr 2024 12:10:57 +0100 From: Mark Rutland To: Dawei Li Cc: will@kernel.org, xueshuai@linux.alibaba.com, renyu.zj@linux.alibaba.com, yangyicong@hisilicon.com, jonathan.cameron@huawei.com, andersson@kernel.org, konrad.dybcio@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 0/9] perf: Avoid explicit cpumask var allocation from stack Message-ID: References: <20240402105610.1695644-1-dawei.li@shingroup.cn> <190FE91C35AB9AE8+ZgwKuORh3VzTkfeJ@centos8> <6D6795E4D37BB843+Zg0yU8SCf+sMNYqp@centos8> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6D6795E4D37BB843+Zg0yU8SCf+sMNYqp@centos8> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_041108_242635_F6007E30 X-CRM114-Status: GOOD ( 26.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 03, 2024 at 06:41:23PM +0800, Dawei Li wrote: > On Tue, Apr 02, 2024 at 03:41:51PM +0100, Mark Rutland wrote: > > Looking at this case, the only reason we need the mask is because it made the > > logic a little easier to write. All we really want is to choose some CPU in the > > intersection of two masks ignoring a specific CPU, and there was no helper > > function to do that. > > > > We can add a new helper to do that for us, which would avoid redundant work to > > manipulate the entire mask, and it would make the existing code simpler. I had > > a series a few years back to add cpumask_any_and_but(): > > > > https://lore.kernel.org/lkml/1486381132-5610-1-git-send-email-mark.rutland@arm.com/ > > Sounds a perfect idea! > > Actually I am re-implementing new series on top of your seven-years-late-yet-still-helpful > patch, with minor update on it: > > diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h > index 1c29947db848..121f3ac757ff 100644 > --- a/include/linux/cpumask.h > +++ b/include/linux/cpumask.h > @@ -388,6 +388,29 @@ unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) > return i; > } > > +/** > + * cpumask_any_and_but - pick a "random" cpu from *mask1 & *mask2, but not this one. > + * @mask1: the first input cpumask > + * @mask2: the second input cpumask > + * @cpu: the cpu to ignore > + * > + * Returns >= nr_cpu_ids if no cpus set. > + */ > +static inline > +unsigned int cpumask_any_and_but(const struct cpumask *mask1, > + const struct cpumask *mask2, > + unsigned int cpu) > +{ > + unsigned int i; > + > + cpumask_check(cpu); > + i = cpumask_first_and(mask1, mask2); > + if (i != cpu) > + return i; > + > + return cpumask_next_and(cpu, mask1, mask2); > +} > + > /** > * cpumask_nth - get the Nth cpu in a cpumask > * @srcp: the cpumask pointer > > Change from your original version: > 1 Moved to cpumask.h, just like other helpers. > 2 Return value converted to unsigned int. > 3 Remove EXPORT_SYMBOL, for obvious reason. That's exactly how I rebased it locally, so that looks good to me! > I will respin V2 as a whole as soon as possible. Great! Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel