From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Cc: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: Re: [PATCH 1/1] s390: actually restart syscalls after sys_restart
Date: Thu, 21 Jan 2010 09:43:32 -0600 [thread overview]
Message-ID: <20100121154332.GE6878@us.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1001210904210.6064-CXF6herHY6ykSYb+qCZC/1i27PF6R63G9nwVQlTi/Pw@public.gmane.org>
Quoting Oren Laadan (orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org):
> Hi,
>
> I'm not sure thix fix is totally correct.
>
> First, a reminder of how -ERESTART... errors behave:
>
> 1) If a (user) signal handler was *not* called then:
> -ERESTARTSYS: re-execute syscall
> -ERESTARTNOHAND: re-execute syscall
> -ERESTARTNOINTR: re-execute syscall
> -ERESTART_RESTARTBLOCK: arrange to call sys_restart_syscall
>
> 2) If a (user) signal handler *was* called then:
> -ERESTARTSYS: re-execute syscall iff SA_RESTART (else EINTR)
> -ERESTARTNOHAND: return -EINTR
> -ERESTARTNOINTR: re-execute syscall
> -ERESTART_RESTARTBLOCK: return -EINTR
>
> The difference between x86 and s390 is _when_ (and how) the task state is
> altered (to arrange for re-execution), in case of task freezing:
>
> * In x86, changes occur _after_ the task is frozen, and the work is split
> between handle_signal() and do_signal().
>
> * In s390, some changes occur _before_ the task is frozen, and possibly
> undone after the freeze if a signal handler was called. All work is done
> is do_signal(). Because of that, our checkpoint only sees a partial view
> of the task's state.
>
> Now back to the proposed fix: it isn't sufficient because:
>
> (a) If the process has a signal pending when checkpointed, then the state
> already reflects some changes by do_signal(). If the signal leads to a
> (user) signal handler after restart, then do_signal() (after restart) will
> _not_ undo the changes originally done before the checkpoint.
>
> This issue holds for ERESTARTSYS, ERESTARTNOHAND and ERESTART_RESTARTBLOCK.
>
> Note that do_signal() after restart will not do the changes again either
> in case of -ERESTART.... value, because the regs->svcnr was set to 0 and
> recorded that way.
>
> (b) Same, but also if the process didn't have a signal at checkpoint
> time, but will have one during/after restart but before resuming.
>
> (c) Because do_restart() selects its return value from gprs[2] (upon
> successful completion), then when it tries to resume userspace and
> enters do_signal() it will have -EINTR (which isn't the original return
> value!), and therefore not set your new TIF_RESTARTBLOCK bit. If the task
> is now checkpointed again, that state will be lost.
Sorry if I'm misunderstanding what you're saying, but the return value
after exiting sys_restart() won't be -EINTR now, bc my patch sets it to
__NR_restart_syscall.
> As a side note: I noticed that on x86 there are {checkpoint,restore}_thread()
> that save the thread flags and restore the necessary flags. They also
> check the flags - at checkpoint to ensure the task is checkpointable, and
> at restore for sanity. Is there not a need for something similar for s390?
>
> That would be an appropriate place to svae and restore a TIF_RESTARTBLOCK
> thread flag and fix (c) above, should you stick to that method.
We actually want that flag cleared - the flag is only there so that
checkpoint can tell that it needs to set the 'should_restart' flag in
the thread info in the checkpoint image. sys_estart does not then reset
that flag, it instead does the steps which are done in the last block
of do_signal(): set gprs[2] to NR_syscall_restart and add the TIF_RESTART_SVC
thread flag.
-serge
next prev parent reply other threads:[~2010-01-21 15:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-21 6:28 [PATCH 1/1] s390: actually restart syscalls after sys_restart Serge E. Hallyn
[not found] ` <20100121062802.GA2770-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-01-21 15:21 ` Oren Laadan
[not found] ` <Pine.LNX.4.64.1001210904210.6064-CXF6herHY6ykSYb+qCZC/1i27PF6R63G9nwVQlTi/Pw@public.gmane.org>
2010-01-21 15:43 ` Serge E. Hallyn [this message]
[not found] ` <20100121154332.GE6878-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-01-21 16:00 ` Oren Laadan
[not found] ` <Pine.LNX.4.64.1001211048260.10869-CXF6herHY6ykSYb+qCZC/1i27PF6R63G9nwVQlTi/Pw@public.gmane.org>
2010-01-22 4:11 ` Serge E. Hallyn
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=20100121154332.GE6878@us.ibm.com \
--to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.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