From: Andrew Morton <akpm@linux-foundation.org>
To: Arjan van de Ven <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org
Subject: Re: [PATCH 1/7] async: Asynchronous function calls to speed up kernel boot
Date: Fri, 13 Feb 2009 23:29:26 -0800 [thread overview]
Message-ID: <20090213232926.924d8740.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090213205949.1ebb441d@infradead.org>
On Fri, 13 Feb 2009 20:59:49 -0800 Arjan van de Ven <arjan@infradead.org> wrote:
> On Fri, 13 Feb 2009 16:22:00 -0800
> Andrew Morton <akpm@linux-foundation.org> wrote:
>
> > It means that sometimes, very rarely, the callback function will be
> > called within the caller's context.
>
> for the cases that use it right now it is ok.
That doesn't mean it's any good! There are only two callsites.
Plus there's the issue which I mentioned: if someone _does_ call this
from atomic context they'll only find out about their bug when the
GFP_ATOMIC allocation fails. This is bad!
> >
> > Hence this interface cannot be used to call might-sleep functions from
> > within atomic contexts. Which should be a major application of this
> > code!
>
> That is not what this was originally designed for. The original design
> goal was to offload existing function calls out of the synchronous
> execution path.
I'm desperately trying to avoid us ending up with multiple
different-but-similar thread pool implementations. It's really quite
important that the one which got there first (actually, it's
approximately our fourth) be usable in place of Evgeniy's one and
dhowells' one.
> Now I understand that it would be nice to do what you propose, but it
> needs a little different interface for that; specifically, the caller
> will need to pass in the memory for the administration.
yep. And we should change the existing interface to take an additional
gfp_t argument. Because it's silly doing an unreliable GFP_ATOMIC when
the caller's context doesn't require that.
As for the fallback-to-synchronous-panics-the-kernel trap: I don't know
how we can save people from falling into that one.
>
> >
> > Furthermore:
> >
> > - If the callback function can sleep then the caller must be able to
> > sleep, so the GFP_ATOMIC is unneeded and undesirable, and the
> > comment is wrong.
>
> And if the callback function does not sleep it can be used in atomic
> context just fine. Hence the GFP_ATOMIC.
> .
>
> >
> > I can't immediately think of a fix, apart from overhauling the
> > implementation and doing it in the proper way: caller-provided storage
> > rather than callee-provided (which always goes wrong).
> > schedule_work() got this right.
>
> schedule_work() got it part right. Pushing the administration to the
> caller means the caller needs to allocate the memory or use static
> memory and then make sure it doesn't get reused for a 2nd piece of work.
> (schedule_work doesn't care, it will just execute it once in that case.
> Here we do absolutely care).
Caller needs to allocate storage for each invocation - that's fine.
It would be sensible for the code to be able to detect when the caller
tries to use the same storage concurrently, and go BUG.
> The caller only rarely can deal better with the memory allocation and
> lifetime rules than the implementation can.
Nonsense. The caller *always* knows better. That's a core design
decision in Linux and we relearn it over and over again. Examples
are the radix-tree code, where we went to exorbitant lengths to make
callee-allocation reliable, and the IDR code, which completely sucks.
> In fact, for the scenario of
> "I want to take this bit of code out of the synchronous path
> normally".. it is just fine and most easy this way; moving this to the
> caller just makes things more fragile.
The code now is fragile. Requiring caller-provided storage and adding
debugging to detect when the caller screws up is solid as a rock.
> So yes based on the discussions on lkml in the last week I was going to
> add an interface where you can pass in your own memory, but I want to
> get the interface right such that it is low complexity for the caller,
> and really hard to get wrong.. and that does involve dealing with the
> "how to do static allocation while doing multiple parallel calls"
> problem.
An alternative is to keep doing the allocation in the callee, add a
gfp_t argument and require that callers be able to handle the resulting
-ENOMEM.
But this is bad because the caller's -ENOMEM handling will remain
basically untested.
next prev parent reply other threads:[~2009-02-14 7:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-07 23:11 [PATCH 0/7] V3 of the async function call patches Arjan van de Ven
2009-01-07 23:12 ` [PATCH 1/7] async: Asynchronous function calls to speed up kernel boot Arjan van de Ven
2009-01-08 0:31 ` Arnaldo Carvalho de Melo
2009-01-08 1:17 ` Arjan van de Ven
2009-01-13 20:48 ` Jonathan Corbet
2009-01-14 11:34 ` Cornelia Huck
2009-02-14 0:22 ` Andrew Morton
2009-02-14 4:59 ` Arjan van de Ven
2009-02-14 7:29 ` Andrew Morton [this message]
2009-02-15 19:16 ` Arjan van de Ven
2009-02-15 22:19 ` Arjan van de Ven
2009-02-16 10:31 ` Cornelia Huck
2009-01-07 23:12 ` [PATCH 2/7] fastboot: make scsi probes asynchronous Arjan van de Ven
2009-01-07 23:13 ` [PATCH 3/7] fastboot: make the libata port scan asynchronous Arjan van de Ven
2009-01-07 23:13 ` [PATCH 4/7] fastboot: Make libata initialization even more async Arjan van de Ven
2009-01-07 23:14 ` [PATCH 5/7] async: make the final inode deletion an asynchronous event Arjan van de Ven
2009-01-07 23:14 ` [PATCH 6/7] bootchart: improve output based on Dave Jones' feedback Arjan van de Ven
2009-01-07 23:15 ` [PATCH 7/7] async: don't do the initcall stuff post boot Arjan van de Ven
2009-01-08 0:17 ` [PATCH 0/7] V3 of the async function call patches Linus Torvalds
2009-01-08 1:21 ` Arjan van de Ven
2009-01-15 8:10 ` Pavel Machek
2009-01-09 20:21 ` Ryan Hope
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=20090213232926.924d8740.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.