public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: tom.leiming@gmail.com, arjan@infradead.org,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH] kernel/async.c:introduce async_schedule*_atomic
Date: Tue, 12 May 2009 18:52:29 +0200	[thread overview]
Message-ID: <20090512165227.GE6255@nowhere> (raw)
In-Reply-To: <20090512183105.09e628f0@gondolin>

On Tue, May 12, 2009 at 06:31:05PM +0200, Cornelia Huck wrote:
> On Tue, 12 May 2009 18:04:35 +0200,
> Frederic Weisbecker <fweisbec@gmail.com> wrote:
> 
> > On Tue, May 12, 2009 at 05:44:58PM +0200, Frederic Weisbecker wrote:
> > > On Tue, May 12, 2009 at 11:13:42PM +0800, tom.leiming@gmail.com wrote:
> > > >   * Returns an async_cookie_t that may be used for checkpointing later.
> > > > - * Note: This function may be called from atomic or non-atomic contexts.
> > > > + * Note:This function may be called from non-atomic contexts,and not
> > > > + * 	called from atomic contexts with safety. Please use
> > > > + * 	async_schedule_atomic in atomic contexts.
> > 
> > 
> > I suggest to add a comment which explains the reason for which it is unsafe
> > to call it in atomic context: because the scheduled work might be synchronously
> > executed.
> > 
> > One could believe this is because async_schedule() internally uses
> > a function which might sleep whereas the actual problem may come
> > from the scheduled function.
> 
> I'm wondering whether this is not mixing two different things up:
> - Making async_schedule_* safe from an atomic context.


It was already safe from atomic context, async_schedule() internals
does not make use of sleeping functions.
So indeed the inatomic suffix is not that much appropriate from
an async internal point in view, it makes sense only from the
caller/callee point of view.

But if we start worrying about the GFP flags used by __async_schedule(),
then yes we are mixing up two things.


> - Disallowing calling the function synchronously if asynchronous
>   scheduling failed.
> 
> Perhaps we want async_schedule_nosync() in addition?



This division would make more sense indeed.

- async_schedule_inatomic() would be nosync() and would use
  GFP_ATOMIC. I guess the case where we want to run
  a job synchronously from atomic in case of async failure is too rare
  (non-existent?).
- async_schedule_nosync() would be only nosync() and would use
  GFP_KERNEL

I'm not sure the second case will ever be used though.

Another alternative would be to define a single async_schedule_nosync()
which also takes a gfp flag.


> > 
> > BTW, now that we have an atomic safe version, may be we could
> > also adapt the kmalloc GFP flags subsequently?
> 
> Yes, that would make sense.


  reply	other threads:[~2009-05-12 16:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-12 15:13 [PATCH] kernel/async.c:introduce async_schedule*_atomic tom.leiming
2009-05-12 15:44 ` Frederic Weisbecker
2009-05-12 15:58   ` Américo Wang
2009-05-13  0:36     ` Ming Lei
2009-05-12 16:04   ` Frederic Weisbecker
2009-05-12 16:31     ` Cornelia Huck
2009-05-12 16:52       ` Frederic Weisbecker [this message]
2009-05-12 17:18         ` Cornelia Huck
2009-05-13  0:28           ` Ming Lei
2009-05-13  1:20             ` Frederic Weisbecker
2009-05-13  7:47               ` Cornelia Huck
2009-05-17 20:59                 ` Arjan van de Ven
2009-05-18 11:29                   ` Cornelia Huck
2009-05-13  3:27           ` Ming Lei
2009-05-13  0:16     ` Ming Lei
2009-05-17 20:26 ` Arjan van de Ven
2009-05-18  1:55   ` Ming Lei
2009-05-18  4:18     ` Arjan van de Ven

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=20090512165227.GE6255@nowhere \
    --to=fweisbec@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=cornelia.huck@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tom.leiming@gmail.com \
    /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