Linux kernel, possible useless continue



2.6.20, arch/i386/mm/init.c

Below code I am curious in (A)'s continue will bring flow to (B) but
from (B) to (A) no code updates the value of both pfn and max_low_pfn.
So the condition of 'if' will always true. Is it useless?

static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
{
unsigned long pfn;
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte;
int pgd_idx, pmd_idx, pte_ofs;

pgd_idx = pgd_index(PAGE_OFFSET);
pgd = pgd_base + pgd_idx;
pfn = 0;

(B) for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
pmd = one_md_table_init(pgd);
if (pfn >= max_low_pfn)
(A) continue;
for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD && pfn < max_low_pfn; pmd+
+, pmd_idx++) {
unsigned int address = pfn * PAGE_SIZE + PAGE_OFFSET;

/* Map with big pages if possible, otherwise create normal page
tables. */
if (cpu_has_pse) {
unsigned int address2 = (pfn + PTRS_PER_PTE - 1) * PAGE_SIZE +
PAGE_OFFSET + PAGE_SIZE-1;

if (is_kernel_text(address) || is_kernel_text(address2))
set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE_EXEC));
else
set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE));
pfn += PTRS_PER_PTE;
} else {
pte = one_page_table_init(pmd);

for (pte_ofs = 0; pte_ofs < PTRS_PER_PTE && pfn < max_low_pfn; pte+
+, pfn++, pte_ofs++) {
if (is_kernel_text(address))
set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC));
else
set_pte(pte, pfn_pte(pfn, PAGE_KERNEL));
}
}
}
}
}

.



Relevant Pages

  • Re: Linux kernel, possible useless continue
    ... Below code I am curious in 's continue will bring flow to but ... from to no code updates the value of both pfn and max_low_pfn. ... Kind regards, ...
    (comp.os.linux.development.system)
  • Re: [patch 3/3] mm: fault handler to replace nopage and populate
    ... backup memory) or map it directly to hardware. ... PROT_WRITE mappings, I trust that isn't a problem for you? ... unsigned long pfn, unsigned long size, pgprot_t); ... * they've allocated into a user vma. ...
    (Linux-Kernel)
  • [patch 4/5] mm: add vm_insert_pfn helpler
    ... unsigned long pfn, unsigned long size, pgprot_t); ... unsigned int foll_flags); ... user vma to map to ... * they've allocated into a user vma. ...
    (Linux-Kernel)
  • [patch 4/5] mm: add vm_insert_pfn helpler
    ... unsigned long pfn, unsigned long size, pgprot_t); ... unsigned int foll_flags); ... user vma to map to ... * they've allocated into a user vma. ...
    (Linux-Kernel)
  • [patch 5/7] mm: add vm_insert_pfn
    ... unsigned long pfn, unsigned long size, pgprot_t); ... unsigned int foll_flags); ... user vma to map to ... * they've allocated into a user vma. ...
    (Linux-Kernel)