2015-05-25 17:45:26

by Kirill Tkhai

[permalink] [raw]
Subject: [PATCH RFC 06/13] core: Add rwlock_t task_list::kin_lock

Add a new primitive for synchronization between relatives.
It will be used in next/further patches.

Signed-off-by: Kirill Tkhai <[email protected]>
---
include/linux/init_task.h | 1 +
include/linux/sched.h | 1 +
kernel/fork.c | 1 +
3 files changed, 3 insertions(+)

diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index bb9b075..919243a 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -218,6 +218,7 @@ extern struct task_group root_task_group;
.parent = &tsk, \
.children = LIST_HEAD_INIT(tsk.children), \
.sibling = LIST_HEAD_INIT(tsk.sibling), \
+ .kin_lock = __RW_LOCK_UNLOCKED(tsk.kin_lock), \
.group_leader = &tsk, \
RCU_POINTER_INITIALIZER(real_cred, &init_cred), \
RCU_POINTER_INITIALIZER(cred, &init_cred), \
diff --git a/include/linux/sched.h b/include/linux/sched.h
index af0eeba..58dc09f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1477,6 +1477,7 @@ struct task_struct {
struct list_head children; /* list of my children */
struct list_head sibling; /* linkage in my parent's children list */
struct task_struct *group_leader; /* threadgroup leader */
+ rwlock_t kin_lock;

/*
* ptraced is the list of tasks this task is using ptrace on.
diff --git a/kernel/fork.c b/kernel/fork.c
index 66e31eb..ee389ba 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1330,6 +1330,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
p->flags |= PF_FORKNOEXEC;
INIT_LIST_HEAD(&p->children);
INIT_LIST_HEAD(&p->sibling);
+ rwlock_init(&p->kin_lock);
rcu_copy_process(p);
p->vfork_done = NULL;
spin_lock_init(&p->alloc_lock);