public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Benjamin LaHaise <bcrl@redhat.com>,
	Roman Zippel <zippel@linux-m68k.org>,
	David Howells <dhowells@redhat.com>,
	alan@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: manipulating sigmask from filesystems and drivers
Date: Thu, 17 Oct 2002 09:32:25 +0100	[thread overview]
Message-ID: <22897.1034843545@passion.cambridge.redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0208020920120.18265-100000@home.transmeta.com>


On Fri, 2 Aug 2002, Linus Torvalds wrote:
> Actually, i fyou read my original email on this thread, I actually
> suggested splitting up the "INTERRUPTIBLE" vs "UNINTERRUPTIBLE" into
> three different cases and one extra bit.
>
> Sending somebody a SIGKILL (or any signal that kills the process) is
> different (in my opinion) from a signal that interrupts a system call
> in order to run a signal handler.
>
> So my original suggestion on this thread was to make 
> 
>         TASK_WAKESIGNAL - wake on all signals
>         TASK_WAKEKILL   - wake on signals that are deadly
>         TASK_NOSIGNAL   - don't wake on signals
>         TASK_LOADAVG    - counts toward loadaverage
>
>         #define TASK_UNINTERRUPTIBLE    (TASK_NOSIGNAL | TASK_LOADAVG)
>         #define TASK_INTERRUPTIBLE      TASK_WAKESIGNAL
>
> and then let code like generic_file_write() etc use other combinations
> than the two existing ones, ie
>
> 	(TASK_WAKEKILL | TASK_LOADAVG) 
>
> results in a process that is woken up by signals that kill it (but not
> other signals), and is counted towards the loadaverage. Which is what we
> want in generic_file_read() (and _probably_ generic_file_write() as well,
> but that's slightly more debatable).

I like this, but perhaps with a slight modification. I think that instead of
being a flag in the task state, the 'can we deal with being interrupted'
should instead be a _counter_, and the process in question can be woken 
by signals only if it's zero. For the following reason:

In the world you describe above, a function sets the NOSIGNAL flag when
sleeping if it can't deal with being interrupted -- presumably because it 
has no simple way to clean up its state in that case.

But we should remain aware that the ability to clean up on being interrupted
is not a function of only the bottom-most function on the call stack; it is
actually a function of the _entire_ call stack, in some cases all the way
back up to the userspace program making the system call. Every function in
the call stack needs to be able to deal with the -EINTR return and clean up
appropriately, not just the bottom-most function.

Consider the case where function A() sleeps, and can perfectly happily deal
with being interrupted. It is called from function B() which can also deal
with an -EINTR return from A(), and in fact _wants_ to do so because it can
take a long time and being uninterruptible would suck. The majority of 
callers of function A() are of this nature, and want to be interruptible.

But there exists a function C() which also calls function A(), and which 
_cannot_ deal with being interrupted.

What we actually tend to do in this case is make function A()
uninterruptible at all times (or -- ugh -- pass an extra argument all the
way down telling it which type of sleep to use and not to check
signal_pending()).

My suggested alternative is to have the afore-mentioned'interruptible_count'
in the task struct, and each function that cannot deal with receiving -EINTR
from the other functions it calls shall increase this count accordingly.

So sys_write() would increase current->interruptible_count, and then 
nothing called from there would upset the user by returning -EINTR.

Similarly, down() would just increase the count before calling what's 
currently down_interruptible(), etc.

--
dwmw2



  parent reply	other threads:[~2002-10-17  8:26 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-31 11:52 manipulating sigmask from filesystems and drivers David Howells
2002-07-31 11:58 ` Alan Cox
2002-08-01 19:09 ` Linus Torvalds
2002-08-01 20:10   ` David Woodhouse
2002-08-01 20:21     ` Linus Torvalds
2002-08-01 20:47       ` Roman Zippel
2002-08-01 20:51         ` Linus Torvalds
2002-08-01 21:15           ` Roman Zippel
2002-08-01 21:42             ` Linus Torvalds
2002-08-01 22:29               ` David Woodhouse
2002-08-01 22:40                 ` Linus Torvalds
2002-08-01 22:50                   ` David Woodhouse
2002-08-02 15:59                   ` yodaiken
2002-08-01 22:35               ` Roman Zippel
2002-08-01 23:30                 ` Linus Torvalds
2002-08-02  0:31                   ` Olivier Galibert
2002-08-02  8:00                     ` Kai Henningsen
2002-08-02 10:02                   ` Roman Zippel
2002-08-02 12:38                     ` Ryan Anderson
2002-08-02 15:39                     ` Linus Torvalds
2002-08-02 16:00                       ` Benjamin LaHaise
2002-08-02 16:27                         ` Linus Torvalds
2002-08-02 17:13                           ` Jamie Lokier
2002-08-02 17:29                             ` Linus Torvalds
2002-08-02 17:57                               ` Trond Myklebust
2002-08-02 18:10                                 ` Linus Torvalds
2002-08-02 17:33                           ` Oliver Neukum
2002-08-03 18:27                             ` David Woodhouse
2002-10-17  8:32                           ` David Woodhouse [this message]
2002-08-02 19:27                       ` Roman Zippel
2002-08-02  7:31                 ` Giuliano Pochini
     [not found]   ` <mailman.1028232841.11555.linux-kernel2news@redhat.com>
2002-08-01 23:37     ` Pete Zaitcev
2002-08-01 23:46       ` David Woodhouse
     [not found] <0C01A29FBAE24448A792F5C68F5EA47D2D3E2B@nasdaq.ms.ensim.com>
2002-08-02 17:57 ` Paul Menage
2002-08-02 23:25   ` Ryan Anderson
2002-08-02 23:30     ` Paul Menage
  -- strict thread matches above, loose matches on Subject: below --
2002-08-02 18:24 Jesse Pollard

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=22897.1034843545@passion.cambridge.redhat.com \
    --to=dwmw2@infradead.org \
    --cc=alan@redhat.com \
    --cc=bcrl@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    --cc=zippel@linux-m68k.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