public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org,
	Ian Campbell <ian.campbell@citrix.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH -v3] x86: do not free zero sized per cpu areas
Date: Fri, 19 Mar 2010 16:24:40 -0700	[thread overview]
Message-ID: <4BA407B8.7070503@kernel.org> (raw)
In-Reply-To: <4BA3F8ED.2090600@zytor.com>

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)

  reply	other threads:[~2010-03-19 23:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-05 15:03 Infinite loop on boot in free_early_partial due to start==end on tip/master Ian Campbell
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-05 19:51     ` Yinghai Lu
2010-03-19 19:24   ` Yinghai Lu
2010-03-19 21:42     ` H. Peter Anvin
2010-03-19 22:18   ` [PATCH -v3] " Yinghai Lu
2010-03-19 22:21     ` H. Peter Anvin
2010-03-19 23:24       ` Yinghai Lu [this message]
2010-03-19 23:29         ` H. Peter Anvin
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
2010-03-20  2:41                 ` Linus Torvalds
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
2010-03-19 23:35         ` [PATCH -v3] " Ian Campbell
2010-03-19 23:43           ` Ian Campbell
2010-03-19 23:43           ` H. Peter Anvin
2010-03-19 18:28 ` Infinite loop on boot in free_early_partial due to start==end on tip/master Konrad Rzeszutek Wilk
2010-03-19 19:04   ` Yinghai Lu
2010-03-19 19:34     ` Ian Campbell
2010-03-19 20:04       ` [LKML] " Konrad Rzeszutek Wilk
2010-03-19 21:17         ` Yinghai Lu
2010-03-19 21:37           ` Ian Campbell
2010-03-20  3:37           ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BA407B8.7070503@kernel.org \
    --to=yinghai@kernel.org \
    --cc=hpa@zytor.com \
    --cc=ian.campbell@citrix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox