mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Reduce system call overhead time (round trip time for invoking a non-existent system call) by 25%. With the removal of set_fs() [1] lazy control register handling was removed in order to keep kernel entry and exit simple. However this made system calls slower. With the conversion to generic entry [2] and numerous follow up changes which simplified the entry code significantly, adding support for lazy asce handling doesn't add much complexity to the entry code anymore. In particular this means: - On kernel entry the primary asce is not modified and contains the user asce - Kernel accesses which require secondary-space mode (for example futex operations) are surrounded by enable_sacf_uaccess() and disable_sacf_uaccess() calls. enable_sacf_uaccess() sets the primary asce to kernel asce so that the sacf instruction can be used to switch to secondary-space mode. The primary asce is changed back to user asce with disable_sacf_uaccess(). The state of the control register which contains the primary asce is reflected with a new TIF_ASCE_PRIMARY bit. This is required on context switch so that the correct asce is restored for the scheduled in process. In result address spaces are now setup like this: CPU running in | %cr1 ASCE | %cr7 ASCE | %cr13 ASCE -----------------------------|-----------|-----------|----------- user space | user | user | kernel kernel (no sacf) | user | user | kernel kernel (during sacf uaccess) | kernel | user | kernel kernel (kvm guest execution) | guest | user | kernel In result cr1 control register content is not changed except for: - futex system calls - legacy s390 PCI system calls - the kvm specific cmpxchg_user_key() uaccess helper This leads to faster system call execution. [1]87d5986345
("s390/mm: remove set_fs / rework address space handling") [2]56e62a7370
("s390: convert to generic entry") Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
36 lines
754 B
C
36 lines
754 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _ASM_S390_ASCE_H
|
|
#define _ASM_S390_ASCE_H
|
|
|
|
#include <linux/thread_info.h>
|
|
#include <linux/irqflags.h>
|
|
#include <asm/lowcore.h>
|
|
#include <asm/ctlreg.h>
|
|
|
|
static inline bool enable_sacf_uaccess(void)
|
|
{
|
|
unsigned long flags;
|
|
|
|
if (test_thread_flag(TIF_ASCE_PRIMARY))
|
|
return true;
|
|
local_irq_save(flags);
|
|
local_ctl_load(1, &get_lowcore()->kernel_asce);
|
|
set_thread_flag(TIF_ASCE_PRIMARY);
|
|
local_irq_restore(flags);
|
|
return false;
|
|
}
|
|
|
|
static inline void disable_sacf_uaccess(bool previous)
|
|
{
|
|
unsigned long flags;
|
|
|
|
if (previous)
|
|
return;
|
|
local_irq_save(flags);
|
|
local_ctl_load(1, &get_lowcore()->user_asce);
|
|
clear_thread_flag(TIF_ASCE_PRIMARY);
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
#endif /* _ASM_S390_ASCE_H */
|