From: "H. Peter Anvin" <hpa@zytor.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Lin Feng <linfeng@cn.fujitsu.com>,
akpm@linux-foundation.org, linux-mm@kvack.org, x86@kernel.org,
linux-kernel@vger.kernel.org, tglx@linutronix.de,
mingo@redhat.com, penberg@kernel.org, jacob.shin@amd.com
Subject: Re: [PATCH] x86: mm: accurate the comments for STEP_SIZE_SHIFT macro
Date: Mon, 18 Mar 2013 11:59:14 -0700 [thread overview]
Message-ID: <51476402.7050102@zytor.com> (raw)
In-Reply-To: <CAE9FiQWuSL5Vq5VaAvQg_NT2gQJr17eMNoQbxtNJ8G3wweWNHQ@mail.gmail.com>
On 03/18/2013 11:53 AM, Yinghai Lu wrote:
> On Mon, Mar 18, 2013 at 3:21 AM, Lin Feng <linfeng@cn.fujitsu.com> wrote:
>> For x86 PUD_SHIFT is 30 and PMD_SHIFT is 21, so the consequence of
>> (PUD_SHIFT-PMD_SHIFT)/2 is 4. Update the comments to the code.
>>
>> Cc: Yinghai Lu <yinghai@kernel.org>
>> Signed-off-by: Lin Feng <linfeng@cn.fujitsu.com>
>> ---
>> arch/x86/mm/init.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
>> index 59b7fc4..637a95b 100644
>> --- a/arch/x86/mm/init.c
>> +++ b/arch/x86/mm/init.c
>> @@ -389,7 +389,7 @@ static unsigned long __init init_range_memory_mapping(
>> return mapped_ram_size;
>> }
>>
>> -/* (PUD_SHIFT-PMD_SHIFT)/2 */
>> +/* (PUD_SHIFT-PMD_SHIFT)/2+1 */
>> #define STEP_SIZE_SHIFT 5
>> void __init init_mem_mapping(void)
>> {
>
> 9/2=4.5, so it becomes 5.
>
No, it doesn't. This is C, not elementary school Now I'm really bothered.
The comment doesn't say *why* (PUD_SHIFT-PMD_SHIFT)/2 or any other
variant is correct, furthermore I suspect that the +1 is misplaced.
However, what is really needed is:
1. Someone needs to explain what the logic should be and why, and
2. replace the macro with a symbolic macro, not with a constant and a
comment explaining, incorrectly, how that value was derived.
-hpa
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-03-18 18:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-18 10:21 Lin Feng
2013-03-18 18:53 ` Yinghai Lu
2013-03-18 18:59 ` H. Peter Anvin [this message]
2013-03-18 19:13 ` Yinghai Lu
2013-03-18 19:14 ` H. Peter Anvin
2013-03-18 21:19 ` Yinghai Lu
2013-03-18 22:50 ` H. Peter Anvin
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=51476402.7050102@zytor.com \
--to=hpa@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=jacob.shin@amd.com \
--cc=linfeng@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=penberg@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yinghai@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