From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21CA634D90D for ; Tue, 6 Jan 2026 15:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767714539; cv=none; b=PzrkpYkXvjPs+APheYw7JnDsP69BhnwBFk9huQNB4gMsY4/hYRt9tPUj6jOisy4BetR0yS/iU7wLkiCCH3zn3MASIwZfSf8EV6Qw5e9Kwrb0VDjqRrwm+L5sQSuZsb+P9jYYGekKo8Y0zxht5EM4t/fYl+fi0pbdyEdmc3LbRhs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767714539; c=relaxed/simple; bh=G/pPociLLqseTOZmij7QHAGaRhCpkREzFhGamSZjAg0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ut8GKIe13hotobHCHbprgwHYiCUjaJ5QiqVcb4cx7nY0V/JHp8FlpGHCqyjGng1ANLdPPhWzDAErrXjdG/ifIVj8LMDaRn7RHtkfjPGMp/M2abB3ZJrlWL6oGGUL2C1zMd3QUpCCbQNnJ4wP+sJyNoYKOW63Akc4ZehXLUplSqM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; arc=none smtp.client-ip=216.40.44.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Received: from omf02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 47DD0C18E3; Tue, 6 Jan 2026 15:48:49 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf02.hostedemail.com (Postfix) with ESMTPA id 1C8B480011; Tue, 6 Jan 2026 15:48:47 +0000 (UTC) Date: Tue, 6 Jan 2026 10:49:11 -0500 From: Steven Rostedt To: K Prateek Nayak Cc: Chen Jinghuang , , , , , , , , , Subject: Re: [RESEND] sched/rt: Skip currently executing CPU in rto_next_cpu() Message-ID: <20260106104911.54fac7f4@gandalf.local.home> In-Reply-To: <077e8b78-f526-497b-b651-50a4e4fbef5e@amd.com> References: <20260105034012.3196947-1-chenjinghuang2@huawei.com> <077e8b78-f526-497b-b651-50a4e4fbef5e@amd.com> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: ampktcniroik9amfhbxcw3cpdgf7xyys X-Rspamd-Server: rspamout03 X-Rspamd-Queue-Id: 1C8B480011 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1/HWJu/vtWpXPoeUJAVYeeoy9I1rS5qcXQ= X-HE-Tag: 1767714527-278009 X-HE-Meta: U2FsdGVkX1/PnCs2v6ZrKKZXUTbRrT5wu/TFtC2/Sks/51yXNkaszro+8iBmuSPDSm0H3t84Py2Ptnni+d9iZocKEFlAJG9SAENpsCiqF4xft9Fsgs57H8CB8lWLm8oMB80Q75e062hiqjQGOV4ILKaH0iyKy63r7/97owxOkUmjGTDGzCslQHXaHyP3khuHO2JwePqLZIq6hqYZGdQl8ebOdRG1X6Gq32csYKmgDeCnFdubLbAbK00OH6wpR/MAuZvaPMnbiDzVUKYfjifboWb47/8Gp8eww75X+q9lrwhdPQTOFred80VXm4qg1WtEY2u3fHpEYr5qhZx8fsS0MofbbaRMvmny On Tue, 6 Jan 2026 14:11:57 +0530 K Prateek Nayak wrote: > Hello Chen, Steve, > > On 1/5/2026 9:10 AM, Chen Jinghuang wrote: > > @@ -2118,10 +2119,13 @@ static int rto_next_cpu(struct root_domain *rd) > > */ > > for (;;) { > > > > - /* When rto_cpu is -1 this acts like cpumask_first() */ > > - cpu = cpumask_next(rd->rto_cpu, rd->rto_mask); > > + do { > > + /* When rto_cpu is -1 this acts like cpumask_first() */ > > + cpu = cpumask_next(rd->rto_cpu, rd->rto_mask); > > > > - rd->rto_cpu = cpu; > > + rd->rto_cpu = cpu; > > + /* Do not send IPI to self */ > > + } while (cpu == this_cpu); > > nit. > > Since we are already within an infinite for-loop, can't we simply do: > > /* Do not send IPI to self */ > if (cpu == this_cpu) > continue; > > here and go evaluate cpumask_next() again instead of adding another > do-while? Was the nested loop intentional to highlight these bits > explicitly? Hmm, yeah, I think I added the loop to express this issue. But I think your suggestion could work too. I originally had something like that, but for some reason I thought it added an extra branch (over the added do { } while). > > > > > if (cpu < nr_cpu_ids) > > return cpu; > for (;;) { /* When rto_cpu is -1 this acts like cpumask_first() */ cpu = cpumask_next(rd->rto_cpu, rd->rto_mask); rd->rto_cpu = cpu; + /* Do not send IPI to self */ + if (cpu == this_cpu) + continue; + if (cpu < nr_cpu_ids) return cpu; rd->rto_cpu = -1; /* * ACQUIRE ensures we see the @rto_mask changes * made prior to the @next value observed. * * Matches WMB in rt_set_overload(). */ next = atomic_read_acquire(&rd->rto_loop_next); if (rd->rto_loop == next) break; rd->rto_loop = next; } Looks to be equivalent. Chen, care to send a new version? -- Steve