提交 05725f7e 编写于 作者: J Jiri Pirko 提交者: Ingo Molnar

rculist: use list_entry_rcu in places where it's appropriate

Use previously introduced list_entry_rcu instead of an open-coded
list_entry + rcu_dereference combination.
Signed-off-by: NJiri Pirko <jpirko@redhat.com>
Reviewed-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: dipankar@in.ibm.com
LKML-Reference: <20090414181715.GA3634@psychotron.englab.brq.redhat.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 72c6a987
...@@ -77,6 +77,7 @@ struct sched_param { ...@@ -77,6 +77,7 @@ struct sched_param {
#include <linux/proportions.h> #include <linux/proportions.h>
#include <linux/seccomp.h> #include <linux/seccomp.h>
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
#include <linux/rculist.h>
#include <linux/rtmutex.h> #include <linux/rtmutex.h>
#include <linux/time.h> #include <linux/time.h>
...@@ -2010,7 +2011,8 @@ static inline unsigned long wait_task_inactive(struct task_struct *p, ...@@ -2010,7 +2011,8 @@ static inline unsigned long wait_task_inactive(struct task_struct *p,
} }
#endif #endif
#define next_task(p) list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks) #define next_task(p) \
list_entry_rcu((p)->tasks.next, struct task_struct, tasks)
#define for_each_process(p) \ #define for_each_process(p) \
for (p = &init_task ; (p = next_task(p)) != &init_task ; ) for (p = &init_task ; (p = next_task(p)) != &init_task ; )
...@@ -2049,8 +2051,8 @@ int same_thread_group(struct task_struct *p1, struct task_struct *p2) ...@@ -2049,8 +2051,8 @@ int same_thread_group(struct task_struct *p1, struct task_struct *p2)
static inline struct task_struct *next_thread(const struct task_struct *p) static inline struct task_struct *next_thread(const struct task_struct *p)
{ {
return list_entry(rcu_dereference(p->thread_group.next), return list_entry_rcu(p->thread_group.next,
struct task_struct, thread_group); struct task_struct, thread_group);
} }
static inline int thread_group_empty(struct task_struct *p) static inline int thread_group_empty(struct task_struct *p)
......
...@@ -1290,8 +1290,8 @@ void exit_sem(struct task_struct *tsk) ...@@ -1290,8 +1290,8 @@ void exit_sem(struct task_struct *tsk)
int i; int i;
rcu_read_lock(); rcu_read_lock();
un = list_entry(rcu_dereference(ulp->list_proc.next), un = list_entry_rcu(ulp->list_proc.next,
struct sem_undo, list_proc); struct sem_undo, list_proc);
if (&un->list_proc == &ulp->list_proc) if (&un->list_proc == &ulp->list_proc)
semid = -1; semid = -1;
else else
......
...@@ -84,8 +84,8 @@ static void *ima_measurements_next(struct seq_file *m, void *v, loff_t *pos) ...@@ -84,8 +84,8 @@ static void *ima_measurements_next(struct seq_file *m, void *v, loff_t *pos)
* against concurrent list-extension * against concurrent list-extension
*/ */
rcu_read_lock(); rcu_read_lock();
qe = list_entry(rcu_dereference(qe->later.next), qe = list_entry_rcu(qe->later.next,
struct ima_queue_entry, later); struct ima_queue_entry, later);
rcu_read_unlock(); rcu_read_unlock();
(*pos)++; (*pos)++;
......
...@@ -734,8 +734,8 @@ static void smk_netlbladdr_insert(struct smk_netlbladdr *new) ...@@ -734,8 +734,8 @@ static void smk_netlbladdr_insert(struct smk_netlbladdr *new)
return; return;
} }
m = list_entry(rcu_dereference(smk_netlbladdr_list.next), m = list_entry_rcu(smk_netlbladdr_list.next,
struct smk_netlbladdr, list); struct smk_netlbladdr, list);
/* the comparison '>' is a bit hacky, but works */ /* the comparison '>' is a bit hacky, but works */
if (new->smk_mask.s_addr > m->smk_mask.s_addr) { if (new->smk_mask.s_addr > m->smk_mask.s_addr) {
...@@ -748,8 +748,8 @@ static void smk_netlbladdr_insert(struct smk_netlbladdr *new) ...@@ -748,8 +748,8 @@ static void smk_netlbladdr_insert(struct smk_netlbladdr *new)
list_add_rcu(&new->list, &m->list); list_add_rcu(&new->list, &m->list);
return; return;
} }
m_next = list_entry(rcu_dereference(m->list.next), m_next = list_entry_rcu(m->list.next,
struct smk_netlbladdr, list); struct smk_netlbladdr, list);
if (new->smk_mask.s_addr > m_next->smk_mask.s_addr) { if (new->smk_mask.s_addr > m_next->smk_mask.s_addr) {
list_add_rcu(&new->list, &m->list); list_add_rcu(&new->list, &m->list);
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册