[lkml]   [2002]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: programming for preemption (was: [PATCH] 2.5.46: accesspermission filesystem)
Olaf Dietsche wrote:
> Andrew Morton <> writes:
> > Olaf Dietsche wrote:
> >>
> >> Ben Clifford <> writes:
> >>
> >> > I still get those stack traces, though...
> >>
> >> I retested with CONFIG_PREEMPT=y and now I get those stack traces,
> >> too. So, it seems my code is not preempt safe.
> >>
> >
> > It's not that your code is unsafe with preemption. It's just that
> > CONFIG_PREEMPT=y turns on the debugging infrastructure which allows
> > us to detect things like calling kmalloc(GFP_KERNEL) inside spinlock.
> Thanks for this hint. So this means kmalloc(GFP_KERNEL) inside
> spinlock is not necessarily dangerous, but should be avoided if
> possible?

It can lock an SMP kernel up. This CPU can switch to another task in the
page allocator and then, within the context of the new task, come around
and try to take the same lock.

> Is using a semaphore better than using spinlocks?

A semaphore won't have that problem. If your CPU comes around again onto
the already-held lock it will just switch to another task.

> Is
> there a list of dos and don'ts for preempt kernels beside
> Documentation/preempt-locking.txt?

Not that I'm aware of. (This is not preempt-related though. Generally,
correct SMP coding is correct preempt coding)

> And btw, who is "us"?

It is a broad term for "those who code on the kernel".
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:30    [W:1.088 / U:0.008 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site