lkml.org 
[lkml]   [2009]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/5] TOMOYO: Clarify lock protected section.
From
Date
Serge E. Hallyn wrote:
> Again I feel (no offense) like I'm reading Ada code here...
I don't know much about the Linux kernel's way of coding.
I'm making a lot of out-of-conventional coding.
Please mention without hesitating.

> 1. the mutex lock belonging to this function really is just protecting
> writes to elements of tomoyo_profile_ptr. It should be defined,
> with a descriptive name and comment, next to tomoyo_profile_ptr
> at common.c:46.

(1) Declare a variable and a lock for that variable together.

I've heard (1) in the past.

On the other hand, I think there is another rule

(2) Declare variables inside a function if they are used only within
that function.

If I bring the declaration of the lock to outside the function, it widens
the scope of the lock.

But Linux kernel's way is to follow (1), isn't it?

> 2. I see no reason for this not to be a fast spinlock at this
> point.

I'm thinking that
(1) If I use mutex and rw_semaphore, the CPU which is waiting for the lock
can spend it's power for doing other process's jobs.
(2) If I use spinlock, the CPU's power is merely wasted, even though
the CPU can spend it's power for doing other process's jobs.
and therefore I'm using mutex and rw_semaphore if sleeping is permitted.

Should I use spinlock rather than mutex and rw_semaphore whenever possible?

> 3. Once it's a fast checkpoint, you can change the flow a bit
> (unless there is good reason not to) to do:
Indeed.

Thanks.


\
 
 \ /
  Last update: 2009-06-02 05:45    [W:0.074 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site