public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/8] arm: perf: dynamically allocate cpu hardware data
Date: Wed, 22 Oct 2014 12:06:28 +0100	[thread overview]
Message-ID: <20141022110628.GF22642@leverpostej> (raw)
In-Reply-To: <5446CF26.8010102@codeaurora.org>

On Tue, Oct 21, 2014 at 10:24:54PM +0100, Stephen Boyd wrote:
> On 10/21/2014 06:11 AM, Mark Rutland wrote:
> > @@ -162,16 +160,22 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
> >  	return 0;
> >  }
> >  
> > -static void cpu_pmu_init(struct arm_pmu *cpu_pmu)
> > +static int cpu_pmu_init(struct arm_pmu *cpu_pmu)
> >  {
> >  	int cpu;
> > +	struct pmu_hw_events __percpu *cpu_hw_events;
> > +
> > +	cpu_hw_events = alloc_percpu(struct pmu_hw_events);
> 
> Shouldn't we free this somewhere?

My bad. We should clean this up if registration fails. As we don't
support unregistering PMUs, that should be the only case where we'll
need to free this.

I'll wrap that up in a new cpu_pmu_destroy function, which we can also
use to tear down the notifier introduced in the next patch.

Thanks,
Mark.

> 
> > +	if (!cpu_hw_events)
> > +		return -ENOMEM;
> > +
> >  	for_each_possible_cpu(cpu) {
> > -		struct pmu_hw_events *events = &per_cpu(cpu_hw_events, cpu);
> > +		struct pmu_hw_events *events = per_cpu_ptr(cpu_hw_events, cpu);
> >  		raw_spin_lock_init(&events->pmu_lock);
> >  		events->percpu_pmu = cpu_pmu;
> >  	}
> >  
> > -	cpu_pmu->hw_events	= &cpu_hw_events;
> > +	cpu_pmu->hw_events	= cpu_hw_events;
> >  	cpu_pmu->request_irq	= cpu_pmu_request_irq;
> >  	cpu_pmu->free_irq	= cpu_pmu_free_irq;
> >  
> > @@ -303,7 +309,10 @@ static int cpu_pmu_device_probe(struct platform_device *pdev)
> >  		goto out_free;
> >  	}
> >  
> > -	cpu_pmu_init(cpu_pmu);
> > +	ret = cpu_pmu_init(cpu_pmu);
> > +	if (ret)
> > +		goto out_free;
> > +
> >  	ret = armpmu_register(cpu_pmu, -1);
> >  
> >  	if (!ret)
> 
> Especially if this fails?
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 
> 

  reply	other threads:[~2014-10-22 11:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21 13:11 [PATCH 0/8] Prepatory rework for multi-PMU support Mark Rutland
2014-10-21 13:11 ` [PATCH 1/8] arm: perf: factor out callchain code Mark Rutland
2014-10-21 13:11 ` [PATCH 2/8] arm: perf: make PMU probing data-driven Mark Rutland
2014-10-21 21:25   ` Stephen Boyd
2014-10-22  9:50     ` Mark Rutland
2014-10-21 13:11 ` [PATCH 3/8] arm: perf: use IDR types for CPU PMUs Mark Rutland
2014-10-21 21:25   ` Stephen Boyd
2014-10-22 10:06     ` Mark Rutland
2014-10-27 20:29       ` Stephen Boyd
2014-10-21 13:11 ` [PATCH 4/8] arm: perf: limit size of accounting data Mark Rutland
2014-10-21 13:11 ` [PATCH 5/8] arm: perf: kill get_hw_events() Mark Rutland
2014-10-21 13:11 ` [PATCH 6/8] arm: perf: fold percpu_pmu into pmu_hw_events Mark Rutland
2014-10-21 22:05   ` Stephen Boyd
2014-10-22 10:10     ` Mark Rutland
2014-10-21 13:11 ` [PATCH 7/8] arm: perf: dynamically allocate cpu hardware data Mark Rutland
2014-10-21 21:24   ` Stephen Boyd
2014-10-22 11:06     ` Mark Rutland [this message]
2014-10-21 13:11 ` [PATCH 8/8] arm: perf: fold hotplug notifier into arm_pmu Mark Rutland
2014-10-21 22:18   ` Stephen Boyd

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=20141022110628.GF22642@leverpostej \
    --to=mark.rutland@arm.com \
    --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