Received: by 10.223.185.116 with SMTP id b49csp1634218wrg; Sat, 24 Feb 2018 00:42:08 -0800 (PST) X-Google-Smtp-Source: AH8x225Ed9LLm2faVRagrhLHvFH4KLBpfVUny7XHbWF2RGThZ2lkGccqtSUhxemQe5V8g0w5zF6Y X-Received: by 2002:a17:902:40e:: with SMTP id 14-v6mr4214049ple.64.1519461728438; Sat, 24 Feb 2018 00:42:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519461728; cv=none; d=google.com; s=arc-20160816; b=kJHNUNlS8WnZFpupS1wjfQkBuHby97JG+39H1yBR6tc9fsrQPaWPHP1Jea0eQEsW57 sQI4FHUqfkC1a13Ek9ueEr0bDvvewGgiedYkDB6uLQP7i0DoX9dEsXxCpoM2z7mgHBYh H6a8lzZpXbQNFT/M0EcltDubs3G/lOHDdXGLh0mYuIte0Xyf75ap0Fsaf0N2YAouMbEo SJo64GGe7Yzd7WS6y/XCXhFjaX0lX3baHYihiAnkwV4QAKh77fmazFKWZbKb+ThgES0v ggOjfE/I/+lAqclWrPat5i4f5IcX0Ug5JKNKdyBsnE08FueEMWLvU/Y0RqBQ46n2S0hV FURA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=+cQtuKuylwBWE/RpeA3AMbIcns65eByWlR9Fu0VTURk=; b=ZudQabjGJNDsEbYG9yD9fxiFzM5NidHOpWo5as57qt5LnxyOdDjrcpwTv7VCH+gTTn T0uuIa8/y8YWu/Bey+4ohpI5ZXloB+gzw3qJ6AM11l7K5XS+EPXiotAWpvktgJxzF1O0 Os0g8Qych62jrHfA+3821U+QPbf7K0pbf9v97moG/Jd+DbwvUJxzo4atUga9M4dQkBPi egd3kfjnKn3UxdqKltOiTiN/wGUL6TUA9bZuO8m0Zv419ay8T0E+5IE9LIAztnhd2nBJ 5phjTTRlkX0ooqfbXFlMgAW3pFbaNxjpuRzigrL5aTcrdjK245W6k738zOSuVOQ4oSqb 2hHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=k27joUgN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12-v6si3171089pls.265.2018.02.24.00.41.53; Sat, 24 Feb 2018 00:42:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=k27joUgN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751131AbeBXIlP (ORCPT + 99 others); Sat, 24 Feb 2018 03:41:15 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:37576 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbeBXIlO (ORCPT ); Sat, 24 Feb 2018 03:41:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+cQtuKuylwBWE/RpeA3AMbIcns65eByWlR9Fu0VTURk=; b=k27joUgNO9+CSI4Cz7OJZye/W PC8MM+D9hg4Xptg5cJmpWPcWEAM+dyuw5t9/7dZ7K3wHin+XsCGHFC2UEoerZoLW2vfiEtbpQexOv Pi6zbfEGt1ppIJrKZm6sz+M7RMMRPkv6w74qbp8qTZp1z4zvA72TG/Z87bp1VHzwbGDGBHfvvLGBD lfxbFOqfHDGicew3rqIkgMbQ9Q/gvcd/h4etSwZ/2ej11C444DvZfCWfWgGrLzWWtgUvlLT9OLR3V 7VV7sjK58LkuLCL48iqYXTbf84kTXxDaF96gAklAyQmjSXGp9pkvSN5NKWDuSMrFkcg51iGn1dlIp g76OZVTbg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1epVOG-00079I-Hi; Sat, 24 Feb 2018 08:41:08 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D69B82029F1DF; Sat, 24 Feb 2018 09:41:06 +0100 (CET) Date: Sat, 24 Feb 2018 09:41:06 +0100 From: Peter Zijlstra To: Saravana Kannan Cc: mark.rutland@arm.com, Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , avilaj@codeaurora.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 2/2] perf/core: Add support for PMUs that can be read from any CPU Message-ID: <20180224084106.GC25201@hirez.programming.kicks-ass.net> References: <1519431578-11995-1-git-send-email-skannan@codeaurora.org> <1519431578-11995-2-git-send-email-skannan@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519431578-11995-2-git-send-email-skannan@codeaurora.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 23, 2018 at 04:19:38PM -0800, Saravana Kannan wrote: > Some PMUs events can be read from any CPU. So allow the PMU to mark > events as such. For these events, we don't need to reject reads or > make smp calls to the event's CPU and cause unnecessary wake ups. > > Good examples of such events would be events from caches shared across > all CPUs. So why would the existing ACTIVE_PKG not work for you? Because clearly your example does not cross a package. > Signed-off-by: Saravana Kannan > --- > include/linux/perf_event.h | 3 +++ > kernel/events/core.c | 10 ++++++++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 7546822..ee8978f 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -510,9 +510,12 @@ typedef void (*perf_overflow_handler_t)(struct perf_event *, > * PERF_EV_CAP_SOFTWARE: Is a software event. > * PERF_EV_CAP_READ_ACTIVE_PKG: A CPU event (or cgroup event) that can be read > * from any CPU in the package where it is active. > + * PERF_EV_CAP_READ_ANY_CPU: A CPU event (or cgroup event) that can be read > + * from any CPU. > */ > #define PERF_EV_CAP_SOFTWARE BIT(0) > #define PERF_EV_CAP_READ_ACTIVE_PKG BIT(1) > +#define PERF_EV_CAP_READ_ANY_CPU BIT(2) > > #define SWEVENT_HLIST_BITS 8 > #define SWEVENT_HLIST_SIZE (1 << SWEVENT_HLIST_BITS) > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 5d3df58..570187b 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -3484,6 +3484,10 @@ static int __perf_event_read_cpu(struct perf_event *event, int event_cpu) > { > u16 local_pkg, event_pkg; > > + if (event->group_caps & PERF_EV_CAP_READ_ANY_CPU) { > + return smp_processor_id(); > + } > + > if (event->group_caps & PERF_EV_CAP_READ_ACTIVE_PKG) { > int local_cpu = smp_processor_id(); > > @@ -3575,6 +3579,7 @@ int perf_event_read_local(struct perf_event *event, u64 *value, > { > unsigned long flags; > int ret = 0; > + bool is_any_cpu = !!(event->group_caps & PERF_EV_CAP_READ_ANY_CPU); > > /* > * Disabling interrupts avoids all counter scheduling (context > @@ -3600,7 +3605,8 @@ int perf_event_read_local(struct perf_event *event, u64 *value, > > /* If this is a per-CPU event, it must be for this CPU */ > if (!(event->attach_state & PERF_ATTACH_TASK) && > - event->cpu != smp_processor_id()) { > + event->cpu != smp_processor_id() && > + !is_any_cpu) { > ret = -EINVAL; > goto out; > } > @@ -3610,7 +3616,7 @@ int perf_event_read_local(struct perf_event *event, u64 *value, > * or local to this CPU. Furthermore it means its ACTIVE (otherwise > * oncpu == -1). > */ > - if (event->oncpu == smp_processor_id()) > + if (event->oncpu == smp_processor_id() || is_any_cpu) > event->pmu->read(event); > > *value = local64_read(&event->count); And why are you modifying read_local for this? That didn't support ACTIVE_PKG, so why should it support this? And again, where are the users?