All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Liang, Kan" <kan.liang@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Stephane Eranian <eranian@google.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH V6] perf: Reset the dirty counter to prevent the leak for an RDPMC task
Date: Mon, 10 May 2021 15:29:21 -0500	[thread overview]
Message-ID: <CAL_JsqKeVoBL6cn6CGUW17jnf8B+4aHKeyRdceaGCiKzsUsZwg@mail.gmail.com> (raw)
In-Reply-To: <20210510191811.GA21560@worktop.programming.kicks-ass.net>

On Mon, May 10, 2021 at 2:18 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Thu, Apr 22, 2021 at 11:25:52AM -0700, kan.liang@linux.intel.com wrote:
>
> > - Add a new method check_leakage() to check and clear dirty counters
> >   to prevent potential leakage.
>
> I really dislike adding spurious callbacks, also because indirect calls
> are teh suck, but also because it pollutes the interface so.
>
> That said, I'm not sure I actually like the below any better :/
>
> ---
>
>  arch/x86/events/core.c       | 58 +++++++++++++++++++++++++++++++++++++++++---
>  arch/x86/events/perf_event.h |  1 +
>  include/linux/perf_event.h   |  2 ++
>  kernel/events/core.c         |  7 +++++-
>  4 files changed, 63 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index 8e509325c2c3..e650c4ab603a 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -740,21 +740,26 @@ void x86_pmu_enable_all(int added)
>         }
>  }
>
> -static inline int is_x86_event(struct perf_event *event)
> +static inline bool is_x86_pmu(struct pmu *_pmu)
>  {
>         int i;
>
>         if (!is_hybrid())
> -               return event->pmu == &pmu;
> +               return _pmu == &pmu;
>
>         for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) {
> -               if (event->pmu == &x86_pmu.hybrid_pmu[i].pmu)
> +               if (_pmu == &x86_pmu.hybrid_pmu[i].pmu)
>                         return true;
>         }
>
>         return false;
>  }

[...]

> +bool arch_perf_needs_sched_in(struct pmu *pmu)
> +{
> +       if (!READ_ONCE(x86_pmu.attr_rdpmc))
> +               return false;
> +
> +       if (!is_x86_pmu(pmu))
> +               return  false;
> +
> +       return current->mm && atomic_read(&current->mm->context.perf_rdpmc_allowed);
>  }

Why add an arch hook for something that clearly looks to be per PMU?
Couldn't we add another atomic/flag for calling sched_task() that is
per PMU rather than per CPU. With that, I think I can avoid a hook in
switch_mm() and keep every self contained in the Arm PMU driver.

Rob

  reply	other threads:[~2021-05-10 20:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 18:25 [PATCH V6] perf: Reset the dirty counter to prevent the leak for an RDPMC task kan.liang
2021-05-10 19:18 ` Peter Zijlstra
2021-05-10 20:29   ` Rob Herring [this message]
2021-05-11 17:59     ` Liang, Kan
2021-05-11 20:39       ` Rob Herring
2021-05-11 21:42         ` Liang, Kan
2021-05-12  7:35           ` Peter Zijlstra
2021-05-12 14:09             ` Liang, Kan
2021-05-12 14:54           ` Rob Herring
2021-05-12 15:36             ` Liang, Kan

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=CAL_JsqKeVoBL6cn6CGUW17jnf8B+4aHKeyRdceaGCiKzsUsZwg@mail.gmail.com \
    --to=robh@kernel.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@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 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.