lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <yt9dh6kgvtpx.fsf@linux.ibm.com>
Date: Mon, 18 Dec 2023 08:46:18 +0100
From: Sven Schnelle <svens@...ux.ibm.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Peter Zijlstra <peterz@...radead.org>, Andy Lutomirski
 <luto@...nel.org>,
        linux-kernel@...r.kernel.org, Heiko Carstens
 <hca@...ux.ibm.com>
Subject: Re: [PATCH 1/3] entry: move exit to usermode functions to header file

Hi Thomas,

Thomas Gleixner <tglx@...utronix.de> writes:

> On Tue, Dec 05 2023 at 14:30, Sven Schnelle wrote:
>> +/**
>> + * exit_to_user_mode_loop - do any pending work before leaving to user space
>> + */
>> +static __always_inline unsigned long exit_to_user_mode_loop(struct pt_regs *regs,
>> +							    unsigned long ti_work)
>> +{
>> +	/*
>> +	 * Before returning to user space ensure that all pending work
>> +	 * items have been completed.
>> +	 */
>> +	while (ti_work & EXIT_TO_USER_MODE_WORK) {
>> +
>> +		local_irq_enable_exit_to_user(ti_work);
>> +
>> +		if (ti_work & _TIF_NEED_RESCHED)
>> +			schedule();
>> +
>> +		if (ti_work & _TIF_UPROBE)
>> +			uprobe_notify_resume(regs);
>> +
>> +		if (ti_work & _TIF_PATCH_PENDING)
>> +			klp_update_patch_state(current);
>> +
>> +		if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
>> +			arch_do_signal_or_restart(regs);
>> +
>> +		if (ti_work & _TIF_NOTIFY_RESUME)
>> +			resume_user_mode_work(regs);
>> +
>> +		/* Architecture specific TIF work */
>> +		arch_exit_to_user_mode_work(regs, ti_work);
>> +
>> +		/*
>> +		 * Disable interrupts and reevaluate the work flags as they
>> +		 * might have changed while interrupts and preemption was
>> +		 * enabled above.
>> +		 */
>> +		local_irq_disable_exit_to_user();
>> +
>> +		/* Check if any of the above work has queued a deferred wakeup */
>> +		tick_nohz_user_enter_prepare();
>> +
>> +		ti_work = read_thread_flags();
>> +	}
>> +
>> +	/* Return the latest work state for arch_exit_to_user_mode() */
>> +	return ti_work;
>> +}
>
> I'm not really sure about this part. exit_to_user_mode_loop() is the
> slowpath when a TIF work flag is set. I can see the benefit on the
> fastpath functions which are way smaller.

Indeed, the main performance improvement comes from inlining the small
functions. As Peter mentioned the same, i sent out a v2 which doesn't
move exit_to_user_mode_loop().

Thanks!
Sven

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ