* [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support
@ 2015-09-04 16:04 Yury Norov
2015-09-04 16:36 ` David Daney
2015-09-04 16:40 ` Suzuki K. Poulose
0 siblings, 2 replies; 6+ messages in thread
From: Yury Norov @ 2015-09-04 16:04 UTC (permalink / raw)
To: linux-arm-kernel
This patch is on top of https://lkml.org/lkml/2015/9/2/413
In master, there's only a single function -
update_mixed_endian_el0_support
And similar function is on review mentioned above.
The algorithm for them is like this:
- there's system-wide boolean marker for the feature that is
initially enabled;
- there's also updater for the feature that may disable it
system-widely if feature is not supported on current CPU.
- updater is called for each CPU on bootup.
The problem is the way updater does its work. On each CPU, it
unconditionally updates system-wide marker. For multi-core
system it makes CPU issue invalidate message for a cache
line containing marker. This invalidate increases cache
contention for nothing, because there's a single marker reset
that is really needed, and the others are useless.
If the number of system-wide markers of this sort will grow,
it may become a trouble on large-scale SOCs. The fix is trivial,
though: do system-wide marker update conditionally, and preserve
corresponding cache line in shared state for all update() calls,
except, probably, one.
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
arch/arm64/kernel/cpuinfo.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index 4a6ae31..9972c1e 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -87,12 +87,14 @@ bool system_supports_aarch32_el0(void)
static void update_mixed_endian_el0_support(struct cpuinfo_arm64 *info)
{
- mixed_endian_el0 &= id_aa64mmfr0_mixed_endian_el0(info->reg_id_aa64mmfr0);
+ if (mixed_endian_el0 && !id_aa64mmfr0_mixed_endian_el0(info->reg_id_aa64mmfr0))
+ mixed_endian_el0 = false;
}
static void update_aarch32_el0_support(struct cpuinfo_arm64 *info)
{
- aarch32_el0 &= id_aa64pfr0_aarch32_el0(info->reg_id_aa64pfr0);
+ if (aarch32_el0 && !id_aa64pfr0_aarch32_el0(info->reg_id_aa64pfr0))
+ aarch32_el0 = false;
}
static void update_cpu_features(struct cpuinfo_arm64 *info)
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support
2015-09-04 16:04 [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support Yury Norov
@ 2015-09-04 16:36 ` David Daney
2015-09-07 8:56 ` Catalin Marinas
2015-09-04 16:40 ` Suzuki K. Poulose
1 sibling, 1 reply; 6+ messages in thread
From: David Daney @ 2015-09-04 16:36 UTC (permalink / raw)
To: linux-arm-kernel
On 09/04/2015 09:04 AM, Yury Norov wrote:
> This patch is on top of https://lkml.org/lkml/2015/9/2/413
>
> In master, there's only a single function -
> update_mixed_endian_el0_support
> And similar function is on review mentioned above.
>
> The algorithm for them is like this:
> - there's system-wide boolean marker for the feature that is
> initially enabled;
> - there's also updater for the feature that may disable it
> system-widely if feature is not supported on current CPU.
> - updater is called for each CPU on bootup.
>
> The problem is the way updater does its work. On each CPU, it
> unconditionally updates system-wide marker. For multi-core
> system it makes CPU issue invalidate message for a cache
> line containing marker. This invalidate increases cache
> contention for nothing, because there's a single marker reset
> that is really needed, and the others are useless.
>
> If the number of system-wide markers of this sort will grow,
> it may become a trouble on large-scale SOCs. The fix is trivial,
> though: do system-wide marker update conditionally, and preserve
> corresponding cache line in shared state for all update() calls,
> except, probably, one.
>
> Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
> ---
> arch/arm64/kernel/cpuinfo.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> index 4a6ae31..9972c1e 100644
> --- a/arch/arm64/kernel/cpuinfo.c
> +++ b/arch/arm64/kernel/cpuinfo.c
> @@ -87,12 +87,14 @@ bool system_supports_aarch32_el0(void)
>
> static void update_mixed_endian_el0_support(struct cpuinfo_arm64 *info)
> {
> - mixed_endian_el0 &= id_aa64mmfr0_mixed_endian_el0(info->reg_id_aa64mmfr0);
> + if (mixed_endian_el0 && !id_aa64mmfr0_mixed_endian_el0(info->reg_id_aa64mmfr0))
> + mixed_endian_el0 = false;
> }
>
> static void update_aarch32_el0_support(struct cpuinfo_arm64 *info)
> {
> - aarch32_el0 &= id_aa64pfr0_aarch32_el0(info->reg_id_aa64pfr0);
> + if (aarch32_el0 && !id_aa64pfr0_aarch32_el0(info->reg_id_aa64pfr0))
> + aarch32_el0 = false;
> }
>
How many times in the lifetime of the kernel are these functions called?
If it is just done at startup, then there is no "steady state"
performance impact, and the burden of complicating the code may not be
worthwhile.
David Daney
> static void update_cpu_features(struct cpuinfo_arm64 *info)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support
2015-09-04 16:36 ` David Daney
@ 2015-09-07 8:56 ` Catalin Marinas
0 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2015-09-07 8:56 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Sep 04, 2015 at 09:36:06AM -0700, David Daney wrote:
> On 09/04/2015 09:04 AM, Yury Norov wrote:
> >This patch is on top of https://lkml.org/lkml/2015/9/2/413
> >
> >In master, there's only a single function -
> > update_mixed_endian_el0_support
> >And similar function is on review mentioned above.
> >
> >The algorithm for them is like this:
> > - there's system-wide boolean marker for the feature that is
> > initially enabled;
> > - there's also updater for the feature that may disable it
> > system-widely if feature is not supported on current CPU.
> > - updater is called for each CPU on bootup.
> >
> >The problem is the way updater does its work. On each CPU, it
> >unconditionally updates system-wide marker. For multi-core
> >system it makes CPU issue invalidate message for a cache
> >line containing marker. This invalidate increases cache
> >contention for nothing, because there's a single marker reset
> >that is really needed, and the others are useless.
> >
> >If the number of system-wide markers of this sort will grow,
> >it may become a trouble on large-scale SOCs. The fix is trivial,
> >though: do system-wide marker update conditionally, and preserve
> >corresponding cache line in shared state for all update() calls,
> >except, probably, one.
> >
> >Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
> >---
> > arch/arm64/kernel/cpuinfo.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> >diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> >index 4a6ae31..9972c1e 100644
> >--- a/arch/arm64/kernel/cpuinfo.c
> >+++ b/arch/arm64/kernel/cpuinfo.c
> >@@ -87,12 +87,14 @@ bool system_supports_aarch32_el0(void)
> >
> > static void update_mixed_endian_el0_support(struct cpuinfo_arm64 *info)
> > {
> >- mixed_endian_el0 &= id_aa64mmfr0_mixed_endian_el0(info->reg_id_aa64mmfr0);
> >+ if (mixed_endian_el0 && !id_aa64mmfr0_mixed_endian_el0(info->reg_id_aa64mmfr0))
> >+ mixed_endian_el0 = false;
> > }
> >
> > static void update_aarch32_el0_support(struct cpuinfo_arm64 *info)
> > {
> >- aarch32_el0 &= id_aa64pfr0_aarch32_el0(info->reg_id_aa64pfr0);
> >+ if (aarch32_el0 && !id_aa64pfr0_aarch32_el0(info->reg_id_aa64pfr0))
> >+ aarch32_el0 = false;
> > }
>
> How many times in the lifetime of the kernel are these functions called?
>
> If it is just done at startup, then there is no "steady state" performance
> impact, and the burden of complicating the code may not be worthwhile.
I fully agree. Unless the code is on some hot path, I really don't care
about few cycles potentially saved during boot.
And in general, with any such micro optimisations, I want to see
benchmark results to prove it worth.
--
Catalin
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support
2015-09-04 16:04 [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support Yury Norov
2015-09-04 16:36 ` David Daney
@ 2015-09-04 16:40 ` Suzuki K. Poulose
2015-09-04 19:52 ` Yury Norov
1 sibling, 1 reply; 6+ messages in thread
From: Suzuki K. Poulose @ 2015-09-04 16:40 UTC (permalink / raw)
To: linux-arm-kernel
On 04/09/15 17:04, Yury Norov wrote:
> This patch is on top of https://lkml.org/lkml/2015/9/2/413
>
> In master, there's only a single function -
> update_mixed_endian_el0_support
> And similar function is on review mentioned above.
>
> The algorithm for them is like this:
> - there's system-wide boolean marker for the feature that is
> initially enabled;
> - there's also updater for the feature that may disable it
> system-widely if feature is not supported on current CPU.
> - updater is called for each CPU on bootup.
>
> The problem is the way updater does its work. On each CPU, it
> unconditionally updates system-wide marker. For multi-core
> system it makes CPU issue invalidate message for a cache
> line containing marker. This invalidate increases cache
> contention for nothing, because there's a single marker reset
> that is really needed, and the others are useless.
>
> If the number of system-wide markers of this sort will grow,
> it may become a trouble on large-scale SOCs. The fix is trivial,
> though: do system-wide marker update conditionally, and preserve
> corresponding cache line in shared state for all update() calls,
> except, probably, one.
As I have mentioned already, this patch (and the per feature functions)
won't be needed once we merge my series (which is waiting for the merge
window to see the public lights)
Cheers
Suzuki
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support
2015-09-04 16:40 ` Suzuki K. Poulose
@ 2015-09-04 19:52 ` Yury Norov
2015-09-16 14:49 ` Suzuki K. Poulose
0 siblings, 1 reply; 6+ messages in thread
From: Yury Norov @ 2015-09-04 19:52 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Sep 04, 2015 at 05:40:57PM +0100, Suzuki K. Poulose wrote:
> On 04/09/15 17:04, Yury Norov wrote:
> >This patch is on top of https://lkml.org/lkml/2015/9/2/413
> >
> >In master, there's only a single function -
> > update_mixed_endian_el0_support
> >And similar function is on review mentioned above.
> >
> >The algorithm for them is like this:
> > - there's system-wide boolean marker for the feature that is
> > initially enabled;
> > - there's also updater for the feature that may disable it
> > system-widely if feature is not supported on current CPU.
> > - updater is called for each CPU on bootup.
> >
> >The problem is the way updater does its work. On each CPU, it
> >unconditionally updates system-wide marker. For multi-core
> >system it makes CPU issue invalidate message for a cache
> >line containing marker. This invalidate increases cache
> >contention for nothing, because there's a single marker reset
> >that is really needed, and the others are useless.
> >
> >If the number of system-wide markers of this sort will grow,
> >it may become a trouble on large-scale SOCs. The fix is trivial,
> >though: do system-wide marker update conditionally, and preserve
> >corresponding cache line in shared state for all update() calls,
> >except, probably, one.
>
> As I have mentioned already, this patch (and the per feature functions)
> won't be needed once we merge my series (which is waiting for the merge
> window to see the public lights)
>
OK. Than waiting for your patchset.
BR,
Yury
> Cheers
> Suzuki
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support
2015-09-04 19:52 ` Yury Norov
@ 2015-09-16 14:49 ` Suzuki K. Poulose
0 siblings, 0 replies; 6+ messages in thread
From: Suzuki K. Poulose @ 2015-09-16 14:49 UTC (permalink / raw)
To: linux-arm-kernel
On 04/09/15 20:52, Yury Norov wrote:
> On Fri, Sep 04, 2015 at 05:40:57PM +0100, Suzuki K. Poulose wrote:
>> On 04/09/15 17:04, Yury Norov wrote:
>>> This patch is on top of https://lkml.org/lkml/2015/9/2/413
>>>
>>> In master, there's only a single function -
>>> update_mixed_endian_el0_support
>>> And similar function is on review mentioned above.
>>>
>>> The algorithm for them is like this:
>>> - there's system-wide boolean marker for the feature that is
>>> initially enabled;
>>> - there's also updater for the feature that may disable it
>>> system-widely if feature is not supported on current CPU.
>>> - updater is called for each CPU on bootup.
>>>
>>> The problem is the way updater does its work. On each CPU, it
>>> unconditionally updates system-wide marker. For multi-core
>>> system it makes CPU issue invalidate message for a cache
>>> line containing marker. This invalidate increases cache
>>> contention for nothing, because there's a single marker reset
>>> that is really needed, and the others are useless.
>>>
>>> If the number of system-wide markers of this sort will grow,
>>> it may become a trouble on large-scale SOCs. The fix is trivial,
>>> though: do system-wide marker update conditionally, and preserve
>>> corresponding cache line in shared state for all update() calls,
>>> except, probably, one.
>>
>> As I have mentioned already, this patch (and the per feature functions)
>> won't be needed once we merge my series (which is waiting for the merge
>> window to see the public lights)
>>
>
> OK. Than waiting for your patchset.
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-September/370386.html
Cheers
Suzuki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-09-16 14:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-04 16:04 [RFC PATCH] arm64: cpuinfo: reduce cache contention on update_{feature}_support Yury Norov
2015-09-04 16:36 ` David Daney
2015-09-07 8:56 ` Catalin Marinas
2015-09-04 16:40 ` Suzuki K. Poulose
2015-09-04 19:52 ` Yury Norov
2015-09-16 14:49 ` Suzuki K. Poulose
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).