From: Reinette Chatre <reinette.chatre@intel.com>
To: Yury Norov <yury.norov@gmail.com>,
Tony Luck <tony.luck@intel.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "Borislav Petkov" <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>, <x86@kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/4] cpumask: add cpumask_{first,next}_andnot() API
Date: Wed, 23 Apr 2025 14:28:38 -0700 [thread overview]
Message-ID: <c96bade5-200a-4812-8df6-d6dcf2984a01@intel.com> (raw)
In-Reply-To: <20250407153856.133093-4-yury.norov@gmail.com>
Hi Yury,
On 4/7/25 8:38 AM, Yury Norov wrote:
...
> @@ -284,6 +297,25 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p,
> small_cpumask_bits, n + 1);
> }
>
> +/**
> + * cpumask_next_andnot - get the next cpu in *src1p & ~*src2p
> + * @n: the cpu prior to the place to search (i.e. return will be > @n)
> + * @src1p: the first cpumask pointer
> + * @src2p: the second cpumask pointer
> + *
> + * Return: >= nr_cpu_ids if no further cpus set in both.
> + */
> +static __always_inline
> +unsigned int cpumask_next_andnot(int n, const struct cpumask *src1p,
> + const struct cpumask *src2p)
Looks like the custom followed here is to name parameter that can have
-1 as value "n" and let it have type "int". Should this also apply to
cpumask_andnot_any_but(), cpumask_any_but(), and cpumask_any_and_but()
modified/introduced in this series?
> +{
> + /* -1 is a legal arg here. */
> + if (n != -1)
> + cpumask_check(n);
> + return find_next_andnot_bit(cpumask_bits(src1p), cpumask_bits(src2p),
> + small_cpumask_bits, n + 1);
> +}
> +
> /**
> * cpumask_next_and_wrap - get the next cpu in *src1p & *src2p, starting from
> * @n+1. If nothing found, wrap around and start from
> @@ -458,6 +490,33 @@ unsigned int cpumask_any_and_but(const struct cpumask *mask1,
> return cpumask_next_and(cpu, mask1, mask2);
> }
>
> +/**
> + * cpumask_andnot_any_but - pick an arbitrary cpu from *mask1 & ~*mask2, but not this one.
> + * @mask1: the first input cpumask
> + * @mask2: the second input cpumask
> + * @cpu: the cpu to ignore
> + *
> + * If @cpu == -1, the function returns the first matching cpu.
> + * Returns >= nr_cpu_ids if no cpus set.
> + */
> +static __always_inline
> +unsigned int cpumask_andnot_any_but(const struct cpumask *mask1,
> + const struct cpumask *mask2,
> + unsigned int cpu)
Since -1 is legal argument I expect "cpu" to be int.
> +{
> + unsigned int i;
> +
> + /* -1 is a legal arg here. */
> + if (cpu != -1)
> + cpumask_check(cpu);
> +
> + i = cpumask_first_andnot(mask1, mask2);
> + if (i != cpu)
> + return i;
> +
> + return cpumask_next_andnot(cpu, mask1, mask2);
> +}
> +
> /**
> * cpumask_nth - get the Nth cpu in a cpumask
> * @srcp: the cpumask pointer
Reinette
next prev parent reply other threads:[~2025-04-23 21:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 15:38 [PATCH 0/4] cpumask: add missing API and simplify cpumask_any_housekeeping() Yury Norov
2025-04-07 15:38 ` [PATCH 1/4] cpumask: relax cpumask_any_but() Yury Norov
2025-04-23 21:28 ` Reinette Chatre
2025-04-24 2:46 ` Yury Norov
2025-04-07 15:38 ` [PATCH 2/4] find: add find_first_andnot_bit() Yury Norov
2025-04-23 21:28 ` Reinette Chatre
2025-04-24 2:57 ` Yury Norov
2025-04-07 15:38 ` [PATCH 3/4] cpumask: add cpumask_{first,next}_andnot() API Yury Norov
2025-04-23 21:28 ` Reinette Chatre [this message]
2025-04-24 2:58 ` Yury Norov
2025-04-24 17:07 ` James Morse
2025-04-07 15:38 ` [PATCH 4/4] x86/resctrl: optimize cpumask_any_housekeeping() Yury Norov
2025-04-23 21:29 ` Reinette Chatre
2025-04-24 3:01 ` Yury Norov
2025-04-22 13:50 ` [PATCH 0/4] cpumask: add missing API and simplify cpumask_any_housekeeping() Yury Norov
2025-04-22 15:13 ` Reinette Chatre
2025-04-23 21:27 ` Reinette Chatre
2025-04-24 3:11 ` Yury Norov
2025-04-24 17:22 ` James Morse
2025-04-24 17:12 ` James Morse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c96bade5-200a-4812-8df6-d6dcf2984a01@intel.com \
--to=reinette.chatre@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox