[PATCH 06/19] tracing/workqueue: turn cpu_workqueue_stats::inserted into unsigned int

From: Frederic Weisbecker
Date: Wed Apr 29 2009 - 20:29:35 EST


struct cpu_workqueue_stats used an atomic_t to protect against
concurrent incrementation of inserted worklets. But
trace_workqueue_insertion() is already inside a section protected
by the cpu workqueue lock.

Then we can safely convert it into an unsigned int.

[ Impact: cleanup ]

Reported-by: Oleg Nesterov <oleg@xxxxxxxxxx>
Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Zhao Lei <zhaolei@xxxxxxxxxxxxxx>
Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Tom Zanussi <tzanussi@xxxxxxxxx>
Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---
kernel/trace/trace_workqueue.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
index 1a68b5a..7c632b9 100644
--- a/kernel/trace/trace_workqueue.c
+++ b/kernel/trace/trace_workqueue.c
@@ -20,7 +20,7 @@ struct workfunc_stats {

/* Addr of worklet's callback function */
work_func_t func;
- /* Can be inserted from interrupt or user context, need to be atomic */
+ /* Can be inserted on different workqueues, need to be atomic */
atomic_t inserted;
/*
* Don't need to be atomic, works are serialized in a single workqueue
@@ -34,8 +34,8 @@ struct cpu_workqueue_stats {
struct list_head list;
int cpu;
pid_t pid;
- /* Refer to comments of struct workfunc_stats for detail */
- atomic_t inserted;
+ /* Protected by cpu workqueue lock */
+ unsigned int inserted;
unsigned int executed;
/* list of struct workfunc_stats in this workqueue */
struct list_head workfunclist;
@@ -62,7 +62,7 @@ int do_workqueue_insertion(struct cpu_workqueue_stats *cws,
{
struct workfunc_stats *wfstat;

- atomic_inc(&cws->inserted);
+ cws->inserted++;

list_for_each_entry(wfstat, &cws->workfunclist, list)
if (wfstat->func == work->func)
@@ -311,7 +311,7 @@ static int workqueue_stat_show(struct seq_file *s, void *p)
if (tsk) {
seq_printf(s, "%3d %6d %6u %s:%d\n",
cws->cpu,
- atomic_read(&cws->inserted),
+ cws->inserted,
cws->executed,
tsk->comm,
cws->pid);
--
1.6.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/