linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-pci@vger.kernel.org, yannick.roehlly@free.fr
Subject: Re: [PATCH] x86/pci: make pci_mem_start to be aligned only -v4
Date: Sat, 18 Apr 2009 16:01:06 -0700	[thread overview]
Message-ID: <49EA5BB2.90603@kernel.org> (raw)
In-Reply-To: <49EA57C4.1000603@kernel.org>

Yinghai Lu wrote:
> Linus Torvalds wrote:
>> On Sat, 18 Apr 2009, Yinghai Lu wrote:
>>> except need to change 
>>>> +		reserve_region_with_split(&iomem_resource, start, end, "RAM buffer");
>>> ==> > +		reserve_region_with_split(&iomem_resource, start, end - 1, "RAM buffer");
>> Yes, I sent out a later email pointing that out.
>>
>>> it will make sure dynmical allocating code will not use those range.
>>>
>>> and could make e820_setup_gap much simple.
>> ACK. In fact:
>>
>>> Index: linux-2.6/arch/x86/kernel/e820.c
>>> ===================================================================
>>> --- linux-2.6.orig/arch/x86/kernel/e820.c
>>> +++ linux-2.6/arch/x86/kernel/e820.c
>>> @@ -635,14 +635,12 @@ __init void e820_setup_gap(void)
>>>  #endif
>>>  
>>>  	/*
>>> -	 * See how much we want to round up: start off with
>>> -	 * rounding to the next 1MB area.
>>> +	 * e820_reserve_resources_late will protect stolen RAM
>>> +	 * so just round it to 1M
>>>  	 */
>>>  	round = 0x100000;
>>> -	while ((gapsize >> 4) > round)
>>> -		round += round;
>>> -	/* Fun with two's complement */
>>> -	pci_mem_start = (gapstart + round) & -round;
>>> +
>>> +	pci_mem_start = roundup(gapstart, round);
>> You can just remove "round" entirely. It's no longer a variable, it's just 
>> an odd way of saying 1M ;)
>>
>>> Ingo, can you put those two patches in tip?
>> I would suggest that we first change "reserve_region_with_split()" to not 
>> recurse into the region.
>>
>> That function isn't used by anything else (we ended up using 
>> "expand_to_fit()" instead in the one place that migth have used it), and 
>> now th eone caller we do have would not want the recursion - if there 
>> already exists a resource at the top level, we want to just avoid it.
>>
>> This - again TOTALLY UNTESTED - patch removes the "recurse into conflicts" 
>> code. Comments? Testing?
>>
>> 			Linus
>> ---
>>  kernel/resource.c |   46 ++++++++++++----------------------------------
>>  1 files changed, 12 insertions(+), 34 deletions(-)
>>
>> diff --git a/kernel/resource.c b/kernel/resource.c
>> index fd5d7d5..ac5f3a3 100644
>> --- a/kernel/resource.c
>> +++ b/kernel/resource.c
>> @@ -533,43 +533,21 @@ static void __init __reserve_region_with_split(struct resource *root,
>>  	res->end = end;
>>  	res->flags = IORESOURCE_BUSY;
>>  
>> -	for (;;) {
>> -		conflict = __request_resource(parent, res);
>> -		if (!conflict)
>> -			break;
>> -		if (conflict != parent) {
>> -			parent = conflict;
>> -			if (!(conflict->flags & IORESOURCE_BUSY))
>> -				continue;
>> -		}
>> -
>> -		/* Uhhuh, that didn't work out.. */
>> -		kfree(res);
>> -		res = NULL;
>> -		break;
>> -	}
>> -
>> -	if (!res) {
>> -		/* failed, split and try again */
>> -
>> -		/* conflict covered whole area */
>> -		if (conflict->start <= start && conflict->end >= end)
>> -			return;
>> +	conflict = __request_resource(parent, res);
>> +	if (!conflict)
>> +		return;
>>  
>> -		if (conflict->start > start)
>> -			__reserve_region_with_split(root, start, conflict->start-1, name);
>> -		if (!(conflict->flags & IORESOURCE_BUSY)) {
>> -			resource_size_t common_start, common_end;
>> +	/* failed, split and try again */
>> +	kfree(res);
>>  
>> -			common_start = max(conflict->start, start);
>> -			common_end = min(conflict->end, end);
>> -			if (common_start < common_end)
>> -				__reserve_region_with_split(root, common_start, common_end, name);
>> -		}
>> -		if (conflict->end < end)
>> -			__reserve_region_with_split(root, conflict->end+1, end, name);
>> -	}
>> +	/* conflict covered whole area */
>> +	if (conflict->start <= start && conflict->end >= end)
>> +		return;
>>  
>> +	if (conflict->start > start)
>> +		__reserve_region_with_split(root, start, conflict->start-1, name);
>> +	if (conflict->end < end)
>> +		__reserve_region_with_split(root, conflict->end+1, end, name);
>>  }
>>  
>>  void __init reserve_region_with_split(struct resource *root,
> 
> with
> [    0.000000] BIOS-provided physical RAM map:
> [    0.000000]  BIOS-e820: 0000000000000100 - 0000000000097400 (usable)
> [    0.000000]  BIOS-e820: 0000000000097400 - 00000000000a0000 (reserved)
> [    0.000000]  BIOS-e820: 0000000000100000 - 00000000b7fa0000 (usable)
> [    0.000000]  BIOS-e820: 00000000b7fae000 - 00000000b7fb0000 (usable)
> [    0.000000]  BIOS-e820: 00000000b7fb0000 - 00000000b7fbe000 (ACPI data)
> [    0.000000]  BIOS-e820: 00000000b7fbe000 - 00000000b7ff0000 (ACPI NVS)
> [    0.000000]  BIOS-e820: 00000000b7ff0000 - 00000000b8000000 (reserved)
> [    0.000000]  BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)
> [    0.000000]  BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved)
> [    0.000000]  BIOS-e820: 00000000fee00000 - 00000000fef00000 (reserved)
> [    0.000000]  BIOS-e820: 00000000ff700000 - 0000000100000000 (reserved)
> [    0.000000]  BIOS-e820: 0000000100000000 - 0000002048000000 (usable)
> 
> got
> 
> 00000100-000973ff : System RAM
> 00097400-0009ffff : reserved
> 000a0000-000bffff : PCI Bus #00
> 000c0000-000cffff : pnp 00:0c
> 000e0000-000fffff : pnp 00:0c
> 00100000-b7f9ffff : System RAM
>   00200000-00c68f6b : Kernel code
>   00c68f6c-01332f7f : Kernel data
>   015a6000-01fcaa57 : Kernel bss
>   20000000-23ffffff : GART
> b7fa0000-b7fadfff : RAM buffer
> b7fae000-b7faffff : System RAM
> b7fb0000-b7fbdfff : ACPI Tables
> b7fbe000-b7feffff : ACPI Non-volatile Storage
> b7ff0000-b7ffffff : reserved
> ...
> 
without your patch got
00000100-000973ff : System RAM
00097400-0009ffff : reserved
000a0000-000bffff : PCI Bus #00
000c0000-000cffff : pnp 00:0c
000e0000-000fffff : pnp 00:0c
00100000-b7f9ffff : System RAM
  00200000-00c68f6b : Kernel code
  00c68f6c-01332f7f : Kernel data
  015a6000-01fcaa57 : Kernel bss
  20000000-23ffffff : GART
b7fa0000-b7fadfff : RAM buffer
b7fae000-b7faffff : System RAM
b7fb0000-b7fbdfff : ACPI Tables
b7fbe000-b7feffff : ACPI Non-volatile Storage
b7ff0000-b7ffffff : reserved
  b7ff0000-b7ffffff : RAM buffer
b8000000-beffffff : PCI Bus #00
bf000000-bfffffff : PCI Bus #80


  reply	other threads:[~2009-04-18 23:02 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-11103-13546@http.bugzilla.kernel.org/>
     [not found] ` <200904101913.n3AJDhMm018684@demeter.kernel.org>
2009-04-10 20:27   ` [Bug 11103] Can't use framebuffer or vesa Xorg with two memory modules Yinghai Lu
2009-04-11  3:29     ` Yinghai Lu
2009-04-14 20:49       ` [PATCH] pci: don't assume pref memio are 64bit -v2 Yinghai Lu
2009-04-14 20:50         ` [PATCH] x86/pci: make pci_mem_start to be aligned only Yinghai Lu
2009-04-14 21:10           ` Linus Torvalds
2009-04-14 21:27             ` H. Peter Anvin
2009-04-14 21:27             ` Yinghai Lu
2009-04-14 22:35             ` Yannick Roehlly
2009-04-15  0:29             ` [PATCH] x86/pci: make pci_mem_start to be aligned only -v2 Yinghai Lu
2009-04-15  0:41               ` [PATCH] x86/pci: make pci_mem_start to be aligned only -v3 Yinghai Lu
2009-04-15  0:42                 ` [PATCH] x86/pci: fix -1 calling to e820_all_mapped with mmconfig Yinghai Lu
2009-04-16 16:31                 ` [PATCH] x86/pci: make pci_mem_start to be aligned only -v3 Jesse Barnes
2009-04-16 16:44                   ` Linus Torvalds
2009-04-16 16:56                     ` Ingo Molnar
2009-04-16 17:18                       ` Yinghai Lu
2009-04-16 17:27                         ` H. Peter Anvin
2009-04-16 17:38                           ` Ingo Molnar
2009-04-16 17:28                         ` Ingo Molnar
2009-04-16 20:13                           ` [PATCH] x86/pci: make pci_mem_start to be aligned only -v4 Yinghai Lu
2009-04-16 23:18                             ` Linus Torvalds
2009-04-16 23:54                               ` Ingo Molnar
2009-04-17  0:24                                 ` Linus Torvalds
2009-04-17 13:16                                   ` Ingo Molnar
2009-04-17 21:59                                     ` Yinghai Lu
2009-04-17 22:04                                     ` H. Peter Anvin
2009-04-18  5:37                                       ` [PATCH] pci: keep pci device resource name pointer right Yinghai Lu
2009-04-18  7:51                                         ` Ingo Molnar
2009-04-18 16:05                                           ` Jesse Barnes
2009-04-18 18:42                                         ` Linus Torvalds
2009-04-18 19:19                                           ` Yinghai Lu
2009-04-18 19:23                                             ` Greg KH
2009-04-18 20:00                                               ` Kay Sievers
2009-04-18 20:27                                                 ` Kay Sievers
2009-04-18 20:37                                                   ` Ingo Molnar
2009-04-18 22:05                                                     ` [PATCH] driver: dont update dev_name via device_add path Yinghai Lu
2009-04-28  7:36                                                       ` [PATCH] driver: make dev_set_name(, NULL) work Yinghai Lu
2009-04-28  7:42                                                         ` [RFC PATCH] use dev_set_name(,NULL) to prevent leaking Yinghai Lu
2009-04-28  8:25                                                           ` Kay Sievers
2009-04-28 15:21                                                             ` Yinghai Lu
2009-04-28 15:34                                                               ` Yinghai Lu
2009-04-28 15:39                                                                 ` Greg KH
2009-04-28 15:51                                                                   ` Yinghai Lu
2009-04-28 15:56                                                                     ` Kay Sievers
2009-04-28 16:08                                                                       ` Yinghai Lu
2009-04-28 16:15                                                                         ` Kay Sievers
2009-04-28 19:04                                                                           ` Yinghai Lu
2009-04-28 16:36                                                                       ` Yinghai Lu
2009-04-28 16:50                                                                         ` Kay Sievers
2009-04-28 14:52                                                           ` Greg KH
2009-04-28 14:51                                                         ` [PATCH] driver: make dev_set_name(, NULL) work Greg KH
2009-04-28 15:14                                                           ` Yinghai Lu
2009-04-28 15:39                                                             ` Greg KH
2009-04-18 21:07                                                   ` [PATCH] pci: keep pci device resource name pointer right Yinghai Lu
2009-04-18 22:17                                                   ` Linus Torvalds
2009-04-18 20:00                                               ` [PATCH] driver: dont update dev_name if it is not changed Yinghai Lu
2009-04-18 20:11                                                 ` Ingo Molnar
2009-04-18 20:20                                                   ` Yinghai Lu
2009-04-18 20:27                                                     ` Ingo Molnar
2009-04-18  8:33                               ` [PATCH] x86/pci: make pci_mem_start to be aligned only -v4 Yinghai Lu
2009-04-18  9:22                                 ` Ingo Molnar
2009-04-18 17:07                                   ` Yinghai Lu
2009-04-18 18:57                                   ` Linus Torvalds
2009-04-18 19:14                                     ` Ingo Molnar
2009-04-18 19:26                                       ` Yinghai Lu
2009-04-18 22:20                                         ` Yinghai Lu
2009-04-18 22:31                                         ` Linus Torvalds
2009-04-18 20:13                                       ` Ivan Kokshaysky
2009-04-18 18:50                                 ` Linus Torvalds
2009-04-18 22:44                                   ` Yinghai Lu
2009-04-18 23:01                                     ` Yinghai Lu [this message]
2009-04-18 23:06                                       ` Linus Torvalds
2009-04-18 23:26                                         ` Yinghai Lu
2009-04-18 23:30                                           ` Yinghai Lu
2009-04-18 23:04                                     ` Linus Torvalds
2009-04-19  0:32                                       ` H. Peter Anvin
2009-04-19  4:50                                       ` Linus Torvalds
2009-04-19  5:26                                         ` Yinghai Lu
2009-04-19 19:35                                           ` Yannick Roehlly
2009-04-19 19:59                                             ` Yinghai Lu
2009-04-19 20:24                                               ` Yannick Roehlly
2009-04-19  9:02                                         ` Ingo Molnar
2009-04-19  9:06                                           ` Ingo Molnar
2009-04-19 17:52                                             ` Jesse Barnes
2009-04-20 22:33                                             ` Ivan Kokshaysky
2009-04-20 22:52                                               ` Yinghai Lu
2009-04-21 10:54                                                 ` Ivan Kokshaysky
2009-04-21  0:09                                               ` Yinghai Lu
2009-04-21 10:56                                                 ` Ivan Kokshaysky
2009-04-21 15:57                                                   ` Yinghai Lu
2009-04-22 22:37                                                   ` [RFC PATCH 1/2] pci: don't assume pref memio are 64bit -v3 Yinghai Lu
2009-04-22 22:38                                                     ` [RFC PATCH 2/2] pci: try to assign res for device under transparent bridges Yinghai Lu
2009-04-22 22:49                                                     ` [RFC PATCH 1/2] pci: don't assume pref memio are 64bit -v3 Jesse Barnes
2009-04-23  0:49                                                       ` Yinghai Lu
2009-04-23  1:05                                                         ` Jesse Barnes
2009-04-23  2:03                                                           ` Yinghai Lu
2009-04-23 12:58                                                             ` Ivan Kokshaysky
2009-04-23 15:30                                                               ` Yinghai Lu
2009-04-23  2:10                                                           ` Yinghai Lu
2009-04-23 13:22                                                             ` Ivan Kokshaysky
2009-04-23 15:13                                                               ` Yinghai Lu
2009-04-23 22:19                                                                 ` Ivan Kokshaysky
2009-04-24  3:48                                                                   ` [PATCH 1/4] pci/x86: don't assume pref memio are 64bit -v4 Yinghai Lu
2009-04-24  3:49                                                                     ` [PATCH 2/4] pci: try to assign res for device under transparent bridges -v2 Yinghai Lu
2009-04-24  3:50                                                                     ` [PATCH 3/4] x86: reserve range near the ram Yinghai Lu
2009-04-24  3:50                                                                     ` [PATCH 4/4] x86/pci: make pci_mem_start to be aligned only -v5 Yinghai Lu
2009-04-24 13:16                                                                     ` [PATCH 1/4] pci/x86: don't assume pref memio are 64bit -v4 Ivan Kokshaysky
2009-05-05 18:52                                                                     ` Jesse Barnes
2009-05-06 12:33                                                                       ` Ingo Molnar
2009-05-06 15:06                                                                         ` [PATCH 1/2] x86: reserve range near the ram Yinghai Lu
2009-05-11  9:51                                                                           ` [tip:x86/mm] x86, e820, pci: reserve extra free space near end of RAM tip-bot for Linus Torvalds
2009-05-06 15:07                                                                         ` [PATCH 1/2] x86/pci: make pci_mem_start to be aligned only -v5 Yinghai Lu
2009-05-11  9:51                                                                           ` [tip:x86/mm] x86/pci: remove rounding quirk from e820_setup_gap() tip-bot for Yinghai Lu
2009-04-23 12:36                                                     ` [RFC PATCH 1/2] pci: don't assume pref memio are 64bit -v3 Ivan Kokshaysky
2009-04-23 12:41                                                       ` Ingo Molnar
2009-04-23 13:09                                                         ` Ivan Kokshaysky
2009-04-23 15:05                                                       ` Yinghai Lu
2009-04-21 15:41                                               ` [PATCH] x86/pci: make pci_mem_start to be aligned only -v4 Jesse Barnes

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=49EA5BB2.90603@kernel.org \
    --to=yinghai@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=yannick.roehlly@free.fr \
    /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;
as well as URLs for NNTP newsgroup(s).