All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] entry: inline syscall enter/exit functions
@ 2023-12-05 13:30 Sven Schnelle
  2023-12-05 13:30 ` [PATCH 1/3] entry: move exit to usermode functions to header file Sven Schnelle
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Sven Schnelle @ 2023-12-05 13:30 UTC (permalink / raw)
  To: Thomas Gleixner, Peter Zijlstra, Andy Lutomirski
  Cc: linux-kernel, Heiko Carstens

Hi List,

looking into the performance of syscall entry/exit after s390 switched
to generic entry showed that there's quite some overhead calling some
of the entry/exit work functions even when there's nothing to do.
This patchset moves the entry and exit function to entry-common.h, so
non inlined code gets only called when there is some work pending.

I wrote a small program that just issues invalid syscalls in a loop.
On an s390 machine, this results in the following numbers:

without this series:

# ./syscall 1000000000
runtime: 94.886581s / per-syscall 9.488658e-08s

with this series:

./syscall 1000000000
runtime: 84.732391s / per-syscall 8.473239e-08s

so the time required for one syscall dropped from 94.8ns to
84.7ns, which is a drop of about 11%.

Sven Schnelle (3):
  entry: move exit to usermode functions to header file
  move enter_from_user_mode() to header file
  entry: move syscall_enter_from_user_mode() to header file

 include/linux/entry-common.h | 137 ++++++++++++++++++++++++++++++++-
 kernel/entry/common.c        | 145 ++---------------------------------
 2 files changed, 138 insertions(+), 144 deletions(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] entry: move exit to usermode functions to header file
@ 2023-12-13 19:48 kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-12-13 19:48 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20231205133015.752543-2-svens@linux.ibm.com>
References: <20231205133015.752543-2-svens@linux.ibm.com>
TO: Sven Schnelle <svens@linux.ibm.com>
TO: Thomas Gleixner <tglx@linutronix.de>
TO: Peter Zijlstra <peterz@infradead.org>
TO: Andy Lutomirski <luto@kernel.org>
CC: linux-kernel@vger.kernel.org
CC: Heiko Carstens <hca@linux.ibm.com>

Hi Sven,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/core/entry]
[also build test WARNING on linus/master v6.7-rc5 next-20231213]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Sven-Schnelle/entry-move-exit-to-usermode-functions-to-header-file/20231205-213501
base:   tip/core/entry
patch link:    https://lore.kernel.org/r/20231205133015.752543-2-svens%40linux.ibm.com
patch subject: [PATCH 1/3] entry: move exit to usermode functions to header file
:::::: branch date: 8 days ago
:::::: commit date: 8 days ago
config: riscv-randconfig-r071-20231211 (https://download.01.org/0day-ci/archive/20231214/202312140345.y20Pgw79-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231214/202312140345.y20Pgw79-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202312140345.y20Pgw79-lkp@intel.com/

smatch warnings:
include/linux/entry-common.h:285 exit_to_user_mode_loop() warn: bitwise AND condition is false here

vim +285 include/linux/entry-common.h

a9f3a74a29af09 Thomas Gleixner 2020-07-22  264  
f682d70e117d9c Sven Schnelle   2023-12-05  265  /**
f682d70e117d9c Sven Schnelle   2023-12-05  266   * exit_to_user_mode_loop - do any pending work before leaving to user space
f682d70e117d9c Sven Schnelle   2023-12-05  267   */
f682d70e117d9c Sven Schnelle   2023-12-05  268  static __always_inline unsigned long exit_to_user_mode_loop(struct pt_regs *regs,
f682d70e117d9c Sven Schnelle   2023-12-05  269  							    unsigned long ti_work)
f682d70e117d9c Sven Schnelle   2023-12-05  270  {
f682d70e117d9c Sven Schnelle   2023-12-05  271  	/*
f682d70e117d9c Sven Schnelle   2023-12-05  272  	 * Before returning to user space ensure that all pending work
f682d70e117d9c Sven Schnelle   2023-12-05  273  	 * items have been completed.
f682d70e117d9c Sven Schnelle   2023-12-05  274  	 */
f682d70e117d9c Sven Schnelle   2023-12-05  275  	while (ti_work & EXIT_TO_USER_MODE_WORK) {
f682d70e117d9c Sven Schnelle   2023-12-05  276  
f682d70e117d9c Sven Schnelle   2023-12-05  277  		local_irq_enable_exit_to_user(ti_work);
f682d70e117d9c Sven Schnelle   2023-12-05  278  
f682d70e117d9c Sven Schnelle   2023-12-05  279  		if (ti_work & _TIF_NEED_RESCHED)
f682d70e117d9c Sven Schnelle   2023-12-05  280  			schedule();
f682d70e117d9c Sven Schnelle   2023-12-05  281  
f682d70e117d9c Sven Schnelle   2023-12-05  282  		if (ti_work & _TIF_UPROBE)
f682d70e117d9c Sven Schnelle   2023-12-05  283  			uprobe_notify_resume(regs);
f682d70e117d9c Sven Schnelle   2023-12-05  284  
f682d70e117d9c Sven Schnelle   2023-12-05 @285  		if (ti_work & _TIF_PATCH_PENDING)
f682d70e117d9c Sven Schnelle   2023-12-05  286  			klp_update_patch_state(current);
f682d70e117d9c Sven Schnelle   2023-12-05  287  
f682d70e117d9c Sven Schnelle   2023-12-05  288  		if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
f682d70e117d9c Sven Schnelle   2023-12-05  289  			arch_do_signal_or_restart(regs);
f682d70e117d9c Sven Schnelle   2023-12-05  290  
f682d70e117d9c Sven Schnelle   2023-12-05  291  		if (ti_work & _TIF_NOTIFY_RESUME)
f682d70e117d9c Sven Schnelle   2023-12-05  292  			resume_user_mode_work(regs);
f682d70e117d9c Sven Schnelle   2023-12-05  293  
f682d70e117d9c Sven Schnelle   2023-12-05  294  		/* Architecture specific TIF work */
f682d70e117d9c Sven Schnelle   2023-12-05  295  		arch_exit_to_user_mode_work(regs, ti_work);
f682d70e117d9c Sven Schnelle   2023-12-05  296  
f682d70e117d9c Sven Schnelle   2023-12-05  297  		/*
f682d70e117d9c Sven Schnelle   2023-12-05  298  		 * Disable interrupts and reevaluate the work flags as they
f682d70e117d9c Sven Schnelle   2023-12-05  299  		 * might have changed while interrupts and preemption was
f682d70e117d9c Sven Schnelle   2023-12-05  300  		 * enabled above.
f682d70e117d9c Sven Schnelle   2023-12-05  301  		 */
f682d70e117d9c Sven Schnelle   2023-12-05  302  		local_irq_disable_exit_to_user();
f682d70e117d9c Sven Schnelle   2023-12-05  303  
f682d70e117d9c Sven Schnelle   2023-12-05  304  		/* Check if any of the above work has queued a deferred wakeup */
f682d70e117d9c Sven Schnelle   2023-12-05  305  		tick_nohz_user_enter_prepare();
f682d70e117d9c Sven Schnelle   2023-12-05  306  
f682d70e117d9c Sven Schnelle   2023-12-05  307  		ti_work = read_thread_flags();
f682d70e117d9c Sven Schnelle   2023-12-05  308  	}
f682d70e117d9c Sven Schnelle   2023-12-05  309  
f682d70e117d9c Sven Schnelle   2023-12-05  310  	/* Return the latest work state for arch_exit_to_user_mode() */
f682d70e117d9c Sven Schnelle   2023-12-05  311  	return ti_work;
f682d70e117d9c Sven Schnelle   2023-12-05  312  }
f682d70e117d9c Sven Schnelle   2023-12-05  313  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2023-12-18  7:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-05 13:30 [PATCH 0/3] entry: inline syscall enter/exit functions Sven Schnelle
2023-12-05 13:30 ` [PATCH 1/3] entry: move exit to usermode functions to header file Sven Schnelle
2023-12-15 19:09   ` Thomas Gleixner
2023-12-18  7:46     ` Sven Schnelle
2023-12-05 13:30 ` [PATCH 2/3] move enter_from_user_mode() " Sven Schnelle
2023-12-05 13:30 ` [PATCH 3/3] entry: move syscall_enter_from_user_mode() " Sven Schnelle
2023-12-06 11:02 ` [PATCH 0/3] entry: inline syscall enter/exit functions Peter Zijlstra
2023-12-14  8:24   ` Sven Schnelle
2023-12-15 19:06     ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2023-12-13 19:48 [PATCH 1/3] entry: move exit to usermode functions to header file kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.