* Re: Infinite loop on boot in free_early_partial due to start==end on tip/master
2010-03-05 18:16 ` Yinghai Lu
@ 2010-03-05 19:45 ` Ian Campbell
2010-03-05 19:49 ` [PATCH] x86: do not free zero sized per cpu areas Ian Campbell
` (2 subsequent siblings)
3 siblings, 0 replies; 28+ messages in thread
From: Ian Campbell @ 2010-03-05 19:45 UTC (permalink / raw)
To: Yinghai Lu; +Cc: Peter Zijlstra, Ingo Molnar, linux-kernel
On Fri, 2010-03-05 at 18:16 +0000, Yinghai Lu wrote:
>
> > + if (unlikely(start>=end)) {
> > + WARN_ONCE(1, "free_early_partial get wrong start/end
> \n:);
> > + return;
> > + }
> > +
Sure, although this can be written:
if (WARN_ONCE(start >= end, "free_early_partial.....\n"))
return;
Updated patch to follow.
Ian.
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH] x86: do not free zero sized per cpu areas
2010-03-05 18:16 ` Yinghai Lu
2010-03-05 19:45 ` Ian Campbell
@ 2010-03-05 19:49 ` Ian Campbell
2010-03-05 19:51 ` Yinghai Lu
2010-03-19 19:24 ` Yinghai Lu
2010-03-19 22:18 ` [PATCH -v3] " Yinghai Lu
3 siblings, 1 reply; 28+ messages in thread
From: Ian Campbell @ 2010-03-05 19:49 UTC (permalink / raw)
To: linux-kernel; +Cc: Ian Campbell, Yinghai Lu, Peter Zijlstra, Ingo Molnar
This avoids an infinite loop in free_early_partial().
Add a warning to free_early_partial to catch future problems.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/setup_percpu.c | 3 ++-
kernel/early_res.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index ef6370b..89a3205 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -140,7 +140,8 @@ static void __init pcpu_fc_free(void *ptr, size_t size)
#ifdef CONFIG_NO_BOOTMEM
u64 start = __pa(ptr);
u64 end = start + size;
- free_early_partial(start, end);
+ if (start < end)
+ free_early_partial(start, end);
#else
free_bootmem(__pa(ptr), size);
#endif
diff --git a/kernel/early_res.c b/kernel/early_res.c
index 3cb2c66..f3a861b 100644
--- a/kernel/early_res.c
+++ b/kernel/early_res.c
@@ -333,6 +333,11 @@ void __init free_early_partial(u64 start, u64 end)
struct early_res *r;
int i;
+ if (WARN_ONCE(start >= end,
+ "free_early_partial got wrong start/end %#llx/%#llx\n",
+ start, end))
+ return;
+
try_next:
i = find_overlapped_early(start, end);
if (i >= max_early_res)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH] x86: do not free zero sized per cpu areas
2010-03-05 19:49 ` [PATCH] x86: do not free zero sized per cpu areas Ian Campbell
@ 2010-03-05 19:51 ` Yinghai Lu
0 siblings, 0 replies; 28+ messages in thread
From: Yinghai Lu @ 2010-03-05 19:51 UTC (permalink / raw)
To: Ian Campbell, H. Peter Anvin, Thomas Gleixner
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar
On 03/05/2010 11:49 AM, Ian Campbell wrote:
> This avoids an infinite loop in free_early_partial().
>
> Add a warning to free_early_partial to catch future problems.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Cc: Yinghai Lu <yinghai@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@elte.hu>
> ---
> arch/x86/kernel/setup_percpu.c | 3 ++-
> kernel/early_res.c | 5 +++++
> 2 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
> index ef6370b..89a3205 100644
> --- a/arch/x86/kernel/setup_percpu.c
> +++ b/arch/x86/kernel/setup_percpu.c
> @@ -140,7 +140,8 @@ static void __init pcpu_fc_free(void *ptr, size_t size)
> #ifdef CONFIG_NO_BOOTMEM
> u64 start = __pa(ptr);
> u64 end = start + size;
> - free_early_partial(start, end);
> + if (start < end)
> + free_early_partial(start, end);
> #else
> free_bootmem(__pa(ptr), size);
> #endif
> diff --git a/kernel/early_res.c b/kernel/early_res.c
> index 3cb2c66..f3a861b 100644
> --- a/kernel/early_res.c
> +++ b/kernel/early_res.c
> @@ -333,6 +333,11 @@ void __init free_early_partial(u64 start, u64 end)
> struct early_res *r;
> int i;
>
> + if (WARN_ONCE(start >= end,
> + "free_early_partial got wrong start/end %#llx/%#llx\n",
> + start, end))
> + return;
> +
> try_next:
> i = find_overlapped_early(start, end);
> if (i >= max_early_res)
Acked-by: Yinghai Lu <yinghai@kernel.org>
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH] x86: do not free zero sized per cpu areas
2010-03-05 18:16 ` Yinghai Lu
2010-03-05 19:45 ` Ian Campbell
2010-03-05 19:49 ` [PATCH] x86: do not free zero sized per cpu areas Ian Campbell
@ 2010-03-19 19:24 ` Yinghai Lu
2010-03-19 21:42 ` H. Peter Anvin
2010-03-19 22:18 ` [PATCH -v3] " Yinghai Lu
3 siblings, 1 reply; 28+ messages in thread
From: Yinghai Lu @ 2010-03-19 19:24 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin
Cc: linux-kernel, Ian Campbell, Yinghai Lu, Peter Zijlstra,
Linus Torvalds
From: Ian Campbell <ian.campbell@citrix.com>
This avoids an infinite loop in free_early_partial().
Add a warning to free_early_partial to catch future problems.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/setup_percpu.c | 3 ++-
kernel/early_res.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index ef6370b..89a3205 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -140,7 +140,8 @@ static void __init pcpu_fc_free(void *ptr, size_t size)
#ifdef CONFIG_NO_BOOTMEM
u64 start = __pa(ptr);
u64 end = start + size;
- free_early_partial(start, end);
+ if (start < end)
+ free_early_partial(start, end);
#else
free_bootmem(__pa(ptr), size);
#endif
diff --git a/kernel/early_res.c b/kernel/early_res.c
index 3cb2c66..f3a861b 100644
--- a/kernel/early_res.c
+++ b/kernel/early_res.c
@@ -333,6 +333,11 @@ void __init free_early_partial(u64 start, u64 end)
struct early_res *r;
int i;
+ if (WARN_ONCE(start >= end,
+ "free_early_partial got wrong start/end %#llx/%#llx\n",
+ start, end))
+ return;
+
try_next:
i = find_overlapped_early(start, end);
if (i >= max_early_res)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH] x86: do not free zero sized per cpu areas
2010-03-19 19:24 ` Yinghai Lu
@ 2010-03-19 21:42 ` H. Peter Anvin
0 siblings, 0 replies; 28+ messages in thread
From: H. Peter Anvin @ 2010-03-19 21:42 UTC (permalink / raw)
To: Yinghai Lu
Cc: Ingo Molnar, Thomas Gleixner, linux-kernel, Ian Campbell,
Peter Zijlstra, Linus Torvalds
On 03/19/2010 12:24 PM, Yinghai Lu wrote:
> From: Ian Campbell <ian.campbell@citrix.com>
>
> This avoids an infinite loop in free_early_partial().
>
> Add a warning to free_early_partial to catch future problems.
Wouldn't it make more sense to simply make free_early_partial() a noop
for the zero range, instead of pushing all those tests into the callers?
It still might make sense to have a WARN_ONCE() for a *negative* range,
however...
-hpa
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH -v3] x86: do not free zero sized per cpu areas
2010-03-05 18:16 ` Yinghai Lu
` (2 preceding siblings ...)
2010-03-19 19:24 ` Yinghai Lu
@ 2010-03-19 22:18 ` Yinghai Lu
2010-03-19 22:21 ` H. Peter Anvin
3 siblings, 1 reply; 28+ messages in thread
From: Yinghai Lu @ 2010-03-19 22:18 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin
Cc: linux-kernel, Ian Campbell, Yinghai Lu, Peter Zijlstra,
Linus Torvalds
From: Ian Campbell <ian.campbell@citrix.com>
This avoids an infinite loop in free_early_partial().
Add a warning to free_early_partial to catch future problems.
-v3: according to hpa, don't bother caller.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
kernel/early_res.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/kernel/early_res.c b/kernel/early_res.c
index 3cb2c66..f3a861b 100644
--- a/kernel/early_res.c
+++ b/kernel/early_res.c
@@ -333,6 +333,11 @@ void __init free_early_partial(u64 start, u64 end)
struct early_res *r;
int i;
+ if (WARN_ONCE(start >= end,
+ "free_early_partial got wrong start/end %#llx/%#llx\n",
+ start, end))
+ return;
+
try_next:
i = find_overlapped_early(start, end);
if (i >= max_early_res)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH -v3] x86: do not free zero sized per cpu areas
2010-03-19 22:18 ` [PATCH -v3] " Yinghai Lu
@ 2010-03-19 22:21 ` H. Peter Anvin
2010-03-19 23:24 ` Yinghai Lu
0 siblings, 1 reply; 28+ messages in thread
From: H. Peter Anvin @ 2010-03-19 22:21 UTC (permalink / raw)
To: Yinghai Lu
Cc: Ingo Molnar, Thomas Gleixner, linux-kernel, Ian Campbell,
Peter Zijlstra, Linus Torvalds
On 03/19/2010 03:18 PM, Yinghai Lu wrote:
> From: Ian Campbell <ian.campbell@citrix.com>
>
> This avoids an infinite loop in free_early_partial().
>
> Add a warning to free_early_partial to catch future problems.
>
> -v3: according to hpa, don't bother caller.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@elte.hu>
> ---
> kernel/early_res.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/early_res.c b/kernel/early_res.c
> index 3cb2c66..f3a861b 100644
> --- a/kernel/early_res.c
> +++ b/kernel/early_res.c
> @@ -333,6 +333,11 @@ void __init free_early_partial(u64 start, u64 end)
> struct early_res *r;
> int i;
>
> + if (WARN_ONCE(start >= end,
> + "free_early_partial got wrong start/end %#llx/%#llx\n",
> + start, end))
> + return;
> +
> try_next:
> i = find_overlapped_early(start, end);
> if (i >= max_early_res)
No, that's wrong.
The workaround is still needed for the case of equality to avoid the
infinite loop.
So you need an:
if (start == end)
return;
-hpa
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH -v3] x86: do not free zero sized per cpu areas
2010-03-19 22:21 ` H. Peter Anvin
@ 2010-03-19 23:24 ` Yinghai Lu
2010-03-19 23:29 ` H. Peter Anvin
2010-03-19 23:35 ` [PATCH -v3] " Ian Campbell
0 siblings, 2 replies; 28+ messages in thread
From: Yinghai Lu @ 2010-03-19 23:24 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Ingo Molnar, Thomas Gleixner, linux-kernel, Ian Campbell,
Peter Zijlstra, Linus Torvalds
On 03/19/2010 03:21 PM, H. Peter Anvin wrote:
> On 03/19/2010 03:18 PM, Yinghai Lu wrote:
>> From: Ian Campbell <ian.campbell@citrix.com>
>>
>> This avoids an infinite loop in free_early_partial().
>>
>> Add a warning to free_early_partial to catch future problems.
>>
>> -v3: according to hpa, don't bother caller.
>>
>> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Cc: Ingo Molnar <mingo@elte.hu>
>> ---
>> kernel/early_res.c | 5 +++++
>> 1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/kernel/early_res.c b/kernel/early_res.c
>> index 3cb2c66..f3a861b 100644
>> --- a/kernel/early_res.c
>> +++ b/kernel/early_res.c
>> @@ -333,6 +333,11 @@ void __init free_early_partial(u64 start, u64 end)
>> struct early_res *r;
>> int i;
>>
>> + if (WARN_ONCE(start >= end,
>> + "free_early_partial got wrong start/end %#llx/%#llx\n",
>> + start, end))
>> + return;
>> +
>> try_next:
>> i = find_overlapped_early(start, end);
>> if (i >= max_early_res)
>
> No, that's wrong.
>
> The workaround is still needed for the case of equality to avoid the
> infinite loop.
>
> So you need an:
>
> if (start == end)
> return;
>
confused, do you mean like this
if (start < end), find_overlapped_early will stop the loop.
From: Ian Campbell <ian.campbell@citrix.com>
This avoids an infinite loop in free_early_partial().
Add a warning to free_early_partial to catch future problems.
-v3: according to hpa, don't bother caller.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
kernel/early_res.c | 8 ++++++++
1 file changed, 8 insertions(+)
Index: linux-2.6/kernel/early_res.c
===================================================================
--- linux-2.6.orig/kernel/early_res.c
+++ linux-2.6/kernel/early_res.c
@@ -333,6 +333,14 @@ void __init free_early_partial(u64 start
struct early_res *r;
int i;
+ if (start >= end) {
+ WARN_ONCE(1,
+ "free_early_partial got wrong start/end %#llx/%#llx\n",
+ start, end);
+
+ return;
+ }
+
try_next:
i = find_overlapped_early(start, end);
if (i >= max_early_res)
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH -v3] x86: do not free zero sized per cpu areas
2010-03-19 23:24 ` Yinghai Lu
@ 2010-03-19 23:29 ` H. Peter Anvin
2010-03-19 23:45 ` [PATCH -v4] " Yinghai Lu
2010-03-19 23:35 ` [PATCH -v3] " Ian Campbell
1 sibling, 1 reply; 28+ messages in thread
From: H. Peter Anvin @ 2010-03-19 23:29 UTC (permalink / raw)
To: Yinghai Lu
Cc: Ingo Molnar, Thomas Gleixner, linux-kernel, Ian Campbell,
Peter Zijlstra, Linus Torvalds
On 03/19/2010 04:24 PM, Yinghai Lu wrote:
>
> confused, do you mean like this
> if (start < end), find_overlapped_early will stop the loop.
>
No.
What I mean is that free_early_partial(), when start == end, is a
legitimate operation that doesn't free anything -- the range is zero
bytes long. Just return.
When start > end, there is an explicit error we should warn about.
-hpa
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH -v4] x86: do not free zero sized per cpu areas
2010-03-19 23:29 ` H. Peter Anvin
@ 2010-03-19 23:45 ` Yinghai Lu
2010-03-20 1:00 ` Linus Torvalds
0 siblings, 1 reply; 28+ messages in thread
From: Yinghai Lu @ 2010-03-19 23:45 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Ingo Molnar, Thomas Gleixner, linux-kernel, Ian Campbell,
Peter Zijlstra, Linus Torvalds
From: Ian Campbell <ian.campbell@citrix.com>
This avoids an infinite loop in free_early_partial().
Add a warning to free_early_partial to catch future problems.
-v3: according to hpa, don't bother caller.
-v4: start == end is ok?
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
kernel/early_res.c | 11 +++++++++++
1 file changed, 11 insertions(+)
Index: linux-2.6/kernel/early_res.c
===================================================================
--- linux-2.6.orig/kernel/early_res.c
+++ linux-2.6/kernel/early_res.c
@@ -333,6 +333,17 @@ void __init free_early_partial(u64 start
struct early_res *r;
int i;
+ if (start == end)
+ return;
+
+ if (start > end) {
+ WARN_ONCE(1,
+ "free_early_partial got wrong start/end %#llx/%#llx\n",
+ start, end);
+
+ return;
+ }
+
try_next:
i = find_overlapped_early(start, end);
if (i >= max_early_res)
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH -v4] x86: do not free zero sized per cpu areas
2010-03-19 23:45 ` [PATCH -v4] " Yinghai Lu
@ 2010-03-20 1:00 ` Linus Torvalds
2010-03-20 1:59 ` [PATCH -v5] " Yinghai Lu
0 siblings, 1 reply; 28+ messages in thread
From: Linus Torvalds @ 2010-03-20 1:00 UTC (permalink / raw)
To: Yinghai Lu
Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner, linux-kernel,
Ian Campbell, Peter Zijlstra
On Fri, 19 Mar 2010, Yinghai Lu wrote:
> +
> + if (start > end) {
> + WARN_ONCE(1,
> + "free_early_partial got wrong start/end %#llx/%#llx\n",
> + start, end);
> +
> + return;
This should be written as
if (WARN_ONCE(start > end, "free_early_partial(%#llx/%#llx)\n", start, end))
return;
rather than having a separate conditional.
Linus
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH -v5] x86: do not free zero sized per cpu areas
2010-03-20 1:00 ` Linus Torvalds
@ 2010-03-20 1:59 ` Yinghai Lu
2010-03-20 2:41 ` Linus Torvalds
0 siblings, 1 reply; 28+ messages in thread
From: Yinghai Lu @ 2010-03-20 1:59 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Linus Torvalds, Ingo Molnar, Thomas Gleixner, linux-kernel,
Ian Campbell, Peter Zijlstra
From: Ian Campbell <ian.campbell@citrix.com>
This avoids an infinite loop in free_early_partial().
Add a warning to free_early_partial to catch future problems.
-v5: put back start > end back into WARN_ONCE()
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
kernel/early_res.c | 8 ++++++++
1 file changed, 8 insertions(+)
Index: linux-2.6/kernel/early_res.c
===================================================================
--- linux-2.6.orig/kernel/early_res.c
+++ linux-2.6/kernel/early_res.c
@@ -333,6 +333,14 @@ void __init free_early_partial(u64 start
struct early_res *r;
int i;
+ if (start == end)
+ return;
+
+ if (WARN_ONCE(start > end,
+ "free_early_partial got wrong start/end %#llx/%#llx\n",
+ start, end))
+ return;
+
try_next:
i = find_overlapped_early(start, end);
if (i >= max_early_res)
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH -v5] x86: do not free zero sized per cpu areas
2010-03-20 1:59 ` [PATCH -v5] " Yinghai Lu
@ 2010-03-20 2:41 ` Linus Torvalds
2010-03-20 6:38 ` [PATCH -v6] " Yinghai Lu
0 siblings, 1 reply; 28+ messages in thread
From: Linus Torvalds @ 2010-03-20 2:41 UTC (permalink / raw)
To: Yinghai Lu
Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner, linux-kernel,
Ian Campbell, Peter Zijlstra
On Fri, 19 Mar 2010, Yinghai Lu wrote:
> + if (WARN_ONCE(start > end,
> + "free_early_partial got wrong start/end %#llx/%#llx\n",
> + start, end))
I really don't want multi-line single statements like this.
Shorten the string a bit, and it should all fit fine on one line, and be
much more greppable.
Linus
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH -v6] x86: do not free zero sized per cpu areas
2010-03-20 2:41 ` Linus Torvalds
@ 2010-03-20 6:38 ` Yinghai Lu
2010-03-20 7:12 ` Ian Campbell
2010-03-22 17:30 ` [LKML] " Konrad Rzeszutek Wilk
0 siblings, 2 replies; 28+ messages in thread
From: Yinghai Lu @ 2010-03-20 6:38 UTC (permalink / raw)
To: Linus Torvalds
Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner, linux-kernel,
Ian Campbell, Peter Zijlstra
From: Ian Campbell <ian.campbell@citrix.com>
This avoids an infinite loop in free_early_partial().
Add a warning to free_early_partial to catch future problems.
-v5: put back start > end back into WARN_ONCE()
-v6: use one line for if according to linus
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
kernel/early_res.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: linux-2.6/kernel/early_res.c
===================================================================
--- linux-2.6.orig/kernel/early_res.c
+++ linux-2.6/kernel/early_res.c
@@ -333,6 +333,12 @@ void __init free_early_partial(u64 start
struct early_res *r;
int i;
+ if (start == end)
+ return;
+
+ if (WARN_ONCE(start > end, "free_early_partial: wrong range [%#llx, %#llx]\n", start, end))
+ return;
+
try_next:
i = find_overlapped_early(start, end);
if (i >= max_early_res)
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH -v6] x86: do not free zero sized per cpu areas
2010-03-20 6:38 ` [PATCH -v6] " Yinghai Lu
@ 2010-03-20 7:12 ` Ian Campbell
2010-03-22 17:30 ` [LKML] " Konrad Rzeszutek Wilk
1 sibling, 0 replies; 28+ messages in thread
From: Ian Campbell @ 2010-03-20 7:12 UTC (permalink / raw)
To: Yinghai Lu
Cc: Linus Torvalds, H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
linux-kernel@vger.kernel.org, Peter Zijlstra
Looks good to me, thanks Yinghai.
On Sat, 2010-03-20 at 06:38 +0000, Yinghai Lu wrote:
> From: Ian Campbell <ian.campbell@citrix.com>
>
> This avoids an infinite loop in free_early_partial().
>
> Add a warning to free_early_partial to catch future problems.
>
> -v5: put back start > end back into WARN_ONCE()
> -v6: use one line for if according to linus
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@elte.hu>
> ---
> kernel/early_res.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> Index: linux-2.6/kernel/early_res.c
> ===================================================================
> --- linux-2.6.orig/kernel/early_res.c
> +++ linux-2.6/kernel/early_res.c
> @@ -333,6 +333,12 @@ void __init free_early_partial(u64 start
> struct early_res *r;
> int i;
>
> + if (start == end)
> + return;
> +
> + if (WARN_ONCE(start > end, "free_early_partial: wrong range [%#llx, %#llx]\n", start, end))
> + return;
> +
> try_next:
> i = find_overlapped_early(start, end);
> if (i >= max_early_res)
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [LKML] [PATCH -v6] x86: do not free zero sized per cpu areas
2010-03-20 6:38 ` [PATCH -v6] " Yinghai Lu
2010-03-20 7:12 ` Ian Campbell
@ 2010-03-22 17:30 ` Konrad Rzeszutek Wilk
1 sibling, 0 replies; 28+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-03-22 17:30 UTC (permalink / raw)
To: Yinghai Lu
Cc: Linus Torvalds, H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
linux-kernel, Ian Campbell, Peter Zijlstra
On Fri, Mar 19, 2010 at 11:38:30PM -0700, Yinghai Lu wrote:
> From: Ian Campbell <ian.campbell@citrix.com>
>
> This avoids an infinite loop in free_early_partial().
>
> Add a warning to free_early_partial to catch future problems.
>
> -v5: put back start > end back into WARN_ONCE()
> -v6: use one line for if according to linus
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@elte.hu>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> kernel/early_res.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> Index: linux-2.6/kernel/early_res.c
> ===================================================================
> --- linux-2.6.orig/kernel/early_res.c
> +++ linux-2.6/kernel/early_res.c
> @@ -333,6 +333,12 @@ void __init free_early_partial(u64 start
> struct early_res *r;
> int i;
>
> + if (start == end)
> + return;
> +
> + if (WARN_ONCE(start > end, "free_early_partial: wrong range [%#llx, %#llx]\n", start, end))
> + return;
> +
> try_next:
> i = find_overlapped_early(start, end);
> if (i >= max_early_res)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH -v3] x86: do not free zero sized per cpu areas
2010-03-19 23:24 ` Yinghai Lu
2010-03-19 23:29 ` H. Peter Anvin
@ 2010-03-19 23:35 ` Ian Campbell
2010-03-19 23:43 ` Ian Campbell
2010-03-19 23:43 ` H. Peter Anvin
1 sibling, 2 replies; 28+ messages in thread
From: Ian Campbell @ 2010-03-19 23:35 UTC (permalink / raw)
To: Yinghai Lu
Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
linux-kernel@vger.kernel.org, Peter Zijlstra, Linus Torvalds
On Fri, 2010-03-19 at 23:24 +0000, Yinghai Lu wrote:
> On 03/19/2010 03:21 PM, H. Peter Anvin wrote:
> > On 03/19/2010 03:18 PM, Yinghai Lu wrote:
> >> From: Ian Campbell <ian.campbell@citrix.com>
> >>
> >> This avoids an infinite loop in free_early_partial().
> >>
> >> Add a warning to free_early_partial to catch future problems.
> >>
> >> -v3: according to hpa, don't bother caller.
> >>
> >> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> >> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> >> Cc: Peter Zijlstra <peterz@infradead.org>
> >> Cc: Ingo Molnar <mingo@elte.hu>
> >> ---
> >> kernel/early_res.c | 5 +++++
> >> 1 files changed, 5 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/kernel/early_res.c b/kernel/early_res.c
> >> index 3cb2c66..f3a861b 100644
> >> --- a/kernel/early_res.c
> >> +++ b/kernel/early_res.c
> >> @@ -333,6 +333,11 @@ void __init free_early_partial(u64 start, u64 end)
> >> struct early_res *r;
> >> int i;
> >>
> >> + if (WARN_ONCE(start >= end,
> >> + "free_early_partial got wrong start/end %#llx/%#llx\n",
> >> + start, end))
> >> + return;
> >> +
> >> try_next:
> >> i = find_overlapped_early(start, end);
> >> if (i >= max_early_res)
> >
> > No, that's wrong.
> >
> > The workaround is still needed for the case of equality to avoid the
> > infinite loop.
> >
> > So you need an:
> >
> > if (start == end)
> > return;
> >
>
> confused, do you mean like this
> if (start < end), find_overlapped_early will stop the loop.
I think Peter means:
if (start == end)
return;
if (WARN_ONCE(start < end, "blah"))
return;
i.e. silently ignore a zero sized region and verbosely ignore a
negatively sized one.
Ian.
> From: Ian Campbell <ian.campbell@citrix.com>
>
> This avoids an infinite loop in free_early_partial().
>
> Add a warning to free_early_partial to catch future problems.
>
> -v3: according to hpa, don't bother caller.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@elte.hu>
> ---
> kernel/early_res.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> Index: linux-2.6/kernel/early_res.c
> ===================================================================
> --- linux-2.6.orig/kernel/early_res.c
> +++ linux-2.6/kernel/early_res.c
> @@ -333,6 +333,14 @@ void __init free_early_partial(u64 start
> struct early_res *r;
> int i;
>
> + if (start >= end) {
> + WARN_ONCE(1,
> + "free_early_partial got wrong start/end %#llx/%#llx\n",
> + start, end);
> +
> + return;
> + }
> +
> try_next:
> i = find_overlapped_early(start, end);
> if (i >= max_early_res)
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH -v3] x86: do not free zero sized per cpu areas
2010-03-19 23:35 ` [PATCH -v3] " Ian Campbell
@ 2010-03-19 23:43 ` Ian Campbell
2010-03-19 23:43 ` H. Peter Anvin
1 sibling, 0 replies; 28+ messages in thread
From: Ian Campbell @ 2010-03-19 23:43 UTC (permalink / raw)
To: Yinghai Lu
Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
linux-kernel@vger.kernel.org, Peter Zijlstra, Linus Torvalds
On Fri, 2010-03-19 at 23:35 +0000, Ian Campbell wrote:
> if (WARN_ONCE(start < end, "blah"))
or rather "start > end"...
Ian.
--
Ian Campbell
I am a friend of the working man, and I would rather be his friend
than be one.
-- Clarence Darrow
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH -v3] x86: do not free zero sized per cpu areas
2010-03-19 23:35 ` [PATCH -v3] " Ian Campbell
2010-03-19 23:43 ` Ian Campbell
@ 2010-03-19 23:43 ` H. Peter Anvin
1 sibling, 0 replies; 28+ messages in thread
From: H. Peter Anvin @ 2010-03-19 23:43 UTC (permalink / raw)
To: Ian Campbell
Cc: Yinghai Lu, Ingo Molnar, Thomas Gleixner,
linux-kernel@vger.kernel.org, Peter Zijlstra, Linus Torvalds
On 03/19/2010 04:35 PM, Ian Campbell wrote:
>
> I think Peter means:
>
> if (start == end)
> return;
>
> if (WARN_ONCE(start < end, "blah"))
> return;
start > end!
> i.e. silently ignore a zero sized region and verbosely ignore a
> negatively sized one.
Correct.
-hpa
^ permalink raw reply [flat|nested] 28+ messages in thread