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] [day] [month] [year] [list]
Message-ID: <2edf1a85-4736-4e8b-bfc9-003dd1f34be7@linux.ibm.com>
Date: Fri, 7 Nov 2025 14:27:05 +0530
From: Shrikanth Hegde <sshegde@...ux.ibm.com>
To: K Prateek Nayak <kprateek.nayak@....com>,
        Tim Chen <tim.c.chen@...ux.intel.com>,
        Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...nel.org>, Chen Yu <yu.c.chen@...el.com>,
        Doug Nelson <doug.nelson@...el.com>,
        Mohini Narkhede <mohini.narkhede@...el.com>,
        linux-kernel@...r.kernel.org,
        Vincent Guittot <vincent.guittot@...aro.org>
Subject: Re: [PATCH v3] sched/fair: Skip sched_balance_running cmpxchg when
 balance is not due



On 11/7/25 8:27 AM, K Prateek Nayak wrote:
> Hello Tim,
> 
> On 11/7/2025 4:57 AM, Tim Chen wrote:
>> @@ -11757,6 +11772,7 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
>>   		.fbq_type	= all,
>>   		.tasks		= LIST_HEAD_INIT(env.tasks),
>>   	};
>> +	int need_unlock = false;
>>   
>>   	cpumask_and(cpus, sched_domain_span(sd), cpu_active_mask);
>>   
>> @@ -11768,6 +11784,13 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
>>   		goto out_balanced;
>>   	}
>>   
>> +	if (idle != CPU_NEWLY_IDLE && (sd->flags & SD_SERIALIZE)) {

Can you also try removing "idle != CPU_NEWLY_IDLE" and see the workload behavior?
If workloads don't observe regression, it might be worth serializing it too.

>> +		if (atomic_cmpxchg_acquire(&sched_balance_running, 0, 1)) {
>> +			goto out_balanced;
>> +		}
>> +		need_unlock = true;
>> +	}
>> +
>>   	group = sched_balance_find_src_group(&env);
>>   	if (!group) {
>>   		schedstat_inc(sd->lb_nobusyg[idle]);
>> @@ -11892,6 +11915,9 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
>>   			if (!cpumask_subset(cpus, env.dst_grpmask)) {
>>   				env.loop = 0;
>>   				env.loop_break = SCHED_NR_MIGRATE_BREAK;
>> +				if (need_unlock)
>> +					atomic_set_release(&sched_balance_running, 0);
> 
> I believe we should reset "need_unlock" to false here since "redo" can
> fail the atomic_cmpxchg_acquire() while still having "need_unlock" set
> to "true" and the "out_balanced" path will then perform the
> atomic_set_release() when another CPU is in middle of a busy / idle
> balance on a SD_SERIALIZE domain.

Yes. Setting need_unlock = false looks better.

> 
> We can also initialize the "need_unlock" to false just after
> the redo label too - whichever you prefer.
> 
> nit. "need_unlock" can just be a bool instead of an int.
> 
> Apart from that, feel free to include:
> 
> Reviewed-by: K Prateek Nayak <kprateek.nayak@....com>
> 
>> +
>>   				goto redo;
>>   			}
>>   			goto out_all_pinned;
>> @@ -12008,6 +12034,9 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
>>   	    sd->balance_interval < sd->max_interval)
>>   		sd->balance_interval *= 2;
>>   out:
>> +	if (need_unlock)
>> +		atomic_set_release(&sched_balance_running, 0);
>> +
>>   	return ld_moved;
>>   }
>>   
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ