From: Ingo Molnar <mingo@chiara.csoma.elte.hu>
To: linux-kernel@vger.rutgers.edu, MM mailing list <linux-mm@kvack.org>
Cc: Linus Torvalds <torvalds@transmeta.com>
Subject: [patch] bootmem-2.3.26-A1
Date: Fri, 5 Nov 1999 22:27:55 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.10.9911052224070.12691-200000@chiara.csoma.elte.hu> (raw)
[-- Attachment #1: Type: TEXT/PLAIN, Size: 277 bytes --]
this fixes the __va confusion. (the patch does not add RAM testing)
but more importantly, Bjorn Andersson found a bug in bootmem_free(): start
addresses have to be rounded upwards, not downwards. This could expain
some of the booting problems and crashes reported.
-- mingo
[-- Attachment #2: Type: TEXT/PLAIN, Size: 2547 bytes --]
--- linux/mm/bootmem.c.orig3 Fri Nov 5 02:10:45 1999
+++ linux/mm/bootmem.c Fri Nov 5 13:12:55 1999
@@ -36,9 +36,7 @@
{
unsigned long mapsize = (pages+7)/8;
- if (bootmem_map)
- BUG();
- bootmem_map = __va(start << PAGE_SHIFT);
+ bootmem_map = phys_to_virt(start << PAGE_SHIFT);
max_low_pfn = pages;
/*
@@ -64,7 +62,6 @@
*/
unsigned long end = (addr + size + PAGE_SIZE-1)/PAGE_SIZE;
- if (!bootmem_map) BUG();
if (!size) BUG();
if (end > max_low_pfn)
@@ -77,18 +74,23 @@
void __init free_bootmem (unsigned long addr, unsigned long size)
{
unsigned long i;
+ unsigned long start;
/*
* round down end of usable mem, partially free pages are
* considered reserved.
*/
unsigned long end = (addr + size)/PAGE_SIZE;
- if (!bootmem_map) BUG();
if (!size) BUG();
-
if (end > max_low_pfn)
BUG();
- for (i = addr/PAGE_SIZE; i < end; i++) {
+
+ /*
+ * Round up the beginning of the address.
+ */
+ start = (addr + PAGE_SIZE-1) / PAGE_SIZE;
+
+ for (i = start; i < end; i++) {
if (!test_and_clear_bit(i, bootmem_map))
BUG();
}
@@ -117,7 +119,6 @@
unsigned long offset, remaining_size;
unsigned long areasize, preferred;
- if (!bootmem_map) BUG();
if (!size) BUG();
/*
@@ -152,6 +153,9 @@
preferred = 0;
goto restart_scan;
}
+ /*
+ * Whoops, we cannot satisfy the allocation request.
+ */
BUG();
found:
if (start >= max_low_pfn)
@@ -173,11 +177,11 @@
areasize = 0;
// last_pos unchanged
last_offset = offset+size;
- ret = __va(last_pos*PAGE_SIZE + offset);
+ ret = phys_to_virt(last_pos*PAGE_SIZE + offset);
} else {
size -= remaining_size;
areasize = (size+PAGE_SIZE-1)/PAGE_SIZE;
- ret = __va(last_pos*PAGE_SIZE + offset);
+ ret = phys_to_virt(last_pos*PAGE_SIZE + offset);
last_pos = start+areasize-1;
last_offset = size;
}
@@ -185,7 +189,7 @@
} else {
last_pos = start + areasize - 1;
last_offset = size & ~PAGE_MASK;
- ret = __va(start * PAGE_SIZE);
+ ret = phys_to_virt(start * PAGE_SIZE);
}
/*
* Reserve the area now:
@@ -211,12 +215,13 @@
count++;
ClearPageReserved(page);
set_page_count(page, 1);
- if (i >= (__pa(MAX_DMA_ADDRESS) >> PAGE_SHIFT))
+ if (i >= (virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT))
clear_bit(PG_DMA, &page->flags);
__free_page(page);
}
}
total += count;
+
/*
* Now free the allocator bitmap itself, it's not
* needed anymore:
reply other threads:[~1999-11-05 21:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Pine.LNX.4.10.9911052224070.12691-200000@chiara.csoma.elte.hu \
--to=mingo@chiara.csoma.elte.hu \
--cc=linux-kernel@vger.rutgers.edu \
--cc=linux-mm@kvack.org \
--cc=torvalds@transmeta.com \
/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