Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3696102imm; Mon, 17 Sep 2018 01:24:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZvwnNfPF6+KHIYZvejdesuqQjgNtV2uJtD1duik5e5lR3bQ3T4zG+SRAVFq7KttA7Wglle X-Received: by 2002:a62:c60e:: with SMTP id m14-v6mr24945419pfg.40.1537172658184; Mon, 17 Sep 2018 01:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537172658; cv=none; d=google.com; s=arc-20160816; b=ztQgqVtoQ/Xok3syIzC7LqMOOKNzGlqcwgKKD793HCXLmpEg2f/fhEqmYG2bLFDHhk WY3QGfk23yy53jL8OnpC+UXrR03tLdlVVRpWil8P1ooSnlRR0AgL/ZDg5xYPYOkcMiIT r2Y7terg5xVmt+hM3NmXpXd2ZnoD7SqURu+0SYyACVZmRHE7rOBWSax0YekJWoKr7Klx Xd9smh513bW/tgWPSuEOUuAcrsM+dJZekQbIOwu8abEm6Lv6SBZkyTAKBRVvQoBR62Pi UMShzhCjO80imtxH7Yux048NTgWBTxbM5bEBcomcT8MV9aRAXilVs54dUC5E6+WLb8Yo SANg== 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; bh=eNKH6e6fBgoHo9OQgEsILNApHLL7uWcVvbojj6a9/2U=; b=qHnkhJ9MkXljXkja7ExUJUsYKyQJbAbcywfJLctwzKAhVpO6ENx+AtYJrr0wZOc6wE LPfWEG2evUmPifw3K6wJ4UI+CAOkK5WXgJOt4ibPrYmWx2YEmjZBv2SjrIF6OlCglqfU wEF/LBJKuGHktLWS9wmfscflAyuYiq3ADXpmUQs0UF4QPd91+ssiGyv0tJJn0kEB4uEQ M9NNfyxUQtTvik2EXC62TNXd30K7lm+8zAPMOTkHQ5vsIYYgyMQ7Tg7PI9jsZNsjaGVD 87UZ9/juvlC2vGeiZ8a8ofPj9+ProhrBZq+tlwtM9NEvt+0rvODUDpiauy/HANMAJpTV N4AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=sxi47nb2; 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 31-v6si16341990pla.129.2018.09.17.01.24.02; Mon, 17 Sep 2018 01:24:18 -0700 (PDT) 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=merlin.20170209 header.b=sxi47nb2; 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 S1728179AbeIQNuH (ORCPT + 99 others); Mon, 17 Sep 2018 09:50:07 -0400 Received: from merlin.infradead.org ([205.233.59.134]:60250 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727185AbeIQNuH (ORCPT ); Mon, 17 Sep 2018 09:50:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=eNKH6e6fBgoHo9OQgEsILNApHLL7uWcVvbojj6a9/2U=; b=sxi47nb2tbbYXr6cYguIPfs0d nn/jptU/oueeHuI09/Osw4lNpt1Z4jS/4Ds+TkUNReIdYRp8ABd155QVLi+N2TlAqNB9Rdypa/GfA SzXYhZuP8AplKpLmPTyV4ePg25z5vvlyMa2EtU+josqLHfSPqNrWXX/SsuF8GSXePgKvHolmOXN1L snXrKF8oid2Jp/GeNCKl0XfHeyMRvLlC/TllEKIW0ZsuOwUT7jxRDddqKLF9w9UOLKcWSe9jz2XOw VVGWZDsP4WrRGhETmnWj+XigTCLOde5MVVUVSLcQ1OTL64Z49dzBWoC/eysFrN8f8S60r2pQ9jhNq rxdC44a0g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g1ooj-0001d1-K4; Mon, 17 Sep 2018 08:23:37 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 17FE4202C1A2E; Mon, 17 Sep 2018 10:23:36 +0200 (CEST) Date: Mon, 17 Sep 2018 10:23:36 +0200 From: Peter Zijlstra To: Reinette Chatre Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, mingo@redhat.com, acme@kernel.org, gavin.hindman@intel.com, jithu.joseph@intel.com, dave.hansen@intel.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 2/6] perf/core: Add helper to obtain performance counter index Message-ID: <20180917082336.GP24124@hirez.programming.kicks-ass.net> References: <6f93048a74c66a275f8eb6e1298f10552d1e5d95.1536685533.git.reinette.chatre@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f93048a74c66a275f8eb6e1298f10552d1e5d95.1536685533.git.reinette.chatre@intel.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 11, 2018 at 10:14:33AM -0700, Reinette Chatre wrote: > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 53c500f0ca79..c04dc666425c 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -1025,6 +1025,27 @@ static inline int in_software_context(struct perf_event *event) > return event->ctx->pmu->task_ctx_nr == perf_sw_context; > } > > +/** > + * perf_rdpmc_index - Return PMC counter used for event > + * @event: the perf_event to which the PMC counter was assigned > + * > + * The counter assigned to this performance event may change if interrupts > + * are enabled. This counter should thus never be used while interrupts are > + * enabled. Before this function is used to obtain the assigned counter the > + * event could be checked for validity using, for example, > + * perf_event_read_local(), within the same interrupt disabled section in > + * which this counter is planned to be used. > + * > + * Return: The index of the performance monitoring counter assigned to > + * @perf_event. > + */ > +static inline int perf_rdpmc_index(struct perf_event *event) > +{ > + lockdep_assert_irqs_disabled(); > + > + return event->hw.event_base_rdpmc; > +} I said arch/x86/include/asm/perf_events.h and call it: x86_perf_rdpmc_index(). This function is very much x86 specific.