From: "Ricardo M. Correia" <ricardo.correia@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Brian Behlendorf <behlendorf1@llnl.gov>,
Andreas Dilger <andreas.dilger@oracle.com>
Subject: Re: Propagating GFP_NOFS inside __vmalloc()
Date: Thu, 11 Nov 2010 23:45:58 +0100 [thread overview]
Message-ID: <1289515558.428.125.camel@oralap> (raw)
In-Reply-To: <20101111142511.c98c3808.akpm@linux-foundation.org>
On Thu, 2010-11-11 at 14:25 -0800, Andrew Morton wrote:
> And then we can set current->gfp_mask to GFP_ATOMIC when we take an
> interrupt, or take a spinlock.
>
> And leave it at GFP_KERNEL when in process context.
>
> And switch GFP_KERNEL to GFP_NOFS in the VM.
>
> And switch to GFP_NOIO in the block layer.
>
> So the allocation mode becomes implicit to the task state, so callers
> usually don't need to track it.
>
> So, ultimately, kmalloc(), alloc_pages() etc don't actually need a mode
> arg at all. We'll need new, special functions which _do_ take the
> gfp_t but they will be rarely-called specialised things.
>
> And probably we'll need interfaces like
>
> gfp_t mm_set_alloc_mode(gfp_t flags);
> void mm_restore_alloc_mode(gfp_t flags);
>
> gfp_t flags;
>
> flags = mm_set_alloc_mode(GFP_NOIO);
> ...
> mm_restore_alloc_mode(flags);
Actually, I think it may not be that simple...
Looking at some of the __GFP_* flags, it seems that some of them look
like allocation "options", i.e. something we may want or may not want to
do on a certain allocation, others look more like "capabilities", i.e.
something that we can or cannot do in a certain context.
For example, __GFP_ZERO, __GFP_REPEAT, __GFP_HIGHMEM, ... is something
that we'd probably want a caller to specify on each allocation, because
only he knows what he actually wants to do.
Others, like __GFP_FS, __GFP_IO, __GFP_WAIT, are things that we either
can or cannot do, depending on the context that we're in.
The latter ones seem worth to start tracking on the task_struct, but the
former ones I think we'd still want to pass them to kmalloc() on each
invocation.
Fortunately, if we put the latter ones in the task_struct, it removes
the need for having to propagate gfp_flags from function to function.
And contrary to what you said previously (which at the time sounded
correct to me), this can actually save a lot of stack space, especially
on more register-starved architectures, because the only places where we
need to save the flags on the stack is when we enter/exit a certain
context, as opposed to having to always having to pass the gfp_mask down
the call stack like we do now.
> argh, someone save us.
:-)
Thanks,
Ricardo
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2010-11-11 22:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 20:42 Propagating GFP_NOFS inside __vmalloc() Ricardo M. Correia
2010-11-10 21:35 ` Ricardo M. Correia
2010-11-10 22:10 ` Dave Chinner
2010-11-11 20:06 ` Andrew Morton
2010-11-11 22:02 ` Ricardo M. Correia
2010-11-11 22:25 ` Andrew Morton
2010-11-11 22:45 ` Ricardo M. Correia [this message]
2010-11-11 23:19 ` Ricardo M. Correia
2010-11-11 23:27 ` Andrew Morton
2010-11-11 23:29 ` Ricardo M. Correia
2010-11-15 17:01 ` Ricardo M. Correia
2010-11-15 21:28 ` David Rientjes
2010-11-15 22:19 ` Ricardo M. Correia
2010-11-15 22:50 ` David Rientjes
2010-11-15 23:30 ` Ricardo M. Correia
2010-11-15 23:55 ` David Rientjes
2010-11-16 22:11 ` Andrew Morton
2010-11-17 7:18 ` Andreas Dilger
2010-11-17 7:24 ` Andrew Morton
2010-11-17 7:37 ` David Rientjes
2010-11-17 9:04 ` Christoph Hellwig
2010-11-17 21:24 ` David Rientjes
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=1289515558.428.125.camel@oralap \
--to=ricardo.correia@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=andreas.dilger@oracle.com \
--cc=behlendorf1@llnl.gov \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).