* [PATCH v2] powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units.
@ 2019-06-10 6:32 Anju T Sudhakar
2019-06-10 18:47 ` Leonardo Bras
2019-06-30 8:37 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Anju T Sudhakar @ 2019-06-10 6:32 UTC (permalink / raw)
To: mpe; +Cc: ego, anju, linuxppc-dev, maddy
Nest and core imc(In-memory Collection counters) assigns a particular
cpu as the designated target for counter data collection.
During system boot, the first online cpu in a chip gets assigned as
the designated cpu for that chip(for nest-imc) and the first online cpu
in a core gets assigned as the designated cpu for that core(for core-imc).
If the designated cpu goes offline, the next online cpu from the same
chip(for nest-imc)/core(for core-imc) is assigned as the next target,
and the event context is migrated to the target cpu.
Currently, cpumask_any_but() function is used to find the target cpu.
Though this function is expected to return a `random` cpu, this always
returns the next online cpu.
If all cpus in a chip/core is offlined in a sequential manner, starting
from the first cpu, the event migration has to happen for all the cpus
which goes offline. Since the migration process involves a grace period,
the total time taken to offline all the cpus will be significantly high.
Example:
In a system which has 2 sockets, with
NUMA node0 CPU(s): 0-87
NUMA node8 CPU(s): 88-175
Time taken to offline cpu 88-175:
real 2m56.099s
user 0m0.191s
sys 0m0.000s
Use cpumask_last() to choose the target cpu, when the designated cpu
goes online, so the migration will happen only when the last_cpu in the
mask goes offline. This way the time taken to offline all cpus in a
chip/core can be reduced.
With the patch,
Time taken to offline cpu 88-175:
real 0m12.207s
user 0m0.171s
sys 0m0.000s
Offlining all cpus in reverse order is also taken care because,
cpumask_any_but() is used to find the designated cpu if the last cpu in
the mask goes offline. Since cpumask_any_but() always return the first
cpu in the mask, that becomes the designated cpu and migration will happen
only when the first_cpu in the mask goes offline.
Example:
With the patch,
Time taken to offline cpu from 175-88:
real 0m9.330s
user 0m0.110s
sys 0m0.000s
Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Reviewed-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
Changes from v1:
Modified the commit log with more info.
---
arch/powerpc/perf/imc-pmu.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index 31fa753..fbfd6e7 100644
--- a/arch/powerpc/perf/imc-pmu.c
+++ b/arch/powerpc/perf/imc-pmu.c
@@ -366,7 +366,14 @@ static int ppc_nest_imc_cpu_offline(unsigned int cpu)
*/
nid = cpu_to_node(cpu);
l_cpumask = cpumask_of_node(nid);
- target = cpumask_any_but(l_cpumask, cpu);
+ target = cpumask_last(l_cpumask);
+
+ /*
+ * If this(target) is the last cpu in the cpumask for this chip,
+ * check for any possible online cpu in the chip.
+ */
+ if (unlikely(target == cpu))
+ target = cpumask_any_but(l_cpumask, cpu);
/*
* Update the cpumask with the target cpu and
@@ -671,7 +678,10 @@ static int ppc_core_imc_cpu_offline(unsigned int cpu)
return 0;
/* Find any online cpu in that core except the current "cpu" */
- ncpu = cpumask_any_but(cpu_sibling_mask(cpu), cpu);
+ ncpu = cpumask_last(cpu_sibling_mask(cpu));
+
+ if (unlikely(ncpu == cpu))
+ ncpu = cpumask_any_but(cpu_sibling_mask(cpu), cpu);
if (ncpu >= 0 && ncpu < nr_cpu_ids) {
cpumask_set_cpu(ncpu, &core_imc_cpumask);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units.
2019-06-10 6:32 [PATCH v2] powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units Anju T Sudhakar
@ 2019-06-10 18:47 ` Leonardo Bras
2019-06-12 5:58 ` Anju T Sudhakar
2019-06-30 8:37 ` Michael Ellerman
1 sibling, 1 reply; 4+ messages in thread
From: Leonardo Bras @ 2019-06-10 18:47 UTC (permalink / raw)
To: Anju T Sudhakar, mpe; +Cc: ego, maddy, linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 3817 bytes --]
On Mon, 2019-06-10 at 12:02 +0530, Anju T Sudhakar wrote:
> Nest and core imc(In-memory Collection counters) assigns a particular
> cpu as the designated target for counter data collection.
> During system boot, the first online cpu in a chip gets assigned as
> the designated cpu for that chip(for nest-imc) and the first online cpu
> in a core gets assigned as the designated cpu for that core(for core-imc).
>
> If the designated cpu goes offline, the next online cpu from the same
> chip(for nest-imc)/core(for core-imc) is assigned as the next target,
> and the event context is migrated to the target cpu.
> Currently, cpumask_any_but() function is used to find the target cpu.
> Though this function is expected to return a `random` cpu, this always
> returns the next online cpu.
>
> If all cpus in a chip/core is offlined in a sequential manner, starting
> from the first cpu, the event migration has to happen for all the cpus
> which goes offline. Since the migration process involves a grace period,
> the total time taken to offline all the cpus will be significantly high.
>
> Example:
> In a system which has 2 sockets, with
> NUMA node0 CPU(s): 0-87
> NUMA node8 CPU(s): 88-175
>
> Time taken to offline cpu 88-175:
> real 2m56.099s
> user 0m0.191s
> sys 0m0.000s
>
> Use cpumask_last() to choose the target cpu, when the designated cpu
> goes online, so the migration will happen only when the last_cpu in the
> mask goes offline. This way the time taken to offline all cpus in a
> chip/core can be reduced.
>
> With the patch,
>
> Time taken to offline cpu 88-175:
> real 0m12.207s
> user 0m0.171s
> sys 0m0.000s
>
>
> Offlining all cpus in reverse order is also taken care because,
> cpumask_any_but() is used to find the designated cpu if the last cpu in
> the mask goes offline. Since cpumask_any_but() always return the first
> cpu in the mask, that becomes the designated cpu and migration will happen
> only when the first_cpu in the mask goes offline.
>
> Example:
> With the patch,
>
> Time taken to offline cpu from 175-88:
> real 0m9.330s
> user 0m0.110s
> sys 0m0.000s
Seems like a very interesting work.
Out of curiosity, have you used 'chcpu -d' to create your benchmark?
>
> Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
> Reviewed-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> ---
>
> Changes from v1:
> Modified the commit log with more info.
> ---
>
> arch/powerpc/perf/imc-pmu.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
> index 31fa753..fbfd6e7 100644
> --- a/arch/powerpc/perf/imc-pmu.c
> +++ b/arch/powerpc/perf/imc-pmu.c
> @@ -366,7 +366,14 @@ static int ppc_nest_imc_cpu_offline(unsigned int cpu)
> */
> nid = cpu_to_node(cpu);
> l_cpumask = cpumask_of_node(nid);
> - target = cpumask_any_but(l_cpumask, cpu);
> + target = cpumask_last(l_cpumask);
> +
> + /*
> + * If this(target) is the last cpu in the cpumask for this chip,
> + * check for any possible online cpu in the chip.
> + */
> + if (unlikely(target == cpu))
> + target = cpumask_any_but(l_cpumask, cpu);
>
> /*
> * Update the cpumask with the target cpu and
> @@ -671,7 +678,10 @@ static int ppc_core_imc_cpu_offline(unsigned int cpu)
> return 0;
>
> /* Find any online cpu in that core except the current "cpu" */
> - ncpu = cpumask_any_but(cpu_sibling_mask(cpu), cpu);
> + ncpu = cpumask_last(cpu_sibling_mask(cpu));
> +
> + if (unlikely(ncpu == cpu))
> + ncpu = cpumask_any_but(cpu_sibling_mask(cpu), cpu);
>
> if (ncpu >= 0 && ncpu < nr_cpu_ids) {
> cpumask_set_cpu(ncpu, &core_imc_cpumask);
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units.
2019-06-10 18:47 ` Leonardo Bras
@ 2019-06-12 5:58 ` Anju T Sudhakar
0 siblings, 0 replies; 4+ messages in thread
From: Anju T Sudhakar @ 2019-06-12 5:58 UTC (permalink / raw)
To: Leonardo Bras, mpe; +Cc: ego, maddy, linuxppc-dev
Hi Leonardo,
On 6/11/19 12:17 AM, Leonardo Bras wrote:
> On Mon, 2019-06-10 at 12:02 +0530, Anju T Sudhakar wrote:
>> Nest and core imc(In-memory Collection counters) assigns a particular
>> cpu as the designated target for counter data collection.
>> During system boot, the first online cpu in a chip gets assigned as
>> the designated cpu for that chip(for nest-imc) and the first online cpu
>> in a core gets assigned as the designated cpu for that core(for core-imc).
>>
>> If the designated cpu goes offline, the next online cpu from the same
>> chip(for nest-imc)/core(for core-imc) is assigned as the next target,
>> and the event context is migrated to the target cpu.
>> Currently, cpumask_any_but() function is used to find the target cpu.
>> Though this function is expected to return a `random` cpu, this always
>> returns the next online cpu.
>>
>> If all cpus in a chip/core is offlined in a sequential manner, starting
>> from the first cpu, the event migration has to happen for all the cpus
>> which goes offline. Since the migration process involves a grace period,
>> the total time taken to offline all the cpus will be significantly high.
> Seems like a very interesting work.
> Out of curiosity, have you used 'chcpu -d' to create your benchmark?
Here I did not use chcpu to disable the cpu.
I used a script which will offline cpus 88-175 by echoing `0` to
/sys/devices/system/cpu/cpu*/online.
Regards,
Anju
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units.
2019-06-10 6:32 [PATCH v2] powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units Anju T Sudhakar
2019-06-10 18:47 ` Leonardo Bras
@ 2019-06-30 8:37 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2019-06-30 8:37 UTC (permalink / raw)
To: Anju T Sudhakar; +Cc: ego, anju, linuxppc-dev, maddy
On Mon, 2019-06-10 at 06:32:29 UTC, Anju T Sudhakar wrote:
> Nest and core imc(In-memory Collection counters) assigns a particular
> cpu as the designated target for counter data collection.
> During system boot, the first online cpu in a chip gets assigned as
> the designated cpu for that chip(for nest-imc) and the first online cpu
> in a core gets assigned as the designated cpu for that core(for core-imc).
>
> If the designated cpu goes offline, the next online cpu from the same
> chip(for nest-imc)/core(for core-imc) is assigned as the next target,
> and the event context is migrated to the target cpu.
> Currently, cpumask_any_but() function is used to find the target cpu.
> Though this function is expected to return a `random` cpu, this always
> returns the next online cpu.
>
> If all cpus in a chip/core is offlined in a sequential manner, starting
> from the first cpu, the event migration has to happen for all the cpus
> which goes offline. Since the migration process involves a grace period,
> the total time taken to offline all the cpus will be significantly high.
>
> Example:
> In a system which has 2 sockets, with
> NUMA node0 CPU(s): 0-87
> NUMA node8 CPU(s): 88-175
>
> Time taken to offline cpu 88-175:
> real 2m56.099s
> user 0m0.191s
> sys 0m0.000s
>
> Use cpumask_last() to choose the target cpu, when the designated cpu
> goes online, so the migration will happen only when the last_cpu in the
> mask goes offline. This way the time taken to offline all cpus in a
> chip/core can be reduced.
>
> With the patch,
>
> Time taken to offline cpu 88-175:
> real 0m12.207s
> user 0m0.171s
> sys 0m0.000s
>
>
> Offlining all cpus in reverse order is also taken care because,
> cpumask_any_but() is used to find the designated cpu if the last cpu in
> the mask goes offline. Since cpumask_any_but() always return the first
> cpu in the mask, that becomes the designated cpu and migration will happen
> only when the first_cpu in the mask goes offline.
>
> Example:
> With the patch,
>
> Time taken to offline cpu from 175-88:
> real 0m9.330s
> user 0m0.110s
> sys 0m0.000s
>
> Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
> Reviewed-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/9c9f8fb71feed144973a70455e0a4ee3da57ed2a
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-30 8:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-10 6:32 [PATCH v2] powerpc/perf: Use cpumask_last() to determine the designated cpu for nest/core units Anju T Sudhakar
2019-06-10 18:47 ` Leonardo Bras
2019-06-12 5:58 ` Anju T Sudhakar
2019-06-30 8:37 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.