* [PATCH 1/1] perf/amd: NULL return of kzalloc_node should be handled
@ 2014-06-10 7:37 Zhouyi Zhou
2014-06-10 8:22 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Zhouyi Zhou @ 2014-06-10 7:37 UTC (permalink / raw)
To: a.p.zijlstra, paulus, mingo, acme, tglx, hpa, x86, linux-kernel
Cc: Zhouyi Zhou, Zhouyi Zhou
Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
---
arch/x86/kernel/cpu/perf_event_amd_uncore.c | 32 +++++++++++++++------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event_amd_uncore.c b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
index 3bbdf4c..f60a50e 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
@@ -300,24 +300,28 @@ static void amd_uncore_cpu_up_prepare(unsigned int cpu)
if (amd_uncore_nb) {
uncore = amd_uncore_alloc(cpu);
- uncore->cpu = cpu;
- uncore->num_counters = NUM_COUNTERS_NB;
- uncore->rdpmc_base = RDPMC_BASE_NB;
- uncore->msr_base = MSR_F15H_NB_PERF_CTL;
- uncore->active_mask = &amd_nb_active_mask;
- uncore->pmu = &amd_nb_pmu;
- *per_cpu_ptr(amd_uncore_nb, cpu) = uncore;
+ if (uncore) {
+ uncore->cpu = cpu;
+ uncore->num_counters = NUM_COUNTERS_NB;
+ uncore->rdpmc_base = RDPMC_BASE_NB;
+ uncore->msr_base = MSR_F15H_NB_PERF_CTL;
+ uncore->active_mask = &amd_nb_active_mask;
+ uncore->pmu = &amd_nb_pmu;
+ *per_cpu_ptr(amd_uncore_nb, cpu) = uncore;
+ }
}
if (amd_uncore_l2) {
uncore = amd_uncore_alloc(cpu);
- uncore->cpu = cpu;
- uncore->num_counters = NUM_COUNTERS_L2;
- uncore->rdpmc_base = RDPMC_BASE_L2;
- uncore->msr_base = MSR_F16H_L2I_PERF_CTL;
- uncore->active_mask = &amd_l2_active_mask;
- uncore->pmu = &amd_l2_pmu;
- *per_cpu_ptr(amd_uncore_l2, cpu) = uncore;
+ if (uncore) {
+ uncore->cpu = cpu;
+ uncore->num_counters = NUM_COUNTERS_L2;
+ uncore->rdpmc_base = RDPMC_BASE_L2;
+ uncore->msr_base = MSR_F16H_L2I_PERF_CTL;
+ uncore->active_mask = &amd_l2_active_mask;
+ uncore->pmu = &amd_l2_pmu;
+ *per_cpu_ptr(amd_uncore_l2, cpu) = uncore;
+ }
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] perf/amd: NULL return of kzalloc_node should be handled
2014-06-10 7:37 [PATCH 1/1] perf/amd: NULL return of kzalloc_node should be handled Zhouyi Zhou
@ 2014-06-10 8:22 ` Peter Zijlstra
2014-06-10 8:45 ` Zhouyi Zhou
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2014-06-10 8:22 UTC (permalink / raw)
To: Zhouyi Zhou
Cc: paulus, mingo, acme, tglx, hpa, x86, linux-kernel, Zhouyi Zhou
[-- Attachment #1: Type: text/plain, Size: 147 bytes --]
On Tue, Jun 10, 2014 at 03:37:38PM +0800, Zhouyi Zhou wrote:
Less typing more thinking, this is wrong. You should fail when the
allocation fails.
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] perf/amd: NULL return of kzalloc_node should be handled
2014-06-10 8:22 ` Peter Zijlstra
@ 2014-06-10 8:45 ` Zhouyi Zhou
2014-06-10 8:51 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Zhouyi Zhou @ 2014-06-10 8:45 UTC (permalink / raw)
To: Peter Zijlstra
Cc: paulus, mingo, acme, tglx, hpa, x86, linux-kernel, Zhouyi Zhou
Thanks Peter for reviewing, and sorry for not think it thoroughly
before submitting.
Is that ok that when amd_uncore_cpu_up_prepare is called from
amd_uncore_cpu_notifier
I return notifier_from_errno(-ENOMEM), and when
amd_uncore_cpu_up_prepare is called from
amd_uncore_init I immediately return -ENODEV?
On Tue, Jun 10, 2014 at 4:22 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> On Tue, Jun 10, 2014 at 03:37:38PM +0800, Zhouyi Zhou wrote:
>
> Less typing more thinking, this is wrong. You should fail when the
> allocation fails.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] perf/amd: NULL return of kzalloc_node should be handled
2014-06-10 8:45 ` Zhouyi Zhou
@ 2014-06-10 8:51 ` Peter Zijlstra
0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2014-06-10 8:51 UTC (permalink / raw)
To: Zhouyi Zhou
Cc: paulus, mingo, acme, tglx, hpa, x86, linux-kernel, Zhouyi Zhou
[-- Attachment #1: Type: text/plain, Size: 417 bytes --]
On Tue, Jun 10, 2014 at 04:45:46PM +0800, Zhouyi Zhou wrote:
> Thanks Peter for reviewing, and sorry for not think it thoroughly
> before submitting.
> Is that ok that when amd_uncore_cpu_up_prepare is called from
> amd_uncore_cpu_notifier
> I return notifier_from_errno(-ENOMEM), and when
> amd_uncore_cpu_up_prepare is called from
> amd_uncore_init I immediately return -ENODEV?
That sounds about right. Thanks!
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] perf/amd: NULL return of kzalloc_node should be handled
@ 2014-06-11 4:08 Zhouyi Zhou
0 siblings, 0 replies; 5+ messages in thread
From: Zhouyi Zhou @ 2014-06-11 4:08 UTC (permalink / raw)
To: a.p.zijlstra, paulus, mingo, acme, tglx, hpa, x86, linux-kernel
Cc: Zhouyi Zhou, Zhouyi Zhou
Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
---
arch/x86/kernel/cpu/perf_event_amd_uncore.c | 32 +++++++++++++++------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event_amd_uncore.c b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
index 3bbdf4c..f60a50e 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
@@ -300,24 +300,28 @@ static void amd_uncore_cpu_up_prepare(unsigned int cpu)
if (amd_uncore_nb) {
uncore = amd_uncore_alloc(cpu);
- uncore->cpu = cpu;
- uncore->num_counters = NUM_COUNTERS_NB;
- uncore->rdpmc_base = RDPMC_BASE_NB;
- uncore->msr_base = MSR_F15H_NB_PERF_CTL;
- uncore->active_mask = &amd_nb_active_mask;
- uncore->pmu = &amd_nb_pmu;
- *per_cpu_ptr(amd_uncore_nb, cpu) = uncore;
+ if (uncore) {
+ uncore->cpu = cpu;
+ uncore->num_counters = NUM_COUNTERS_NB;
+ uncore->rdpmc_base = RDPMC_BASE_NB;
+ uncore->msr_base = MSR_F15H_NB_PERF_CTL;
+ uncore->active_mask = &amd_nb_active_mask;
+ uncore->pmu = &amd_nb_pmu;
+ *per_cpu_ptr(amd_uncore_nb, cpu) = uncore;
+ }
}
if (amd_uncore_l2) {
uncore = amd_uncore_alloc(cpu);
- uncore->cpu = cpu;
- uncore->num_counters = NUM_COUNTERS_L2;
- uncore->rdpmc_base = RDPMC_BASE_L2;
- uncore->msr_base = MSR_F16H_L2I_PERF_CTL;
- uncore->active_mask = &amd_l2_active_mask;
- uncore->pmu = &amd_l2_pmu;
- *per_cpu_ptr(amd_uncore_l2, cpu) = uncore;
+ if (uncore) {
+ uncore->cpu = cpu;
+ uncore->num_counters = NUM_COUNTERS_L2;
+ uncore->rdpmc_base = RDPMC_BASE_L2;
+ uncore->msr_base = MSR_F16H_L2I_PERF_CTL;
+ uncore->active_mask = &amd_l2_active_mask;
+ uncore->pmu = &amd_l2_pmu;
+ *per_cpu_ptr(amd_uncore_l2, cpu) = uncore;
+ }
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-11 4:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-10 7:37 [PATCH 1/1] perf/amd: NULL return of kzalloc_node should be handled Zhouyi Zhou
2014-06-10 8:22 ` Peter Zijlstra
2014-06-10 8:45 ` Zhouyi Zhou
2014-06-10 8:51 ` Peter Zijlstra
2014-06-11 4:08 Zhouyi Zhou
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.