linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-alpha@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCHES] alpha asm glue cleanups and fixes
Date: Fri, 2 Sep 2022 02:48:55 +0100	[thread overview]
Message-ID: <YxFhB4/cEXX5aHbn@ZenIV> (raw)
In-Reply-To: <YU6PVepETVUJF28v@zeniv-ca.linux.org.uk>

Resurrecting old series:

 	Fallout from asm glue review on alpha:

1) TIF_NOTIFY_SIGNAL support is broken; do_work_pending() handles
it, but the logics *calling* do_work_pending() ignores that flag
completely.  If it's called for other reasons - fine, but
TIF_NOTIFY_SIGNAL alone will not suffice for that.  Bug from the
last cycle.  5.11 bug.

2) _TIF_ALLWORK_MASK is junk - never had been used.
 
3) !AUDIT_SYSCALL configs have buggered logics for going into
straced syscall path.  Any thread flag (including TIF_SIGNAL_PENDING)
will suffice to send us there.  3.14 bug.
 
4) on straced syscalls we have force_successful_syscall_return() broken -
it ends up with a3 *not* set to 0.

5) on non-straced syscalls force_successful_syscall_return() handling is
suboptimal - it duplicates code from the normal syscall return path for
no good reason; instead of branching to the copy, it might branch to the
original just fine.

6) ret_from_fork could just as well go to ret_from_user - it's not going
to be hit when returning to kernel mode.

7) lazy FPU switching.  We save/restore all FPU registers a lot more than
we have to; the following reduces the amount quite a bit:
	* move the array we save into from switch_stack to thread_info
	* have a (thread-synchronous) flag set when we save them
	* have another flag set when they should be restored on return to
userland.
	* do *NOT* save/restore them in do_switch_stack()/undo_switch_stack().
	* restore on the exit to user mode if the restore flag had been set.
Clear both flags.
	* on context switch, entry to fork/clone/vfork, before entry into
do_signal() and on entry into straced syscall save the registers and set
the 'saved' flag unless it had been already set.
	* on context switch set the 'restore' flag as well.
	* have copy_thread() set both flags for child, so the registers would
be restored once the child returns to userland.
	* use the saved data in setup_sigcontext(); have restore_sigcontext()
set both flags and copy from sigframe to save area.
	* teach ptrace to look for FPU registers in thread_info instead of
switch_stack.
	* teach isolated accesses to FPU registers (rdfpcr, wrfpcr, etc.)
to check the 'saved' flag (under preempt_disable()) and work with the save area
if it's been set; if 'saved' flag is found upon write access, set 'restore' flag
as well.  NOTE: it's tempting to just force register saving in those - it
would simplify the code quite a bit.  Unfortunately, it would also force the
full FPU save/restore in situations where we really don't want the overhead
of that ;-/

Tested on qemu and on real hw (older one - the only EV67 box I have is not
in good condition).  Seems to work; benefits depend upon the load.

Patchset lives in git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git
#next.alpha; individual patches in followups.

  parent reply	other threads:[~2022-09-02  1:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-25  2:54 [PATCHES] alpha asm glue cleanups and fixes Al Viro
2021-09-25  2:55 ` [PATCH 1/6] alpha: fix TIF_NOTIFY_SIGNAL handling Al Viro
2021-09-25  2:55   ` [PATCH 2/6] alpha: _TIF_ALLWORK_MASK is unused Al Viro
2021-09-25  2:55   ` [PATCH 3/6] alpha: fix syscall entry in !AUDUT_SYSCALL case Al Viro
2021-09-25  2:55   ` [PATCH 4/6] alpha: fix handling of a3 on straced syscalls Al Viro
2021-09-25  2:55   ` [PATCH 5/6] alpha: syscall exit cleanup Al Viro
2021-09-25  2:55   ` [PATCH 6/6] alpha: ret_from_fork can go straight to ret_to_user Al Viro
2021-09-25  2:55   ` [PATCH 7/7] alpha: lazy FPU switching Al Viro
2021-09-25 19:07     ` Linus Torvalds
2021-09-25 20:43       ` Al Viro
2021-09-25 23:18         ` Linus Torvalds
2021-09-26  0:31           ` Al Viro
2021-10-30 20:46         ` Al Viro
2021-10-30 20:46           ` Al Viro
2021-10-30 21:25           ` Maciej W. Rozycki
2021-10-30 22:13             ` Al Viro
2021-09-26  9:08       ` John Paul Adrian Glaubitz
2021-09-25  2:59 ` [PATCHES] alpha asm glue cleanups and fixes Al Viro
2022-09-02  1:48 ` Al Viro [this message]
2022-09-02  1:50   ` [PATCH v2 1/7] alpha: fix TIF_NOTIFY_SIGNAL handling Al Viro
2022-09-02  1:50     ` [PATCH v2 2/7] alpha: _TIF_ALLWORK_MASK is unused Al Viro
2022-09-02  1:50     ` [PATCH v2 3/7] alpha: fix syscall entry in !AUDUT_SYSCALL case Al Viro
2022-09-02  1:50     ` [PATCH v2 4/7] alpha: fix handling of a3 on straced syscalls Al Viro
2022-09-02  1:50     ` [PATCH v2 5/7] alpha: syscall exit cleanup Al Viro
2022-09-02  1:50     ` [PATCH v2 6/7] alpha: ret_from_fork can go straight to ret_to_user Al Viro
2022-09-02  1:50     ` [PATCH v2 7/7] alpha: lazy FPU switching Al Viro
2022-09-02  4:24       ` Linus Torvalds
2022-09-02  5:07         ` Al Viro
2022-09-02  5:14           ` Al Viro

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=YxFhB4/cEXX5aHbn@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-alpha@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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 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).