* [PATCH] relay: fix cpu offline problem
@ 2008-11-14 9:33 Lai Jiangshan
2008-11-14 9:41 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Lai Jiangshan @ 2008-11-14 9:33 UTC (permalink / raw)
To: jens.axboe; +Cc: Andrew Morton, Linux Kernel Mailing List
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.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/relay.c b/kernel/relay.c
index 8d13a78..32b0bef 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -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);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] relay: fix cpu offline problem
2008-11-14 9:33 [PATCH] relay: fix cpu offline problem Lai Jiangshan
@ 2008-11-14 9:41 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2008-11-14 9:41 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: Andrew Morton, Linux Kernel Mailing List
On Fri, Nov 14 2008, Lai Jiangshan wrote:
> 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.
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> diff --git a/kernel/relay.c b/kernel/relay.c
> index 8d13a78..32b0bef 100644
> --- a/kernel/relay.c
> +++ b/kernel/relay.c
> @@ -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);
>
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Relay : fix cpu offline problem
@ 2008-12-09 16:25 Mathieu Desnoyers
2008-12-10 0:33 ` Lai Jiangshan
0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Desnoyers @ 2008-12-09 16:25 UTC (permalink / raw)
To: Tom Zanussi; +Cc: Lai Jiangshan, linux-kernel
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.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Lai Jiangshan <laijs@cn.fujitsu.com>
CC: Tom Zanussi <zanussi@comcast.net>
---
kernel/relay.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Index: linux-2.6-lttng/kernel/relay.c
===================================================================
--- linux-2.6-lttng.orig/kernel/relay.c 2008-12-09 10:58:45.000000000 -0500
+++ linux-2.6-lttng/kernel/relay.c 2008-12-09 11:09:58.000000000 -0500
@@ -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);
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Relay : fix cpu offline problem
2008-12-09 16:25 [PATCH] Relay : " Mathieu Desnoyers
@ 2008-12-10 0:33 ` Lai Jiangshan
2008-12-10 1:54 ` Mathieu Desnoyers
0 siblings, 1 reply; 5+ messages in thread
From: Lai Jiangshan @ 2008-12-10 0:33 UTC (permalink / raw)
To: Mathieu Desnoyers; +Cc: Tom Zanussi, linux-kernel
Hi, Mathieu Desnoyers
I have fixed this problem in mainline.
http://lkml.org/lkml/2008/11/14/74
Lai
Mathieu Desnoyers wrote:
> 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.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> CC: Lai Jiangshan <laijs@cn.fujitsu.com>
> CC: Tom Zanussi <zanussi@comcast.net>
> ---
> kernel/relay.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> Index: linux-2.6-lttng/kernel/relay.c
> ===================================================================
> --- linux-2.6-lttng.orig/kernel/relay.c 2008-12-09 10:58:45.000000000 -0500
> +++ linux-2.6-lttng/kernel/relay.c 2008-12-09 11:09:58.000000000 -0500
> @@ -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);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Relay : fix cpu offline problem
2008-12-10 0:33 ` Lai Jiangshan
@ 2008-12-10 1:54 ` Mathieu Desnoyers
0 siblings, 0 replies; 5+ messages in thread
From: Mathieu Desnoyers @ 2008-12-10 1:54 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: Tom Zanussi, linux-kernel
Ah, great, I did not see it passing by. Thanks !
Mathieu
* Lai Jiangshan (laijs@cn.fujitsu.com) wrote:
> Hi, Mathieu Desnoyers
>
> I have fixed this problem in mainline.
> http://lkml.org/lkml/2008/11/14/74
>
> Lai
>
> Mathieu Desnoyers wrote:
> > 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.
> >
> > Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > CC: Lai Jiangshan <laijs@cn.fujitsu.com>
> > CC: Tom Zanussi <zanussi@comcast.net>
> > ---
> > kernel/relay.c | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > Index: linux-2.6-lttng/kernel/relay.c
> > ===================================================================
> > --- linux-2.6-lttng.orig/kernel/relay.c 2008-12-09 10:58:45.000000000 -0500
> > +++ linux-2.6-lttng/kernel/relay.c 2008-12-09 11:09:58.000000000 -0500
> > @@ -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);
>
>
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-12-10 1:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-14 9:33 [PATCH] relay: fix cpu offline problem Lai Jiangshan
2008-11-14 9:41 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2008-12-09 16:25 [PATCH] Relay : " Mathieu Desnoyers
2008-12-10 0:33 ` Lai Jiangshan
2008-12-10 1:54 ` Mathieu Desnoyers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox