Messages in this thread | | | Subject | Re: [PATCH 0/3] v4 Improve task->comm locking situation | From | Tetsuo Handa <> | Date | Wed, 18 May 2011 12:16:06 +0900 |
| |
What about replacing char comm[TASK_COMM_LEN]; with char *rcu_commname; and switching it atomically using RCU?
Advantages: Readers can use RCU read lock rather than spinlock. Makes task_struct smaller.
Disadvantages: Need to allocate TASK_COMM_LEN bytes upon dup_task_struct() and set_task_comm(). Need to rewrite all task_struct.comm readers (steps shown below).
Steps to rewrite task_struct.comm readers
(1) Introduce a temporary accessor (say, task_comm).
#define task_comm(tsk) (tsk)->comm
(2) Rewrite all tsk->comm users to task_comm(tsk).
(3) Replace sizeof(tsk->comm) with TASK_COMM_LEN.
(4) Temporarily rename from
char comm[TASK_COMM_LEN];
to
char comm_access_me_via_task_comm[TASK_COMM_LEN];
for blocking new tsk->comm users.
(5) Convert to use RCU.
(6) Rename from
char comm_access_me_via_task_comm[TASK_COMM_LEN];
to
char *rcu_commname;
.
(7) Rewrite task_comm(tsk) to use %ptc .
(8) Remove the temporary accessor.
| |