From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752291AbcHIFE2 (ORCPT ); Tue, 9 Aug 2016 01:04:28 -0400 Received: from mail-ua0-f169.google.com ([209.85.217.169]:36796 "EHLO mail-ua0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbcHIFEZ (ORCPT ); Tue, 9 Aug 2016 01:04:25 -0400 MIME-Version: 1.0 In-Reply-To: References: <1470539577-102094-1-git-send-email-davidcc@google.com> <1470539577-102094-4-git-send-email-davidcc@google.com> <9b29b625-d019-6671-5676-3c58a31a6d3f@gmail.com> From: David Carrillo-Cisneros Date: Mon, 8 Aug 2016 22:04:23 -0700 Message-ID: Subject: Re: [PATCH v2 3/4] perf/core: introduce PMU_EV_CAP_READ_ACTIVE_PKG To: Nilay Vaish Cc: linux-kernel , "x86@kernel.org" , Ingo Molnar , Thomas Gleixner , Andi Kleen , Kan Liang , Peter Zijlstra , Vegard Nossum , Paul Turner , Stephane Eranian Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nilay, Sounds good, I will post an updated version. Thanks, David On Mon, Aug 8, 2016 at 9:12 AM, Nilay Vaish wrote: > On 7 August 2016 at 15:10, David Carrillo-Cisneros wrote: >> Hi Nilay, >> >>>> static int perf_event_read(struct perf_event *event, bool group) >>>> { >>>> - int ret = 0; >>>> + int ret = 0, cpu_to_read; >>>> >>>> - /* >>>> - * If event is enabled and currently active on a CPU, update the >>>> - * value in the event structure: >>>> - */ >>>> - if (event->state == PERF_EVENT_STATE_ACTIVE) { >>>> + cpu_to_read = find_cpu_to_read(event); >>>> + >>>> + if (cpu_to_read >= 0) { >>>> struct perf_read_data data = { >>>> .event = event, >>>> .group = group, >>>> .ret = 0, >>>> }; >>>> - ret = smp_call_function_single(event->oncpu, >>>> + ret = smp_call_function_single(cpu_to_read, >>>> __perf_event_read, &data, >>>> 1); >>>> ret = ret ? : data.ret; >>>> } else if (event->state == PERF_EVENT_STATE_INACTIVE) { >>>> >>> >>> I would like to suggest a small change to this patch. I think the check on >>> PERF_EVENT_STATE_ACTIVE should be retained in the perf_event_read() >>> function. The new function should assume that the event is active. I find >>> this more readable since the next check in function perf_event_read() is on >>> PERF_EVENT_STATE_INACTIVE. >> >> Two oncoming flags that Intel CQM/CMT will use are meant to allow read >> even if event is inactive. This makes sense in CQM/CMT because the hw >> RMID is always reserved. I am ok with keeping the check for >> STATE_ACTIVE until those flags are actually introduced, tough. > > > Hello David > > Lets go with checking PERF_EVENT_STATE_ACTIVE in perf_event_read() for > the time being. With the new version of the patch that you posted, I > find that checking PERF_EVENT_STATE_ACTIVE in find_cpu_to_read() makes > you introduce another if statement for checking STATE_INACTIVE. > > If your CQM/CMT patches later need the code structure you have now, I > would also support it. But as of now, I think, it is better to check > STATE_ACTIVE in perf_event_read(). > > > Thanks > Nilay