[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200906020342.n523gjWf029800@www262.sakura.ne.jp>
Date: Tue, 02 Jun 2009 12:42:45 +0900
From: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>
To: serge@...lyn.com
Cc: lizf@...fujitsu.com, linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/5] TOMOYO: Clarify lock protected section.
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists