From: Brian Gerst <bgerst@didntduck.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Linux-Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] i386 mm init cleanup part 2
Date: Sat, 25 May 2002 11:17:51 -0400 [thread overview]
Message-ID: <3CEFAB1F.102@didntduck.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 118 bytes --]
The remaining cleanups are to switch to using pfn instead of vaddr, and
improve readability.
--
Brian Gerst
[-- Attachment #2: mminit-3b --]
[-- Type: text/plain, Size: 2454 bytes --]
diff -urN linux-mm1/arch/i386/mm/init.c linux/arch/i386/mm/init.c
--- linux-mm1/arch/i386/mm/init.c Sat May 25 09:30:21 2002
+++ linux/arch/i386/mm/init.c Sat May 25 10:46:11 2002
@@ -181,22 +181,16 @@
static void __init pagetable_init (void)
{
- unsigned long vaddr, end;
+ unsigned long vaddr, pfn;
pgd_t *pgd, *pgd_base;
int i, j, k;
pmd_t *pmd;
pte_t *pte, *pte_base;
- /*
- * This can be zero as well - no problem, in that case we exit
- * the loops anyway due to the PTRS_PER_* conditions.
- */
- end = (unsigned long)__va(max_low_pfn*PAGE_SIZE);
-
pgd_base = swapper_pg_dir;
#if CONFIG_X86_PAE
for (i = 0; i < PTRS_PER_PGD; i++)
- set_pgd(pgd_base + i, __pgd(1 + __pa(empty_zero_page)));
+ set_pgd(pgd_base + i, __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
#endif
if (cpu_has_pse) {
set_in_cr4(X86_CR4_PSE);
@@ -207,41 +201,28 @@
}
i = __pgd_offset(PAGE_OFFSET);
+ pfn = 0;
pgd = pgd_base + i;
- for (; i < PTRS_PER_PGD; pgd++, i++) {
- vaddr = i*PGDIR_SIZE;
- if (end && (vaddr >= end))
- break;
+ for (; i < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, i++) {
#if CONFIG_X86_PAE
pmd = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
- set_pgd(pgd, __pgd(__pa(pmd) + 0x1));
+ set_pgd(pgd, __pgd(__pa(pmd) | _PAGE_PRESENT));
#else
- pmd = (pmd_t *)pgd;
+ pmd = (pmd_t *) pgd;
#endif
- if (pmd != pmd_offset(pgd, 0))
- BUG();
- for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
- vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
- if (end && (vaddr >= end))
- break;
+ for (j = 0; j < PTRS_PER_PMD && pfn < max_low_pfn; pmd++, j++) {
if (cpu_has_pse) {
- set_pmd(pmd, pfn_pmd(__pa(vaddr) >> PAGE_SHIFT, PAGE_KERNEL_LARGE));
- continue;
- }
+ set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE));
+ pfn += PTRS_PER_PTE;
+ } else {
+ pte_base = pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
- pte_base = pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
+ for (k = 0; k < PTRS_PER_PTE && pfn < max_low_pfn; pte++, pfn++, k++)
+ set_pte(pte, pfn_pte(pfn, PAGE_KERNEL));
- for (k = 0; k < PTRS_PER_PTE; pte++, k++) {
- vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE;
- if (end && (vaddr >= end))
- break;
- *pte = pfn_pte(__pa(vaddr) >> PAGE_SHIFT, PAGE_KERNEL);
+ set_pmd(pmd, __pmd(__pa(pte_base) | _KERNPG_TABLE));
}
- set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte_base)));
- if (pte_base != pte_offset_kernel(pmd, 0))
- BUG();
-
}
}
reply other threads:[~2002-05-25 15:21 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=3CEFAB1F.102@didntduck.org \
--to=bgerst@didntduck.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.