lkml.org 
[lkml]   [2009]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Q: semaphore and kmalloc(GFP_KERNEL)?
Date
> 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.)






\
 
 \ /
  Last update: 2009-05-11 04:59    [W:0.041 / U:1.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site