From: Wei Yang <richardw.yang@linux.intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Wei Yang <richardw.yang@linux.intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
dave.hansen@linux.intel.com, luto@kernel.org,
peterz@infradead.or
Subject: Re: [PATCH 4/6] x86, mm: make split_mem_range() more easy to read
Date: Thu, 28 Mar 2019 15:20:27 +0800 [thread overview]
Message-ID: <20190328072027.GA6531@richard> (raw)
In-Reply-To: <alpine.DEB.2.21.1903232345500.1798@nanos.tec.linutronix.de>
On Sun, Mar 24, 2019 at 03:29:04PM +0100, Thomas Gleixner wrote:
>
>+static int __meminit split_mem_range(struct map_range *mr, unsigned long start,
>+ unsigned long end)
>+{
>+ static const struct mapinfo mapinfos[] = {
> #ifdef CONFIG_X86_64
>+ { .mask = 1U << PG_LEVEL_1G, .size = PUD_SIZE },
> #endif
>+ { .mask = 1U << PG_LEVEL_2M, .size = PMD_SIZE },
>+ { .mask = 0, .size = PAGE_SIZE },
>+ };
>+ const struct mapinfo *mi;
>+ struct map_range *curmr;
>+ unsigned long addr;
>+ int idx;
>+
>+ for (idx = 0, addr = start, curmr = mr; addr < end; idx++, curmr++) {
>+ BUG_ON(idx == NR_RANGE_MR);
>+ mr_setup(curmr, addr, end);
>
>+ /* Try map sizes top down. PAGE_SIZE will always succeed. */
>+ for (mi = mapinfos; !mr_try_map(curmr, mi); mi++);
>
>+ /* Get the start address for the next range */
>+ addr = curmr->end;
> }
I re-arrange the code to make split_mem_range() here easy to read.
My question is to the for loop.
For example, we have a range
+--+---------+-----------------------+
^ 128M 1G 2G
128M - 4K
If my understanding is correct, the original behavior will split this into
three ranges:
4K size: [128M - 4K, 128M]
2M size: [128M, 1G]
1G size: [1G, 2G]
While after your change, it will split this into two ranges:
?? size: [128M - 4K, 1G]
2M size: [1G, 2G]
The question mark here is because you leave the page_size_mask unchanged in
this case.
Is my understanding correct? Or I missed something?
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2019-03-28 7:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 2:12 [PATCH 0/6] x86, mm: refine split_mem_range a little Wei Yang
2019-02-12 2:12 ` [PATCH 1/6] x86, mm: remove second argument of split_mem_range() Wei Yang
2019-03-24 14:38 ` Thomas Gleixner
2019-03-25 1:16 ` Wei Yang
2019-02-12 2:12 ` [PATCH 2/6] x86, mm: remove check in save_mr Wei Yang
2019-02-12 2:12 ` [PATCH 3/6] x86, mm: add comment for split_mem_range to help understanding Wei Yang
2019-02-12 2:12 ` [PATCH 4/6] x86, mm: make split_mem_range() more easy to read Wei Yang
2019-03-24 14:29 ` Thomas Gleixner
2019-03-27 22:05 ` Wei Yang
2019-03-28 0:16 ` Thomas Gleixner
2019-03-28 0:25 ` Wei Yang
2019-03-28 3:35 ` Wei Yang
2019-03-28 7:20 ` Wei Yang [this message]
2019-03-28 8:08 ` Thomas Gleixner
2019-03-29 3:38 ` Wei Yang
[not found] ` <20190328065117.GA6202@richard>
2019-03-28 8:02 ` Thomas Gleixner
2019-04-12 3:08 ` Wei Yang
2019-02-12 2:12 ` [PATCH 5/6] x86, mm: skip 1G range if the range doesn't span PUD Wei Yang
2019-02-12 2:12 ` [PATCH 6/6] x86, mm: x86, mm: jump to split only 4K range when range doesn't span PMD Wei Yang
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=20190328072027.GA6531@richard \
--to=richardw.yang@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.or \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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