lkml.org 
[lkml]   [1999]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: question: spinlocks and userspace.

On Wed, 10 Nov 1999, Tigran Aivazian wrote:

> walk through some linked list {
> for each element take a bit thereof and append to supplied user buf
> }
>
> If I wished to protect the linked list with a spinlock I need to redesign
> the loop and the only way I can think of is to temporarily store those
> elements in kernel buffer and then copy the lot to userspace. But as the
> size of the acumulated buffers is not known in advance the whole thing is
> not as trivial as it should be.

the problem itself is the nontrivial one. You are trying to take a
spinlock-protected 'snapshot' of an indefinit-length kernel-space object,
and that is a nontrivial concept. The 'easy' solution is to give up
atomicity.

> (in particular, I was thinking about qm_modules() that copies
> module->name to user buffer one at a time and I wanted to protect
> module_list with a rw spinlock, taking read_lock in this case).

do you really need atomicity of the list? There are many places in the
kernel which have a spinlock-protected loop, and once they have the
potential to sleep they drop the lock and restart the loop.
truncate_inode_pages() is one example.

-- mingo


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.354 / U:0.832 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site