mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: "Roland McGrath" <roland@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	"Elias Oltmanns" <eo@nebensachen.de>,
	"Török Edwin" <edwintorok@gmail.com>,
	"Arjan van de Ven" <arjan@infradead.org>
Subject: Re: [PATCH] x86_64: fix delayed signals
Date: Fri, 11 Jul 2008 10:58:54 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0807111031310.2936@woody.linux-foundation.org> (raw)
In-Reply-To: <20080711054605.GA17851@elte.hu>



On Fri, 11 Jul 2008, Ingo Molnar wrote:
> 
> nice find! Roland, is this related to the thread started by Elias 
> Oltmanns yesterday:
> 
>     http://lkml.org/lkml/2008/7/10/57

No.

First off, the delayed sending of signals isn't actually delayed that 
much. It's the next kernel entry at the most - certainly *not* across 
scheduling points, which the fact that ^Z shows up in the xterm says 
happen.

Secondly, it seems to happen on x86-32 too, and it is claimed to be a 
regression. Neither of which would be true for this case.

Thirdly, there seems to be no other signals involved (ie it's a single 
signal).

I think the IO interactivity report is simply because of IO scheduling 
and/or paging out the shell too aggressively. No signals will be delivered 
while the process in in 'D' state (the new 'killable' thing being an 
exception in _some_ cases, but that's literally just for killing signals, 
not backgrounding).

So to look at the original report:

 "By sprinkling some printk()s all over the place, I've managed to
  establish the following sequence of events taking place in the event of
  delayed signal handling as described above:
  The first Ctrl+Z event enqueues a SIGTSTP signal which eventually
  results in a call to kick_process(). For some reason though, the signal
  isn't handled straight away but remains on the queue for some time."

the thing is, kick_process() only helps if the other thread is _running_ 
on the other CPU. If it's actively waiting for disk, it's a no-op: the 
signal handling code expects that the scheduler will either wake it up in 
"wake_up_state()" (which won't happen if it is in 'D' state, of course!) 
or that the process will just handle it in its own time when it wakes up 
when IO completes.

So if things have gotten worse latency, it's most likely simply because 
our IO has worse latency - probably because of having more requests 
outstanding, or because of unlucky/bad IO scheduler behaviour. The first 
thing to do (because it's fairly easy) is to start off testing different 
IO schedulers, but also see if there are some cases where we should try to 
return early.

In the particular case of Edwin Török, his latency problem seems to b with 
"find". That's interesting, because it's one of the cases where we *could* 
easily improve on latency, by making "readdir()" return early both for 
killable signals, but also for regular signals when we've filled the 
buffer partially (because unlike a "read()" system call, we don't promise 
to fill the whole buffer _anyway_).

It may be, for example, that the increased latency isn't actually because 
the *kernel* has increased latencies at all, but perhaps 'find' uses a 
much bigger buffer for it's readdir() code? Anyway, _if_ it's readdir() 
that has high latency, the appended patch might make a difference. I think 
it's probably a good idea regardless..

But it would be really good to have the thing bisected regardless of what 
it is.

			Linus

---

This makes 'readdir()' return early if it has a signal pending and it has 
filled at least one entry (the -EINTR will never be passed on to user 
space: the readdir() system call will return the length of the filled-in 
buffer)

 fs/readdir.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/fs/readdir.c b/fs/readdir.c
index 4e026e5..ec8c192 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -159,6 +159,9 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 		return -EOVERFLOW;
 	dirent = buf->previous;
 	if (dirent) {
+		/* Only check signals if we have filled at least one entry! */
+		if (signal_pending(current))
+			return -EINTR;
 		if (__put_user(offset, &dirent->d_off))
 			goto efault;
 	}
@@ -241,6 +244,9 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
 		return -EINVAL;
 	dirent = buf->previous;
 	if (dirent) {
+		/* Only check signals if we have filled at least one entry! */
+		if (signal_pending(current))
+			return -EINTR;
 		if (__put_user(offset, &dirent->d_off))
 			goto efault;
 	}

  parent reply	other threads:[~2008-07-11 18:01 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-10 21:50 Roland McGrath
2008-07-10 22:06 ` Linus Torvalds
2008-07-10 22:42   ` Roland McGrath
2008-07-10 22:51     ` Linus Torvalds
2008-07-10 23:02       ` Linus Torvalds
2008-07-11  0:52       ` Roland McGrath
2008-07-11  1:18         ` Linus Torvalds
2008-07-11  1:27           ` Roland McGrath
2008-07-11  1:48         ` Linus Torvalds
2008-07-11  2:02           ` Linus Torvalds
2008-07-11  2:22             ` Linus Torvalds
2008-07-11  2:26               ` Linus Torvalds
2008-07-12 12:24             ` Andi Kleen
2008-07-11  5:46 ` Ingo Molnar
2008-07-11 11:13   ` Török Edwin
2008-07-11 12:24   ` Elias Oltmanns
2008-07-11 17:58   ` Linus Torvalds [this message]
2008-07-11 18:07     ` Roland McGrath
2008-07-11 18:16       ` Linus Torvalds
2008-07-11 18:17         ` Linus Torvalds
2008-07-11 18:10     ` Linus Torvalds
2008-07-11 18:31       ` Linus Torvalds
2008-07-11 22:53         ` Arjan van de Ven
2008-07-12 10:33           ` Török Edwin
2008-07-11 20:37       ` Linus Torvalds
2008-07-11 23:22         ` Linus Torvalds
2008-07-12 10:32           ` Török Edwin
2008-07-12 13:42             ` Török Edwin
2008-07-12 14:55               ` Arjan van de Ven
2008-07-12 18:00                 ` Linus Torvalds
2008-07-12 18:15                   ` Arjan van de Ven
2008-07-12 18:28                     ` Linus Torvalds
2008-07-12 17:29             ` Linus Torvalds
2008-07-12 20:26               ` Török Edwin
2008-07-12 20:47                 ` Linus Torvalds
2008-07-12 20:57                 ` Denys Vlasenko
2008-07-13 10:46                   ` Oleg Nesterov
2008-07-13 12:34                     ` Denys Vlasenko
2008-07-13 18:36                     ` Linus Torvalds
2008-07-13 18:45                       ` Peter T. Breuer
2008-07-12 12:27     ` Andi Kleen
2008-07-12 17:41       ` Linus Torvalds
2008-07-13  9:38         ` Andi Kleen
2008-07-13 17:32           ` Linus Torvalds
2008-07-13 18:59             ` Andi Kleen
2008-07-13 19:08               ` Linus Torvalds

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=alpine.LFD.1.10.0807111031310.2936@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=edwintorok@gmail.com \
    --cc=eo@nebensachen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®