From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@kernel.org, vincent.guittot@linaro.org,
linux-kernel@vger.kernel.org, kprateek.nayak@amd.com,
juri.lelli@redhat.com, vschneid@redhat.com, tglx@linutronix.de,
dietmar.eggemann@arm.com, frederic@kernel.org,
longman@redhat.com
Subject: Re: [PATCH 2/2] sched/fair: get this cpu once in find_new_ilb
Date: Thu, 19 Mar 2026 18:33:19 +0530 [thread overview]
Message-ID: <5a7b737b-ecae-4dad-9965-5297991c01bb@linux.ibm.com> (raw)
In-Reply-To: <20260319092030.GU3738010@noisy.programming.kicks-ass.net>
Hi Peter.
On 3/19/26 2:50 PM, Peter Zijlstra wrote:
> On Thu, Mar 19, 2026 at 12:23:14PM +0530, Shrikanth Hegde wrote:
>> smp_processor_id() is pointless to fetch in the loop. Move it out.
>> No functional change.
>
> Isn't this what compilers are for?
This is what i see in pseries.
c00000000028cc7c: 1d 70 80 48 bl c000000000a93c98 <_find_next_and_bit>
c00000000028cc80: 00 00 00 60 nop
c00000000028cc84: 00 00 bd 80 lwz r5,0(r29)
c00000000028cc88: b4 07 7e 7c extsw r30,r3
c00000000028cc8c: 78 1b 7f 7c mr r31,r3 << This is ilb_cpu
c00000000028cc90: 78 1b 7a 7c mr r26,r3
c00000000028cc94: 40 18 05 7c cmplw r5,r3
c00000000028cc98: 78 f3 c3 7f mr r3,r30
c00000000028cc9c: 5c 00 81 40 ble c00000000028ccf8 <kick_ilb+0x10c>
c00000000028cca0: 08 00 2d a1 lhz r9,8(r13) << cpu comes from paca_index
c00000000028cca4: 00 f8 09 7c cmpw r9,r31
c00000000028cca8: 18 00 82 41 beq c00000000028ccc0 <kick_ilb+0xd4>
c00000000028ccac: 8d 0c 04 48 bl c0000000002cd938 <idle_cpu+0x8>
c00000000028ccb0: 00 00 00 60 nop
c00000000028ccb4: 00 00 03 2c cmpwi r3,0
c00000000028ccb8: 78 00 82 40 bne c00000000028cd30 <kick_ilb+0x144>
c00000000028ccbc: 00 00 bd 80 lwz r5,0(r29)
c00000000028ccc0: 01 00 df 38 addi r6,r31,1
c00000000028ccc4: 20 00 a5 78 clrldi r5,r5,32
c00000000028ccc8: 78 e3 84 7f mr r4,r28
c00000000028cccc: 78 db 63 7f mr r3,r27
c00000000028ccd0: b4 07 c6 7c extsw r6,r6
c00000000028ccd4: c5 6f 80 48 bl c000000000a93c98 <_find_next_and_bit>
So, yes it is done inside the loop. But accessing it should be cheap as it is r13 access
which is the paca pointer.
Since different archs implement it in their own ways
(many would have it cheap, but for some may be costly)
and there is CONFIG_DEBUG_PREEMPT too.
So it would be good to hoist it out of the loop IMHO.
next prev parent reply other threads:[~2026-03-19 13:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 6:53 [PATCH 0/2] sched/fair: Minor improvements while triggering idle load balance Shrikanth Hegde
2026-03-19 6:53 ` [PATCH 1/2] sched/fair: consider hk_mask early in triggering ilb Shrikanth Hegde
2026-03-19 8:15 ` Mukesh Kumar Chaurasiya
2026-03-19 13:13 ` Shrikanth Hegde
2026-03-19 22:58 ` Shubhang Kaushik
2026-03-20 2:47 ` Shrikanth Hegde
2026-03-20 3:37 ` K Prateek Nayak
2026-03-20 9:19 ` Shrikanth Hegde
2026-03-20 11:43 ` Peter Zijlstra
2026-03-20 14:12 ` Shrikanth Hegde
2026-03-20 14:28 ` Shrikanth Hegde
2026-03-19 6:53 ` [PATCH 2/2] sched/fair: get this cpu once in find_new_ilb Shrikanth Hegde
2026-03-19 8:18 ` Mukesh Kumar Chaurasiya
2026-03-19 9:20 ` Peter Zijlstra
2026-03-19 13:03 ` Shrikanth Hegde [this message]
2026-03-19 13:39 ` Peter Zijlstra
2026-03-20 3:40 ` K Prateek Nayak
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=5a7b737b-ecae-4dad-9965-5297991c01bb@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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