mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: kosaki.motohiro@jp.fujitsu.com, linux-kernel@vger.kernel.org
Subject: Re: Q: semaphore and kmalloc(GFP_KERNEL)?
Date: Mon, 11 May 2009 11:56:02 +0900 (JST)	[thread overview]
Message-ID: <20090511115410.B0EA.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <200905110230.n4B2UUXk082125@www262.sakura.ne.jp>

> Hello.
> I got a question.
> 
> When we use kmalloc(GFP_KERNEL), we cannot use spinlock.
> We use semaphore instead.
> 
> What happens if a writer process got into sleep state at kmalloc()
> without releasing a rw_semaphore for writing,
> 
>     down_write(&sem);
>     list_for_each()
>         ...;
>     ptr = kmalloc(size, GFP_KERNEL);
>     list_add();
>     up_write(&sem);
> 
> and then reader processes tried to hold that rw_semaphore?
> 
>     down_read(&sem);
>     list_for_each()
>         ...;
>     up_read(&sem);
> 
> Can the kernel detect that we need to let kmalloc() fail and
> wake up the writer process so that the writer process releases
> the rw_semaphore and reader processes can continue?

it can't. Plus it shouldn't.
some caller don't want kmalloc() failure.


> (If the kernel can't detect, I worry that we experience
> all processes sleeping for undefined duration.)





  reply	other threads:[~2009-05-11  2:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-11  2:30 Tetsuo Handa
2009-05-11  2:56 ` KOSAKI Motohiro [this message]
2009-05-11  3:19   ` Tetsuo Handa
2009-05-11  3:21     ` KOSAKI Motohiro
2009-05-11  3:26       ` Tetsuo Handa

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=20090511115410.B0EA.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /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®