Skip to contentSkip to conversation

Relay : fix cpu offline problem

PATCH In review Mathieu Desnoyers 2 participants 3 messages Dec 9, 2008 – Dec 10, 2008 Relay

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Relay : fix cpu offline problem

Here is a fix for how relay handles cpu hotplug in the allocation error path. If a cpu goes down while allocating, it may result in a buffer never being freed.

Lai Jiangshan originally identified this problem in the LTTng fork of relay (ltt-relay-alloc). Here is the fix which applies to the original kernel/relay.c.

CC Lai Jiangshan <[email protected]>
CC Tom Zanussi <[email protected]>
---
 kernel/relay.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/relay.c +3 -4
Index: linux-2.6-lttng/kernel/relay.c
===================================================================
@@ -611,10 +611,9 @@ struct rchan *relay_open(const char *bas
 	return chan;
 
 free_bufs:
-	for_each_online_cpu(i) {
-		if (!chan->buf[i])
-			break;
-		relay_close_buf(chan->buf[i]);
+	for_each_possible_cpu(i) {
+		if (chan->buf[i])
+			relay_close_buf(chan->buf[i]);
 	}
 
 	kref_put(&chan->kref, relay_destroy_channel);
Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#1 lore raw

Hi, Mathieu Desnoyers

I have fixed this problem in mainline.
http://lkml.org/lkml/2008/11/14/74

Lai

Quoted 32 lines · Mathieu Desnoyers

Here is a fix for how relay handles cpu hotplug in the allocation error path. If a cpu goes down while allocating, it may result in a buffer never being freed.

Lai Jiangshan originally identified this problem in the LTTng fork of relay (ltt-relay-alloc). Here is the fix which applies to the original kernel/relay.c.

CC Lai Jiangshan <[email protected]>
CC Tom Zanussi <[email protected]>
---
 kernel/relay.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Index: linux-2.6-lttng/kernel/relay.c
===================================================================

kernel/relay.c +3 -4
@@ -611,10 +611,9 @@ struct rchan *relay_open(const char *bas
 	return chan;
 
 free_bufs:
-	for_each_online_cpu(i) {
-		if (!chan->buf[i])
-			break;
-		relay_close_buf(chan->buf[i]);
+	for_each_possible_cpu(i) {
+		if (chan->buf[i])
+			relay_close_buf(chan->buf[i]);
 	}
 
 	kref_put(&chan->kref, relay_destroy_channel);
#2 lore raw

Ah, great, I did not see it passing by. Thanks !

Mathieu

Quoted 42 lines · * Lai Jiangshan ([email protected]) wrote:

Hi, Mathieu Desnoyers

I have fixed this problem in mainline.
http://lkml.org/lkml/2008/11/14/74

Lai

Quoted 32 lines · Mathieu Desnoyers

Here is a fix for how relay handles cpu hotplug in the allocation error path. If a cpu goes down while allocating, it may result in a buffer never being freed.

Lai Jiangshan originally identified this problem in the LTTng fork of relay (ltt-relay-alloc). Here is the fix which applies to the original kernel/relay.c.

CC Lai Jiangshan <[email protected]>
CC Tom Zanussi <[email protected]>
---
 kernel/relay.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Index: linux-2.6-lttng/kernel/relay.c
===================================================================

kernel/relay.c +3 -4
@@ -611,10 +611,9 @@ struct rchan *relay_open(const char *bas
 	return chan;
 
 free_bufs:
-	for_each_online_cpu(i) {
-		if (!chan->buf[i])
-			break;
-		relay_close_buf(chan->buf[i]);
+	for_each_possible_cpu(i) {
+		if (chan->buf[i])
+			relay_close_buf(chan->buf[i]);
 	}
 
 	kref_put(&chan->kref, relay_destroy_channel);
Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68