Received: by 10.223.185.116 with SMTP id b49csp2800828wrg; Sun, 25 Feb 2018 06:39:11 -0800 (PST) X-Google-Smtp-Source: AH8x224JiB53FR+AxEgDdwPUpSLAiZ04212OeNSX0fqbQBUSAIGXSsqKPVflOgVBrdDQaVlkCK3h X-Received: by 10.101.82.1 with SMTP id o1mr6240790pgp.37.1519569551162; Sun, 25 Feb 2018 06:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519569551; cv=none; d=google.com; s=arc-20160816; b=yrSS4F06x+CC0AkJgqW5coJjx0MJxwRxF/SfKxB9Sw/xrrxPM8DnwUSMdLNB6tKSNu 2lynfQ97bImTA1hxfNPZG9qj11cgN/qO9wG52tSBH2qQHW4DJ6TCd+9z+og8UeHvalbZ qZM7BmjbG25hMCW8qZHpsZlc9xrzcJ1fvtIn+HunP0sNP0vX4gweBt3a5Dea3khWCJ5z fkcAjnh6YMyXfUkjdTN9xgb9yz2mvKr5y2xzW9DdOC4knFBy6DPzszvHHMKkkUBmmk+N VBD1WAFVm4WyZb6EwYTMdvJgqnt9WyBdHNaIgArv2yXBbV5aVCwh/hbio3e2PvkjKfA7 buTg== 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:arc-authentication-results; bh=ZEPD960upgxFyorpJFzNEAiq6INkC6b4S3whGFd1rZs=; b=cSLjh2Btjbg7GEi71sBjoXcseOPTfhmlBHLOnmcVtmWQufL/oaMk4XLaCzRuLLrqXL kXCf+tutR+aogMJQ1jNSsgp3OeCzpgGk+/xoP1S65DxUQjefPxm71Ws8CZoTjzqpkJF7 I9EYO76l9hQ+izLPSIllm/NYFzTGJG+EDqN/3YBopqIvJYqr5BIkBVteiESMpWeQlMwO RtFa63FR40Z2lzaGngiIp7uiMgT5bkCjZvPWgktdx3c3P8TXLmRIFxCtaMhALGF5WA81 DAVmIwpV97i4biGbxiBl9THYdr4eWhxLHy2b/MXQcZjxPjiBGsBJxcLKXy88NG3MPzym BGWw== ARC-Authentication-Results: i=1; mx.google.com; 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 a15-v6si5253854pll.691.2018.02.25.06.38.56; Sun, 25 Feb 2018 06:39:11 -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; 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 S1751825AbeBYOiL (ORCPT + 99 others); Sun, 25 Feb 2018 09:38:11 -0500 Received: from foss.arm.com ([217.140.101.70]:41480 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814AbeBYOiI (ORCPT ); Sun, 25 Feb 2018 09:38:08 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0975B80D; Sun, 25 Feb 2018 06:38:08 -0800 (PST) Received: from salmiak (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 34B1C3F53D; Sun, 25 Feb 2018 06:38:06 -0800 (PST) Date: Sun, 25 Feb 2018 14:38:03 +0000 From: Mark Rutland To: Saravana Kannan Cc: Peter Zijlstra , 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: <20180225143802.denbkubqjg2dc7af@salmiak> 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: NeoMutt/20170113 (1.7.2) 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. I think that if we need to generalize PERF_EV_CAP_READ_ACTIVE_PKG, it would be better to give events a pointer to a cpumask. That could then cover all cases quite trivially: static int __perf_event_read_cpu(struct perf_event *event, int event_cpu) { int local_cpu = smp_processor_id(); if (event->read_mask && cpumask_test_cpu(local_cpu, event->read_mask)) event_cpu = local_cpu; return event_cpu; } ... in the PERF_EV_CAP_READ_ACTIVE_PKG case, we can use the exiting(?) package masks, and more generally we can re-use the PMU's affinit mask if it has one. That said, I see that many pmu::read() implementations have side-effects on hwc->prev_count, and event->count, so I worry that this won't be sfe in general (e.g. if we race with the IRQ handler on another CPU). Thanks, Mark.