Re: Linux kernel, possible useless continue
- From: Rainer Weikusat <rainer.weikusat@xxxxxxxxx>
- Date: Mon, 19 Mar 2007 15:58:00 +0100
Ulrich Eckhardt <doomster@xxxxxxxx> writes:
Rainer Weikusat wrote:
Ulrich Eckhardt <doomster@xxxxxxxx> writes:
Bin Chen wrote:
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?
Yes it is useless.
It is not, see below.
I'm not convinced yet, let's get this cleared up. ;)
(B) for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
pmd = one_md_table_init(pgd);
if (pfn >= max_low_pfn)
(A) continue;
You removed an important part here, the inner loop:
for (pmd_idx = 0;^^^^^^^^^^^^^^^^^
pmd_idx < PTRS_PER_PMD && pfn < max_low_pfn;
pmd++, pmd_idx++) {
The requirement 'pfn >= max_low_pfn' for the continue is the opposite of
the one used in the loop, 'pfn < max_low_pfn'. So, if the first comparison
is true, the continue skips the inner loop, because it's all that is left
in the outer loop.
Exactly. The outer loop loops over all entries in the top-level page
directory. It calls 'one_md_table_init' for each one, thereby
populating all 'page middle directory' tables, insofar a pmd is
actually used (when doing PAE). Additionally, it contains another loop
which maps the first 'max_low_pfn' pages into the 'active' address
space. After max_low_pfn pages have been mapped, the second loop shouldn't
run anymore, but the remaining pmds should still get populated. Hence
the continue, which skips over the inner loop after the pmd associated
with the current values of pgd has been initialized.
.
- Follow-Ups:
- Re: Linux kernel, possible useless continue
- From: Rainer Weikusat
- Re: Linux kernel, possible useless continue
- References:
- Linux kernel, possible useless continue
- From: Bin Chen
- Re: Linux kernel, possible useless continue
- From: Ulrich Eckhardt
- Re: Linux kernel, possible useless continue
- From: Rainer Weikusat
- Re: Linux kernel, possible useless continue
- From: Ulrich Eckhardt
- Linux kernel, possible useless continue
- Prev by Date: Re: Linux kernel, possible useless continue
- Next by Date: Re: Linux kernel, possible useless continue
- Previous by thread: Re: Linux kernel, possible useless continue
- Next by thread: Re: Linux kernel, possible useless continue
- Index(es):
Relevant Pages
|