From: Thomas Gleixner <tglx@linutronix.de>
To: Xie Yuanbin <qq570070308@gmail.com>,
riel@surriel.com, segher@kernel.crashing.org, david@redhat.com,
peterz@infradead.org, hpa@zytor.com, osalvador@suse.de,
linux@armlinux.org.uk, mathieu.desnoyers@efficios.com,
paulmck@kernel.org, pjw@kernel.org, palmer@dabbelt.com,
aou@eecs.berkeley.edu, alex@ghiti.fr, hca@linux.ibm.com,
gor@linux.ibm.com, agordeev@linux.ibm.com,
borntraeger@linux.ibm.com, svens@linux.ibm.com,
davem@davemloft.net, andreas@gaisler.com, luto@kernel.org,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
irogers@google.com, adrian.hunter@intel.com,
james.clark@linaro.org, anna-maria@linutronix.de,
frederic@kernel.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, nathan@kernel.org,
nick.desaulniers+lkml@gmail.com, morbo@google.com,
justinstitt@google.com, qq570070308@gmail.com, thuth@redhat.com,
brauner@kernel.org, arnd@arndb.de, sforshee@kernel.org,
mhiramat@kernel.org, andrii@kernel.org, oleg@redhat.com,
jlayton@kernel.org, aalbersh@redhat.com,
akpm@linux-foundation.org, david@kernel.org,
lorenzo.stoakes@oracle.com, baolin.wang@linux.alibaba.com,
max.kellermann@ionos.com, ryan.roberts@arm.com,
nysal@linux.ibm.com, urezki@gmail.com
Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-s390@vger.kernel.org, sparclinux@vger.kernel.org,
linux-perf-users@vger.kernel.org, llvm@lists.linux.dev,
will@kernel.org
Subject: Re: [PATCH v3 3/3] Make finish_task_switch and its subfuncs inline in context switching
Date: Fri, 14 Nov 2025 21:00:43 +0100 [thread overview]
Message-ID: <87346gbd04.ffs@tglx> (raw)
In-Reply-To: <20251113105227.57650-4-qq570070308@gmail.com>
On Thu, Nov 13 2025 at 18:52, Xie Yuanbin wrote:
What are subfuncs? This is not a SMS service. Use proper words and not
made up abbreviations.
> `finish_task_switch` is a hot path in context switching, and due to
Same comment as before about functions....
> possible mitigations inside switch_mm, performance here is greatly
> affected by function calls and branch jumps. Make it inline to optimize
> the performance.
Again you mark them __always_inline and not inline. Most of them are
already 'inline'. Can you please precise in your wording?
> After `finish_task_switch` is changed to an inline function, the number of
> calls to the subfunctions (called by `finish_task_switch`) increases in
> this translation unit due to the inline expansion of `finish_task_switch`.
> Due to compiler optimization strategies, these functions may transition
> from inline functions to non inline functions, which can actually lead to
> performance degradation.
I'm having a hard time to understand this word salad.
> Make the subfunctions of finish_task_stwitch inline to prevent
> degradation.
>
> Perf test:
> Time spent on calling finish_task_switch (rdtsc):
What means (rdtsc)?
> | compiler && appended cmdline | without patch | with patch |
> | gcc + NA | 13.93 - 13.94 | 12.39 - 12.44 |
What is NA and what are the time units of this?
> | gcc + "spectre_v2_user=on" | 24.69 - 24.85 | 13.68 - 13.73 |
> | clang + NA | 13.89 - 13.90 | 12.70 - 12.73 |
> | clang + "spectre_v2_user=on" | 29.00 - 29.02 | 18.88 - 18.97 |
So the real benefit is observable when spectre_v2_user mitigations are
enabled. You completely fail to explain that.
> Perf test info:
> 1. kernel source:
> linux-next
> commit 9c0826a5d9aa4d52206d ("Add linux-next specific files for 20251107")
> 2. compiler:
> gcc: gcc version 15.2.0 (Debian 15.2.0-7) with
> GNU ld (GNU Binutils for Debian) 2.45
> clang: Debian clang version 21.1.4 (8) with
> Debian LLD 21.1.4 (compatible with GNU linkers)
> 3. config:
> base on default x86_64_defconfig, and setting:
> CONFIG_HZ=100
> CONFIG_DEBUG_ENTRY=n
> CONFIG_X86_DEBUG_FPU=n
> CONFIG_EXPERT=y
> CONFIG_MODIFY_LDT_SYSCALL=n
> CONFIG_CGROUPS=n
> CONFIG_BLK_DEV_NVME=y
This really can go into the comment section below the first '---'
separator. No point in having this in the change log.
> Size test:
> bzImage size:
> | compiler | without patches | with patches |
> | clang | 13722624 | 13722624 |
> | gcc | 12596224 | 12596224 |
bzImage size is completely irrelevant. What's interesting is how the
size of the actual function changes.
> Size test info:
> 1. kernel source && compiler: same as above
> 2. config:
> base on default x86_64_defconfig, and setting:
> CONFIG_SCHED_CORE=y
> CONFIG_CC_OPTIMIZE_FOR_SIZE=y
> CONFIG_NO_HZ_FULL=y
And again, we all know how to build a kernel.
next prev parent reply other threads:[~2025-11-14 20:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 10:52 [PATCH v3 0/3] Optimize code generation during context switching Xie Yuanbin
2025-11-13 10:52 ` [PATCH v3 1/3] Make enter_lazy_tlb inline on x86 Xie Yuanbin
2025-11-13 11:02 ` Xie Yuanbin
2025-11-13 12:11 ` David Hildenbrand (Red Hat)
2025-11-14 19:42 ` Thomas Gleixner
2025-11-15 13:54 ` Xie Yuanbin
2025-11-13 10:52 ` [PATCH v3 2/3] Make raw_spin_rq_unlock inline Xie Yuanbin
2025-11-14 19:44 ` Thomas Gleixner
2025-11-15 14:01 ` Xie Yuanbin
2025-11-13 10:52 ` [PATCH v3 3/3] Make finish_task_switch and its subfuncs inline in context switching Xie Yuanbin
2025-11-14 20:00 ` Thomas Gleixner [this message]
2025-11-15 15:09 ` Xie Yuanbin
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=87346gbd04.ffs@tglx \
--to=tglx@linutronix.de \
--cc=aalbersh@redhat.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=alexander.shishkin@linux.intel.com \
--cc=andreas@gaisler.com \
--cc=andrii@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=baolin.wang@linux.alibaba.com \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=brauner@kernel.org \
--cc=bsegall@google.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=david@kernel.org \
--cc=david@redhat.com \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jlayton@kernel.org \
--cc=jolsa@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=justinstitt@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=llvm@lists.linux.dev \
--cc=lorenzo.stoakes@oracle.com \
--cc=luto@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=max.kellermann@ionos.com \
--cc=mgorman@suse.de \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nysal@linux.ibm.com \
--cc=oleg@redhat.com \
--cc=osalvador@suse.de \
--cc=palmer@dabbelt.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=qq570070308@gmail.com \
--cc=riel@surriel.com \
--cc=rostedt@goodmis.org \
--cc=ryan.roberts@arm.com \
--cc=segher@kernel.crashing.org \
--cc=sforshee@kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=thuth@redhat.com \
--cc=urezki@gmail.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).