public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Américo Wang" <xiyou.wangcong@gmail.com>
To: Frederic Weisbecker <fweisbec@gmail.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 23:58:42 +0800	[thread overview]
Message-ID: <20090512155842.GE30014@hack> (raw)
In-Reply-To: <20090512154456.GC6255@nowhere>

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:
>> From: Ming Lei <tom.leiming@gmail.com>
>> 
>> The async_schedule* may not be called in atomic contexts if out of
>> memory or if there's too much work pending already, because the
>> async function to be called may sleep.
>> 
>> This patch fixes the comment of async_schedule*, and introduces
>> async_schedules*_atomic to allow them called from atomic contexts
>> safely.
>
>
>
>Aah, great. Such helper could easily replace some workqueues
>which receive (in atomic) rare jobs but still need to exist because
>they execute jobs which take too much time to be enqueued in kevents.
>
>A good candidate: kpsmoused!
>
>
> 
>> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
>> ---
>>  include/linux/async.h |    3 ++
>>  kernel/async.c        |   56 ++++++++++++++++++++++++++++++++++++++++++------
>>  2 files changed, 52 insertions(+), 7 deletions(-)
>> 
>> diff --git a/include/linux/async.h b/include/linux/async.h
>> index 68a9530..ede9849 100644
>> --- a/include/linux/async.h
>> +++ b/include/linux/async.h
>> @@ -19,6 +19,9 @@ typedef void (async_func_ptr) (void *data, async_cookie_t cookie);
>>  extern async_cookie_t async_schedule(async_func_ptr *ptr, void *data);
>>  extern async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
>>  					    struct list_head *list);
>> +extern async_cookie_t async_schedule_atomic(async_func_ptr *ptr, void *data);
>> +extern async_cookie_t async_schedule_domain_atomic(async_func_ptr *ptr, \
>
>
>trailing backslash?
>
>
>> +					void *data, struct list_head *list);
>>  extern void async_synchronize_full(void);
>>  extern void async_synchronize_full_domain(struct list_head *list);
>>  extern void async_synchronize_cookie(async_cookie_t cookie);
>> diff --git a/kernel/async.c b/kernel/async.c
>> index 968ef94..6bf565b 100644
>> --- a/kernel/async.c
>> +++ b/kernel/async.c
>> @@ -172,12 +172,13 @@ out:
>>  }
>>  
>>  
>> -static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct list_head *running)
>> +static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, \
>
>
>another one.
>
>
>> +				struct list_head *running, int atomic)
>>  {
>>  	struct async_entry *entry;
>>  	unsigned long flags;
>>  	async_cookie_t newcookie;
>> -	
>> +	int  sync_run = 0;
>>  
>>  	/* allow irq-off callers */
>>  	entry = kzalloc(sizeof(struct async_entry), GFP_ATOMIC);
>> @@ -186,7 +187,9 @@ static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct l
>>  	 * If we're out of memory or if there's too much work
>>  	 * pending already, we execute synchronously.
>>  	 */
>> -	if (!async_enabled || !entry || atomic_read(&entry_count) > MAX_WORK) {
>> +	sync_run = !async_enabled || !entry || \
>> +			atomic_read(&entry_count) > MAX_WORK;


And also this one...

Hey, Ming, none of these are macros... You don't need to add backslash to
join two lines, C compilers can recognize.

-- 
Live like a child, think like the god.
 

  reply	other threads:[~2009-05-12 15:58 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 [this message]
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
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=20090512155842.GE30014@hack \
    --to=xiyou.wangcong@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=fweisbec@gmail.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