Skip to contentSkip to conversation

trace: module: Maintain a valid user count

PATCH Superseded Romain Izard 3 participants 8 messages Mar 3, 2014 – May 8, 2014 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace: module: Maintain a valid user count

The replacement of the 'count' variable by two variables 'incs' and 'decs' to resolve some race conditions during module unloading was done in parallel with some cleanup in the trace subsystem, and was integrated as a merge.

Unfortunately, the formula for this replacement was wrong in the tracing code, and the refcount in the traces was not usable as a result.

Use 'count = incs - decs' to compute the user count.

---
 include/trace/events/module.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/trace/events/module.h +2 -1
index 161932737416..1228d963b6d1 100644
@@ -78,7 +78,8 @@ DECLARE_EVENT_CLASS(module_refcnt,
 
 	TP_fast_assign(
 		__entry->ip	= ip;
-		__entry->refcnt	= __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs);
+		__entry->refcnt	= __this_cpu_read(mod->refptr->incs) -
+			__this_cpu_read(mod->refptr->decs);
 		__assign_str(name, mod->name);
 	),
 
Signature · 1 line
1.8.3.2
maintainer
#1 lore raw
Quoted 20 lines · On Mon, 3 Mar 2014 19:17:32 +0100 Romain Izard <[email protected]>…

The replacement of the 'count' variable by two variables 'incs' and 'decs' to resolve some race conditions during module unloading was done in parallel with some cleanup in the trace subsystem, and was integrated as a merge.

Unfortunately, the formula for this replacement was wrong in the tracing code, and the refcount in the traces was not usable as a result.

Use 'count = incs - decs' to compute the user count.

---
 include/trace/events/module.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/trace/events/module.h +0 -0
index 161932737416..1228d963b6d1 100644

include/trace/events/module.h DECLARE_EVENT_CLASS(module_refcnt, · line 82

Quoted 6 lines
include/trace/events/module.h +2 -1
@@ -78,7 +78,8 @@ DECLARE_EVENT_CLASS(module_refcnt,
 
 	TP_fast_assign(
 		__entry->ip	= ip;
-		__entry->refcnt	= __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs);
+		__entry->refcnt	= __this_cpu_read(mod->refptr->incs) -
+			__this_cpu_read(mod->refptr->decs);

I know this breaks the 80 column rule, but please keep it on one line. Look at the above. The line you are removing is much easier to read than the one you replaced it with.

Or if it is too big, what about:

		__entry->refcnt	=
		  __this_cpu_read(mod->refptr->incs) - __this_cpu_read(mod->refptr->decs);

Thanks,

-- Steve

Quoted 3 lines
include/trace/events/module.h +0 -0
 		__assign_str(name, mod->name);
 	),
 
#2 lore raw

PATCH v2 1/1 trace: module: Maintain a valid user count

The replacement of the 'count' variable by two variables 'incs' and 'decs' to resolve some race conditions during module unloading was done in parallel with some cleanup in the trace subsystem, and was integrated as a merge.

Unfortunately, the formula for this replacement was wrong in the tracing code, and the refcount in the traces was not usable as a result.

Use 'count = incs - decs' to compute the user count.

---
 include/trace/events/module.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/module.h +1 -1
index 161932737416..ca298c7157ae 100644
@@ -78,7 +78,7 @@ DECLARE_EVENT_CLASS(module_refcnt,
 
 	TP_fast_assign(
 		__entry->ip	= ip;
-		__entry->refcnt	= __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs);
+		__entry->refcnt	= __this_cpu_read(mod->refptr->incs) - __this_cpu_read(mod->refptr->decs);
 		__assign_str(name, mod->name);
 	),
 
Signature · 1 line
1.8.3.2
maintainer Reviewed-by on v2 1/1
#3 lore raw

Ingo,

You want to push this to Linus?

-- Steve

Quoted 28 lines · On Tue, 4 Mar 2014 10:09:39 +0100 Romain Izard <[email protected]>…

The replacement of the 'count' variable by two variables 'incs' and 'decs' to resolve some race conditions during module unloading was done in parallel with some cleanup in the trace subsystem, and was integrated as a merge.

Unfortunately, the formula for this replacement was wrong in the tracing code, and the refcount in the traces was not usable as a result.

Use 'count = incs - decs' to compute the user count.

---
 include/trace/events/module.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/module.h +1 -1
index 161932737416..ca298c7157ae 100644
@@ -78,7 +78,7 @@ DECLARE_EVENT_CLASS(module_refcnt,
 
 	TP_fast_assign(
 		__entry->ip	= ip;
-		__entry->refcnt	= __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs);
+		__entry->refcnt	= __this_cpu_read(mod->refptr->incs) - __this_cpu_read(mod->refptr->decs);
 		__assign_str(name, mod->name);
 	),
 
#4 lore raw

2014-03-06 18:34 GMT+01:00 Steven Rostedt <[email protected]>:

Quoted 33 lines

Ingo,

You want to push this to Linus?

-- Steve

Quoted 21 lines · On Tue, 4 Mar 2014 10:09:39 +0100 Romain Izard <[email protected]>…

The replacement of the 'count' variable by two variables 'incs' and 'decs' to resolve some race conditions during module unloading was done in parallel with some cleanup in the trace subsystem, and was integrated as a merge.

Unfortunately, the formula for this replacement was wrong in the tracing code, and the refcount in the traces was not usable as a result.

Use 'count = incs - decs' to compute the user count.

---
 include/trace/events/module.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/module.h +0 -0
index 161932737416..ca298c7157ae 100644
@@ -78,7 +78,7 @@ DECLARE_EVENT_CLASS(module_refcnt,
 
Quoted 8 lines

include/trace/events/module.h DECLARE_EVENT_CLASS(module_refcnt, · line 84

Quoted 7 lines
include/trace/events/module.h +1 -1
      TP_fast_assign(
              __entry->ip     = ip;
-             __entry->refcnt = __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs);
+             __entry->refcnt = __this_cpu_read(mod->refptr->incs) - __this_cpu_read(mod->refptr->decs);
              __assign_str(name, mod->name);
      ),
 

Ping ?

maintainer
#6 lore raw
Quoted 12 lines · On Wed, 7 May 2014 21:23:36 +0200 Ingo Molnar <[email protected]> wrote:
Quoted 5 lines · Steven Rostedt

Ingo,

You want to push this to Linus?

I think it would be more natural through the tracing tree, through which most tracepoint fixes go, agreed?

Hmm, yeah. Not sure why I pushed it off to you :-/

Looks like this should be marked as stable and incorporated in 3.15 as well.

Thanks,

-- Steve

Acked-by
#7 lore raw
Quoted 10 lines · Steven Rostedt
Quoted 7 lines · On Wed, 7 May 2014 21:23:36 +0200 Ingo Molnar <[email protected]> wrote:
Quoted 4 lines · Steven Rostedt

Ingo,

You want to push this to Linus?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I think it would be more natural through the tracing tree, through which most tracepoint fixes go, agreed?

Hmm, yeah. Not sure why I pushed it off to you :-/

To check whether I'm awake, I'm sure!

Quoted 2 lines

Looks like this should be marked as stable and incorporated in 3.15 as well.

Yeah.

Thanks,

Ingo