From: Wei Yang <richard.weiyang@gmail.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: use BITS_PER_LONG to unify the definition in page->flags
Date: Sun, 19 Mar 2017 23:03:45 +0800 [thread overview]
Message-ID: <20170319150345.GA34657@WeideMacBook-Pro.local> (raw)
In-Reply-To: <20170319143012.GB12414@dhcp22.suse.cz>
[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]
On Sun, Mar 19, 2017 at 10:30:13AM -0400, Michal Hocko wrote:
>On Sat 18-03-17 08:39:14, Wei Yang wrote:
>> The field page->flags is defined as unsigned long and is divided into
>> several parts to store different information of the page, like section,
>> node, zone. Which means all parts must sit in the one "unsigned
>> long".
>>
>> BITS_PER_LONG is used in several places to ensure this applies.
>>
>> #if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS
>> #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS
>> #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT+LAST_CPUPID_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS
>>
>> While we use "sizeof(unsigned long) * 8" in the definition of
>> SECTIONS_PGOFF
>>
>> #define SECTIONS_PGOFF ((sizeof(unsigned long)*8) - SECTIONS_WIDTH)
>>
>> This may not be that obvious for audience to catch the point.
>>
>> This patch replaces the "sizeof(unsigned long) * 8" with BITS_PER_LONG to
>> make all this consistent.
>
>I am not really sure this is an improvement. page::flags is unsigned
>long nad the current code reflects that type.
>
Hi, Michal
Glad to hear from you.
I think the purpose of definition BITS_PER_LONG is more easily to let audience
know it is the number of bits of type long. If it has no improvement, we don't
need to define a specific macro .
And as you could see, several related macros use BITS_PER_LONG in their
definition. After this change, all of them will have a consistent definition.
After this change, code looks more neat :-)
So it looks more reasonable to use this.
--
Wei Yang
Help you, Help me
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-03-19 15:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-18 0:39 Wei Yang
2017-03-19 14:30 ` Michal Hocko
2017-03-19 15:03 ` Wei Yang [this message]
2017-03-19 15:08 ` Michal Hocko
2017-03-19 16:05 ` 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=20170319150345.GA34657@WeideMacBook-Pro.local \
--to=richard.weiyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@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