From: slash.tmp@free.fr (Mason)
To: linux-arm-kernel@lists.infradead.org
Subject: read_cpuid_id() in arch/arm/kernel/setup.c
Date: Fri, 13 Mar 2015 18:06:54 +0100 [thread overview]
Message-ID: <5503192E.7070704@free.fr> (raw)
In-Reply-To: <20150313164546.GV8656@n2100.arm.linux.org.uk>
On 13/03/2015 17:45, Russell King - ARM Linux wrote:
> On Fri, Mar 13, 2015 at 05:39:23PM +0100, Mason wrote:
>> Good point. I hadn't thought of that.
>>
>> Do you know the latency of an mrc instruction? (compared to a mov)
>
> Not offhand. It'll be different for different CPUs, but it's probably
> not far off mov.
>
>>> It seems that GCC 4.7.4 optimises better than Linaro's 4.9.3. In fact,
>>> it looks like Linaro's 4.9.3 is rather buggy as far as optimisation
>>> goes.
>>>
>>> Later compilers aren't always better.
>>
>> I did NOT expect that. Compiler optimizations passes are so fragile.
>
> You're learning :)
>
>> Anyway, here's another proposed nano-improvement ;-)
>> (This one is code factorization)
>>
>> --- setup.c 2015-03-03 18:04:59.000000000 +0100
>> +++ setup.bar.c 2015-03-13 17:29:23.800668429 +0100
>> @@ -246,12 +246,9 @@
>> if (cpu_arch)
>> cpu_arch += CPU_ARCH_ARMv3;
>> } else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) {
>> - unsigned int mmfr0;
>> -
>> /* Revised CPUID format. Read the Memory Model Feature
>> * Register 0 and check for VMSAv7 or PMSAv7 */
>> - asm("mrc p15, 0, %0, c0, c1, 4"
>> - : "=r" (mmfr0));
>> + unsigned int mmfr0 = read_cpuid_ext(CPUID_EXT_MMFR0);
>> if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
>> (mmfr0 & 0x000000f0) >= 0x00000030)
>> cpu_arch = CPU_ARCH_ARMv7;
>>
>>
>> This one looks good, doesn't it? :-)
>
> Yes, this one I like - and it probably fixes a potential latent bug
> where the compiler was free to re-order that mrc outside of the if()
> statement.
>
> Please wrap it up as a normal submission, thanks.
How exciting, my first kernel patch :-)
I'll take a closer look at other similar refactoring opportunities.
Can I send the patch inline, with "scissors and perforation" delimiter?
Do I have to base it on the latest 4.0 release candidate, or can you
rebase it as needed?
Also, you didn't like "caching" the value of read_cpuid_id() in
a local variable, but it's done in feat_v6_fixup. Do you want me
to submit a patch changing that, or is it not worth it?
Regards.
next prev parent reply other threads:[~2015-03-13 17:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 16:03 read_cpuid_id() in arch/arm/kernel/setup.c Mason
2015-03-13 16:19 ` Russell King - ARM Linux
2015-03-13 16:39 ` Mason
2015-03-13 16:45 ` Russell King - ARM Linux
2015-03-13 17:06 ` Mason [this message]
2015-03-15 17:40 ` Mason
2015-03-16 8:44 ` Mason
2015-03-16 16:54 ` Paul Walmsley
2015-03-16 22:17 ` Mason
2015-03-16 23:30 ` Mason
2015-03-13 16:56 ` Mark Rutland
2015-03-13 17:02 ` Russell King - ARM Linux
2015-03-13 18:26 ` Mark Rutland
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=5503192E.7070704@free.fr \
--to=slash.tmp@free.fr \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).