public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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 4/4] x86/resctrl: optimize cpumask_any_housekeeping()
Date: Wed, 23 Apr 2025 14:29:48 -0700	[thread overview]
Message-ID: <de0758c8-76d5-4ead-84f2-40db45ff4ed8@intel.com> (raw)
In-Reply-To: <20250407153856.133093-5-yury.norov@gmail.com>

Hi Yury,

On 4/7/25 8:38 AM, Yury Norov wrote:
> From: Yury Norov [NVIDIA] <yury.norov@gmail.com>
> 
> With the lack of cpumask_andnot_any_but(), users have to abuse
> cpumask_nth() functions which are O(N*log(N)), comparing to O(N)
> for cpumask_any().
> 
> This series adds missing cpumask_andnot_any_but() and makes
> cpumask_any_but() understanding the RESCTRL_PICK_ANY_CPU hint.
> This simplifies cpumask_any_housekeeping() significantly.

The "This series ..." language is more appropriate for the cover
letter. 

This changelog could be something like:

	With the lack of cpumask_andnot_any_but(), cpumask_any_housekeeping()
	abused cpumask_nth() functions which are O(N*log(N)), compared to O(N)                
	for cpumask_any().                                                              
                                                                                
	Update cpumask_any_housekeeping() to use the new cpumask_any_but() and          
	cpumask_andnot_any_but(). These two functions understand RESCTRL_PICK_ANY_CPU   
	and simplifies cpumask_any_housekeeping() significantly.                        


Also, could you please have the subject of this patch start with an
upper case: "x86/resctrl: Optimize cpumask_any_housekeeping()"?

> 
> Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
> ---
>  arch/x86/kernel/cpu/resctrl/internal.h | 28 +++++++-------------------
>  1 file changed, 7 insertions(+), 21 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index 20c898f09b7e..1db02bab9743 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -71,30 +71,16 @@
>  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);
> -
> -	/* Only continue if tick_nohz_full_mask has been initialized. */
> -	if (!tick_nohz_full_enabled())
> -		return cpu;
> -
> -	/* If the CPU picked isn't marked nohz_full nothing more needs doing. */
> -	if (cpu < nr_cpu_ids && !tick_nohz_full_cpu(cpu))
> -		return cpu;
> +	unsigned int 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;
> +	if (tick_nohz_full_enabled()) {
> +		cpu = cpumask_andnot_any_but(mask, tick_nohz_full_mask, exclude_cpu);
> +		if (cpu < nr_cpu_ids)
> +			return cpu;
> +	}
>  
> -	return cpu;
> +	return cpumask_any_but(mask, exclude_cpu);
>  }
>  
>  struct rdt_fs_context {

This looks good to me. Thank you very much for doing this.

Reinette

  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
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 [this message]
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=de0758c8-76d5-4ead-84f2-40db45ff4ed8@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