Skip to contentSkip to conversation

relay: fix cpu offline problem

PATCH In review Lai Jiangshan 2 participants 2 messages Nov 14, 2008 Relay

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 relay: fix cpu offline problem

relay_open() will close allocated buffers when failed. but if cpu offlined, some buffer will not be closed. this patch fixed it.

and did cleanup for relay_reset() too.

---

kernel/relay.c +4 -5
index 8d13a78..32b0bef 100644
@@ -400,7 +400,7 @@ void relay_reset(struct rchan *chan)
 	}
 
 	mutex_lock(&relay_channels_mutex);
-	for_each_online_cpu(i)
+	for_each_possible_cpu(i)
 		if (chan->buf[i])
 			__relay_reset(chan->buf[i], 0);
 	mutex_unlock(&relay_channels_mutex);
@@ -611,10 +611,9 @@ struct rchan *relay_open(const char *base_filename,
 	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);
#1 lore raw
Quoted 5 lines · Lai Jiangshan

relay_open() will close allocated buffers when failed. but if cpu offlined, some buffer will not be closed. this patch fixed it.

and did cleanup for relay_reset() too.

Good catch, that definitely looks like a bug. Applied.

Quoted 31 lines

---

kernel/relay.c +4 -5
index 8d13a78..32b0bef 100644
@@ -400,7 +400,7 @@ void relay_reset(struct rchan *chan)
 	}
 
 	mutex_lock(&relay_channels_mutex);
-	for_each_online_cpu(i)
+	for_each_possible_cpu(i)
 		if (chan->buf[i])
 			__relay_reset(chan->buf[i], 0);
 	mutex_unlock(&relay_channels_mutex);
@@ -611,10 +611,9 @@ struct rchan *relay_open(const char *base_filename,
 	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 · 1 line
Jens Axboe