All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Sven Schnelle <svens@linux.ibm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andy Lutomirski <luto@kernel.org>
Cc: linux-kernel@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>
Subject: Re: [PATCH 1/3] entry: move exit to usermode functions to header file
Date: Fri, 15 Dec 2023 20:09:27 +0100	[thread overview]
Message-ID: <87r0jnmgew.ffs@tglx> (raw)
In-Reply-To: <20231205133015.752543-2-svens@linux.ibm.com>

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.

Thanks,

        tglx


  reply	other threads:[~2023-12-15 19:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=87r0jnmgew.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=svens@linux.ibm.com \
    /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 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.