From: David Hildenbrand <david@redhat.com>
To: Kefeng Wang <wangkefeng.wang@huawei.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Cc: Mike Rapoport <rppt@kernel.org>,
Oscar Salvador <osalvador@suse.de>,
linux-kernel@vger.kernel.org, Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH 2/2] mm: add pageblock_aligned() macro
Date: Fri, 2 Sep 2022 10:42:48 +0200 [thread overview]
Message-ID: <e0405abb-d1ea-977b-6d16-859a56bf3027@redhat.com> (raw)
In-Reply-To: <20220902064751.17890-2-wangkefeng.wang@huawei.com>
On 02.09.22 08:47, Kefeng Wang wrote:
> Add pageblock_aligned() and use it to simplify code.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
[...]
> - unsigned long nr_pgmask = pageblock_nr_pages - 1;
> int nid = zone_to_nid(zone);
> unsigned long nr_pages = 0;
> int zid = zone_idx(zone);
> @@ -1977,7 +1974,7 @@ static unsigned long __init deferred_init_pages(struct zone *zone,
> if (!deferred_pfn_valid(pfn)) {
> page = NULL;
> continue;
> - } else if (!page || !(pfn & nr_pgmask)) {
I didn't sleep too well this night and am tired, please tell me why I'm
wrong :)
"pfn & (pageblock_nr_pages - 1)" is true if the pageblock is not aligned
E.g., pfn = 1, pageblock_nr_pages = 512
pfn & (pageblock_nr_pages - 1)
-> 1 & (512 - 1)
-> 1 & 511
-> true
"!(pfn & (pageblock_nr_pages - 1))" is true if the pageblock is aligned
-> !(true)
-> false
However, "!pageblock_aligned(1)" = true
> + } else if (!page || !pageblock_aligned(pfn)) {
So shouldn't this be "pageblock_aligned(pfn)"
?
> page = pfn_to_page(pfn);
> } else {
> page++;
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2022-09-02 8:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 6:47 [PATCH 1/2] mm: reuse pageblock_start/end_pfn() macro Kefeng Wang
2022-09-02 6:47 ` [PATCH 2/2] mm: add pageblock_aligned() macro Kefeng Wang
2022-09-02 8:42 ` David Hildenbrand [this message]
2022-09-02 9:02 ` Kefeng Wang
2022-09-02 9:04 ` David Hildenbrand
2022-09-02 9:39 ` Kefeng Wang
2022-09-02 8:20 ` [PATCH 1/2] mm: reuse pageblock_start/end_pfn() macro David Hildenbrand
2022-09-02 8:48 ` Kefeng Wang
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=e0405abb-d1ea-977b-6d16-859a56bf3027@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=vbabka@suse.cz \
--cc=wangkefeng.wang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox