From: Daniel Phillips <phillips@bonn-fries.net>
To: Robert Love <rml@tech9.net>
Cc: linux-kernel@vger.kernel.org,
Marcelo Tosatti <marcelo@conectiva.com.br>,
Chris Mason <mason@suse.com>
Subject: Re: Feedback on preemptible kernel patch
Date: Sun, 16 Sep 2001 03:28:37 +0200 [thread overview]
Message-ID: <20010916012129Z16244-2758+66@humbolt.nl.linux.org> (raw)
In-Reply-To: <1000581501.32705.46.camel@phantasy>
In-Reply-To: <1000581501.32705.46.camel@phantasy>
On September 15, 2001 09:18 pm, Robert Love wrote:
> On Sun, 2001-09-09 at 23:24, Daniel Phillips wrote:
> > This may not be your fault. It's a GFP_NOFS recursive allocation - this
> > comes either from grow_buffers or ReiserFS, probably the former. In
> > either case, it means we ran completely out of free pages, even though
> > the caller is willing to wait. Hmm. It smells like a loophole in vm
> > scanning.
>
> Hi, Daniel. If you remember, a few users of the preemption patch
> reported instability and/or syslog messages such as:
>
> Sep 9 23:08:02 sjoerd kernel: __alloc_pages: 0-order allocation failed (gfp=0x70/1).
> Sep 9 23:08:02 sjoerd last message repeated 93 times
> Sep 9 23:08:02 sjoerd kernel: cation failed (gfp=0x70/1).
> Sep 9 23:08:02 sjoerd kernel: __alloc_pages: 0-order allocation failed (gfp=0x70/1).
> Sep 9 23:08:02 sjoerd last message repeated 281 times
>
> It now seems that all of them are indeed using ReiserFS. There are no
> other reported problems with the preemption patch, except from those
> users...
>
> I am beginning to muse over the source, looking at when kmalloc is
> called with GFP_NOFS in ReiserFS, and then the path that code takes in
> the VM source.
>
> I assume the kernel VM code has a hole somewhere, and the request is
> falling through? It should wait, even if no pages were free so, right?
>
> Where should I begin looking? How does it relate to ReiserFS?
The only other path that uses NO_FS is grow_buffers. But the page probably
got dirtied in generic_file_write, which already put buffers on it. A NOFS
allocation could also be triggered by Ext2 (and other filesystems) by having
lots of dirty mmaps: when page_launder calls page->writepage then the page
won't have buffers on it. That's probably not what's happening though.
I don't think NOFS is causing the problem by the way, it's just a convenient
marker to recognize where the allocation is coming from.
What happens is, page_launder calls reseiserfs_writepage which for some
reason recursively allocates a page (I don't have time to look for the exact
path - it's probably for the journal - but whoever has the problem can check
it via show_trace). We now are in a recursive allocation situation (with
PF_MEMALLOC) so page_launder doesn't get called and we drop through to get
the "failed" message.
It's not nice for __alloc_pages to fail back to a caller that's willing to
wait. See below for one idea about what to do about it.
> How is preemption related?
I'll speculate: page_launder is now yielding to other tasks when it releases
spinlocks to do a writepage. One of them is likely to come back in and
attempt another allocation while we're at rock bottom.
If that's true then I think we should consider something I've wanted to try:
make callers block on a wait queue in __alloc_pages when memory is really
tight.
Hmm. We could do that just in this specific case of PF_MEMALLOC+GFP_WAIT.
Semaphores work well for this kind of thing, something like:
if (!(current->flags & PF_MEMALLOC)) {
<the existing reclaim/launder logic>
} else
if (gfp_mask & __GFP_WAIT) {
wakeup_kswapd();
atomic_inc(&memwaiters);
down(&memwait);
goto try_again;
}
Then in kswapd:
waiters = atomic_read(&memwaiters);
atomic_sub(waiters, &memwaiters);
while (waiters--)
up(&memwaiter);
when we detect that free memory is restored to something reasonable. This
won't deadlock on memwait because kswapd doesn't use __GFP_WAIT.
We also have to make kswapd count wakeups so we can be sure it doesn't sleep
while somebody is waiting in __alloc_pages. The only way I know to do this
reliably is with another semaphore:
void wakeup_kswapd() {
up(&kswapd_sleep);
}
and kswapd downs that semaphore instead of doing interruptible_sleep_on_timeout.
Additionally, a timer has to up() the semaphore periodically, to recover the
sleep_on_timeout behaviour.
Sound like overkill? The alternative is to let GFP_WAIT allocations fail which
forces users like journalling filesystems to busy wait and load up the runqueue.
Sorry I don't have time to code this just now, but I'd like to give this a try
if the problem's still there next week though. Or if you're in the mood...
--
Daniel
next prev parent reply other threads:[~2001-09-16 1:21 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-20 1:49 Feedback on preemptible kernel patch xfs Gerold Jury
2001-09-15 19:18 ` Feedback on preemptible kernel patch Robert Love
2001-09-16 1:28 ` Daniel Phillips [this message]
2001-09-16 1:54 ` Daniel Phillips
2001-09-18 11:05 ` Feedback on preemptible kernel patch xfs jury gerold
2001-09-18 22:52 ` Robert Love
2001-09-20 0:56 ` Robert Love
2001-09-21 12:29 ` Gerold Jury
2001-09-21 19:50 ` Robert Love
[not found] <Pine.LNX.4.33.0109140838040.21992-100000@sjoerd.sjoerdnet>
2001-09-14 15:04 ` Feedback on preemptible kernel patch Robert Love
2001-09-15 9:44 ` Arjan Filius
2001-09-15 10:38 ` Erik Mouw
2001-09-15 17:57 ` Robert Love
[not found] <200109150444.f8F4iEG19063@zero.tech9.net>
[not found] ` <200109140302.f8E32LG13400@zero.tech9.net>
2001-09-14 4:35 ` Robert Love
2001-09-15 4:25 ` Dieter Nützel
2001-09-15 5:14 ` Robert Love
2001-09-18 4:06 ` Dieter Nützel
2001-09-18 8:35 ` Daniel Phillips
2001-09-18 18:18 ` Roger Larsson
2001-09-18 23:31 ` Robert Love
2001-09-20 6:40 ` Dieter Nützel
2001-09-18 23:31 ` Robert Love
-- strict thread matches above, loose matches on Subject: below --
2001-09-14 2:47 Dieter Nützel
2001-09-11 22:53 Robert Love
2001-09-08 5:22 grue
2001-09-08 5:47 ` Robert Love
2001-09-08 17:33 ` Arjan Filius
2001-09-08 18:22 ` safemode
2001-09-09 4:40 ` Robert Love
2001-09-09 17:09 ` Robert Love
2001-09-09 21:07 ` Arjan Filius
2001-09-09 21:26 ` Robert Love
2001-09-09 21:23 ` Arjan Filius
2001-09-09 21:37 ` Robert Love
2001-09-10 3:24 ` Daniel Phillips
2001-09-10 3:37 ` Jeremy Zawodny
2001-09-10 5:09 ` Robert Love
2001-09-10 18:25 ` Daniel Phillips
2001-09-10 21:29 ` Arjan Filius
2001-09-13 17:27 ` Robert Love
2001-09-14 7:30 ` george anzinger
2001-09-14 15:01 ` Robert Love
2001-09-11 19:47 ` Arjan Filius
2001-09-09 18:57 ` grue
2001-09-09 21:44 ` Robert Love
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=20010916012129Z16244-2758+66@humbolt.nl.linux.org \
--to=phillips@bonn-fries.net \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=mason@suse.com \
--cc=rml@tech9.net \
/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®