linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Julien Thierry <julien.thierry@arm.com>
Cc: peterz@infradead.org, liwei391@huawei.com, will.deacon@arm.com,
	acme@kernel.org, alexander.shishkin@linux.intel.com,
	mingo@redhat.com, Catalin Marinas <catalin.marinas@arm.com>,
	namhyung@kernel.org, jolsa@redhat.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 2/9] arm64: perf: Remove PMU locking
Date: Mon, 8 Jul 2019 16:03:20 +0100	[thread overview]
Message-ID: <20190708150320.GC33099@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <1562596377-33196-3-git-send-email-julien.thierry@arm.com>

On Mon, Jul 08, 2019 at 03:32:50PM +0100, Julien Thierry wrote:
> Since the PMU driver uses direct registers for counter
> setup/manipulation, locking around these operations is no longer needed.
> 
> For operations that can be called with interrupts enabled, preemption
> still needs to be disabled to ensure the programming of the PMU is
> done on the expected CPU and not migrated mid-programming.

[...]

>  static void armv8pmu_start(struct arm_pmu *cpu_pmu)
>  {
> -	unsigned long flags;
> -	struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
> -
> -	raw_spin_lock_irqsave(&events->pmu_lock, flags);
> +	preempt_disable();
>  	/* Enable all counters */
>  	armv8pmu_pmcr_write(armv8pmu_pmcr_read() | ARMV8_PMU_PMCR_E);
> -	raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
> +	preempt_enable();
>  }
> 
>  static void armv8pmu_stop(struct arm_pmu *cpu_pmu)
>  {
> -	unsigned long flags;
> -	struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
> -
> -	raw_spin_lock_irqsave(&events->pmu_lock, flags);
> +	preempt_disable();
>  	/* Disable all counters */
>  	armv8pmu_pmcr_write(armv8pmu_pmcr_read() & ~ARMV8_PMU_PMCR_E);
> -	raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
> +	preempt_enable();
>  }

I think that we'd have bigger problems if these could be called in
preemptible context, since we couldn't guarantee which HW PMU instance
they'd operate on.

I also thought that the interrupt disable/enable was a hold-over from
the old days of perf core, and these days all of the synchronous
operations are held with the pmu ctx lock held (and interrupts
disabled).

Do you have an example of when these are called with interrupts enabled?
Or in a preemptible context?

Thanks,
Mark.

> 
>  static irqreturn_t armv8pmu_handle_irq(struct arm_pmu *cpu_pmu)
> --
> 1.9.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-07-08 15:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08 14:32 [PATCH v3 0/9] arm_pmu: Use NMI for perf interrupt Julien Thierry
2019-07-08 14:32 ` [PATCH v3 1/9] arm64: perf: avoid PMXEV* indirection Julien Thierry
2019-07-08 15:03   ` Mark Rutland
2019-07-10 10:57   ` Steven Price
2019-07-10 11:01     ` Julien Thierry
2019-07-16 10:33       ` Shijith Thotton
2019-07-16 10:54         ` Julien Thierry
2019-07-17  4:45           ` Shijith Thotton
2019-07-08 14:32 ` [PATCH v3 2/9] arm64: perf: Remove PMU locking Julien Thierry
2019-07-08 15:03   ` Mark Rutland [this message]
2019-07-08 15:34     ` Julien Thierry
2019-07-09 11:22       ` Mark Rutland
2019-07-08 14:32 ` [PATCH v3 3/9] arm: perf: save/resore pmsel Julien Thierry
2019-07-08 15:06   ` Mark Rutland
2019-07-08 15:40     ` Julien Thierry
2019-07-08 14:32 ` [PATCH v3 4/9] arm: perf: Remove Remove PMU locking Julien Thierry
2019-07-08 15:10   ` Mark Rutland
2019-07-08 14:32 ` [PATCH v3 5/9] perf/arm_pmu: Move PMU lock to ARMv6 events Julien Thierry
2019-07-08 15:19   ` Mark Rutland
2019-07-08 15:50     ` Julien Thierry
2019-07-08 14:32 ` [PATCH v3 6/9] arm64: perf: Do not call irq_work_run in NMI context Julien Thierry
2019-07-08 15:29   ` Mark Rutland
2019-07-08 16:00     ` Julien Thierry
2019-07-08 14:32 ` [PATCH v3 7/9] arm/arm64: kvm: pmu: Make overflow handler NMI safe Julien Thierry
2019-07-08 15:30   ` Mark Rutland
2019-07-11 12:38   ` Zenghui Yu
2019-07-08 14:32 ` [PATCH v3 8/9] arm_pmu: Introduce pmu_irq_ops Julien Thierry
2019-07-08 14:32 ` [PATCH v3 9/9] arm_pmu: Use NMIs for PMU Julien Thierry

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=20190708150320.GC33099@lakrids.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=catalin.marinas@arm.com \
    --cc=jolsa@redhat.com \
    --cc=julien.thierry@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=liwei391@huawei.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /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).