lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z3oDyqZK5pcPZ7y4@yury-ThinkPad>
Date: Sat, 4 Jan 2025 20:00:10 -0800
From: Yury Norov <yury.norov@...il.com>
To: Andrea Righi <arighi@...dia.com>
Cc: Tejun Heo <tj@...nel.org>, David Vernet <void@...ifault.com>,
	Changwoo Min <changwoo@...lia.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched_ext: idle: small CPU iteration refactoring

On Sat, Jan 04, 2025 at 10:00:09AM +0100, Andrea Righi wrote:
> loop to check if all SMT CPUs are idle with
> cpumask_subset(). This simplifies the code and slightly improves
> efficiency, while preserving the original behavior.

In my experience, replacing iterator with a dedicated function makes
you 400-500 times faster. So 'slightly' sounds like an understatement
here.

> Note that idle_masks.smt handling remains racy, which is acceptable as
> it serves as an optimization and is self-correcting.
> 
> Suggested-by: Yury Norov <yury.norov@...il.com>
> Signed-off-by: Andrea Righi <arighi@...dia.com>

Reviewed-by: Yury Norov <yury.norov@...il.com>

> ---
>  kernel/sched/ext.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 926579624c41..0ce116e0f67c 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -3671,10 +3671,8 @@ void __scx_update_idle(struct rq *rq, bool idle)
>  			 * idle_masks.smt handling is racy but that's fine as
>  			 * it's only for optimization and self-correcting.
>  			 */
> -			for_each_cpu(cpu, smt) {
> -				if (!cpumask_test_cpu(cpu, idle_masks.cpu))
> -					return;
> -			}
> +			if (!cpumask_subset(smt, idle_masks.cpu))
> +				return;
>  			cpumask_or(idle_masks.smt, idle_masks.smt, smt);
>  		} else {
>  			cpumask_andnot(idle_masks.smt, idle_masks.smt, smt);
> -- 
> 2.47.1
> 
> From yury  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ