Re: Linux kernel, possible useless continue



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.


(B) for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
pmd = one_md_table_init(pgd);
if (pfn >= max_low_pfn)
(A) continue;

[...]

Other than that, Iwo Mergler's comment that one_md_table_init() is called
with the next index indeed applies,

And this routine is documented by the following comment (and the code,
of course):

/*
* Creates a middle page table and puts a pointer to it in the
* given global directory entry. This only returns the gd entry
* in non-PAE compilation mode, since the middle layer is folded.
*/

Which means that the loop in questions populates all of the pmd (if a
pmd is in use) and maps at most max_low_pfn pages of memory directly
for use by the kernel.
.