linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] include/linux: Fix outdated comment on entry-common.h
@ 2025-06-08 19:48 Khalid Ali
  2025-06-13 16:28 ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Khalid Ali @ 2025-06-08 19:48 UTC (permalink / raw)
  To: tglx, peterz, luto; +Cc: linux-kernel, Khalid Ali

From: Khalid Ali <khaliidcaliy@gmail.com>

On most calls to this function, syscall_enter_from_user_mode_prepare()
never get called as the comment indicates.

Privious kernel version i used to see things happen as the function documentation
indicated (syscall_enter_from_user_mode_prepare() called before
syscall_enter_from_user_mode_work), however it seems now some things
have changed which makes that point irrevelant. Most preparations that
function does is handled manually by enter_from_user_mode() and
some other places. So this makes it misleading.

The point is remove strict function call indication on documentation as might be outdated
one day in the future. There multiple places currently called
syscall_enter_from_user_mode_work() without
syscall_enter_from_user_mode_prepare() get called so that will make it
condition not met.

Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
---
 include/linux/entry-common.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index f94f3fdf15fc..8b52551600cf 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -146,8 +146,7 @@ long syscall_trace_enter(struct pt_regs *regs, long syscall,
  * @syscall:	The syscall number
  *
  * Invoked from architecture specific syscall entry code with interrupts
- * enabled after invoking syscall_enter_from_user_mode_prepare() and extra
- * architecture specific work.
+ * enabled and extra architecture specific work.
  *
  * Returns: The original or a modified syscall number
  *
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* Re: [PATCH] include/linux: Fix outdated comment on entry-common.h
@ 2025-06-13 20:58 Khalid Ali
  2025-06-14  6:34 ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Khalid Ali @ 2025-06-13 20:58 UTC (permalink / raw)
  To: tglx, peterz, luto; +Cc: linux-kernel


> 'include/linux:' is not a valid prefix. See the documentation I pointed
> you to in the other reply.
>
> > From: Khalid Ali <khaliidcaliy@gmail.com>
> >
> > On most calls to this function, syscall_enter_from_user_mode_prepare()
> > never get called as the comment indicates.
> >
> > Privious kernel version i used to see things happen as the function documentation
> > indicated (syscall_enter_from_user_mode_prepare() called before
> > syscall_enter_from_user_mode_work), however it seems now some things
> > have changed which makes that point irrevelant. Most preparations that
> > function does is handled manually by enter_from_user_mode() and
> > some other places. So this makes it misleading.
> >
> > The point is remove strict function call indication on documentation as might be outdated
> > one day in the future. There multiple places currently called
> > syscall_enter_from_user_mode_work() without
> > syscall_enter_from_user_mode_prepare() get called so that will make it
> > condition not met.
>
> That's again incomprehensible word salad.
>
> You are right that the comment is not longer accurate, but your fixup
> makes it even worse.
>
> The real condition for calling this function is:
>
>    1) enter_from_user_mode() has been invoked
>
>    2) interrupts have been enabled
>
>    3) Architecture specific work has been done
>
> #1 must be the first thing. #2 and #3 have no ordering requirements.
>
> syscall_enter_from_user_mode_prepare() does #1 and #2 together and in
> the original implementation this was used in more places. So yes, the
> comment is outdated, but it needs to describe the above requirements and
> not something pulled out of thin air.
>
> Thanks,
>
>       tglx

Thanks and noted, however just asking why syscall_enter_from_user_mode() isn't calling
syscall_enter_from_user_mode_prepare() i don't get it why #1 and #2 is redone, is it because
of instrumentations since syscall_enter_from_user_mode_prepare() is calling instrumentation_end()?

Maybe we need to determine if instrumentation_end() is neccessary for syscall_enter_from_user_mode_prepare().
As i know the only place where syscall_enter_from_user_mode_prepare() is called is arch/x86/entry/syscall_32.c,
on that source when the function returns they begin the instrumentation again using instrumentation_begin(). So i think
with little adjusment of that source file and removing instrumentation_end() on syscall_enter_from_user_mode_prepare()
then we can use syscall_enter_from_user_mode_prepare() as we did. Yet don't know the reason, however suspect some duplication.

Another thing i should indicate if you don't agree with me is, can we change the comment the function to enter_from_user_mode(), 
and with little adjusment make steps as you mentioned.

Let me know if these ideas above right and whether i should keep going on updating the comment.
Thanks, Khalid ALi


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH] kernel/entry: Remove some redundancy checks on syscall works
@ 2025-06-14  6:21 Thomas Gleixner
  2025-06-14 12:04 ` [PATCH] include/linux: Fix outdated comment on entry-common.h Khalid Ali
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2025-06-14  6:21 UTC (permalink / raw)
  To: Khalid Ali, peterz, luto; +Cc: linux-kernel


Can you please reply to the mail you received, so that there are proper
In-Reply-To and References tags in the mail, which are required for mail
threading?

I almost missed your replies because they ended up as single mail
threads without reference somewhere in my endless mail pile.

On Fri, Jun 13 2025 at 20:28, Khalid Ali wrote:

> First if we are talking about performance then we may need likely() on
> SYSCALL_WORK_ENTER since the probability of condition evaluating as
> true is very high.

That depends on the system configuration scenario and the likely() has
been omitted on purpose.

> Second syscall_enter_audit() missing SYSCALL_WORK_SYSCALL_AUDIT
> evaluation, aren't we supposed to call it only if
> SYSCALL_WORK_SYSCALL_AUDIT is set?

That's redundant as syscall_enter_audit() checks for a valid audit
context already. Both are valid indicators and go in lockstep. So it
might be arguable that evaluating the work bit is cheaper than the
context check, but I doubt it's measurable.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-06-14 12:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-08 19:48 [PATCH] include/linux: Fix outdated comment on entry-common.h Khalid Ali
2025-06-13 16:28 ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2025-06-13 20:58 Khalid Ali
2025-06-14  6:34 ` Thomas Gleixner
2025-06-14 11:42   ` Khalid Ali
2025-06-14  6:21 [PATCH] kernel/entry: Remove some redundancy checks on syscall works Thomas Gleixner
2025-06-14 12:04 ` [PATCH] include/linux: Fix outdated comment on entry-common.h Khalid Ali

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).