Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4196629pxj; Tue, 8 Jun 2021 08:36:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqKWzA1bJoXV6niJp1uTNA+l9NalNKNJ9qy2MQSPqCPRImnxf4Bqng6OxYK4drFtEh7PbW X-Received: by 2002:a17:906:b74a:: with SMTP id fx10mr23864326ejb.248.1623166600400; Tue, 08 Jun 2021 08:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623166599; cv=none; d=google.com; s=arc-20160816; b=ZvWs7HAWnIPXdXA0katwYSJPEfhzUWK7ixVaEWzuUwYLwRsX0pRVdH9NF8yk3fkkYI NqdlVx6deDlPyFbtAIWBNeUj68Ks59rNyhQyKxoNzkoCeOHHZ6fEn/eVAyaNSYTGuQuq nr0xCHZc83K6l3GZLOwaVCeRqqWQoRxfz5PFFzP+aNDwwQLuK9B5hTB/vWBkq7XRU5h6 eLjzEHzlzy8pPrYrU3wItG/axgRx4PQqcutjUvcsgvF9vZAzLowQv5Edx4LUs1Z/8J6M ZtKKCC9nf2WDJ4h94xqJjufhS5a+PddkdDFM0WQFLfoX1m3dZ5OIzjHQSlCEOWXCKCOc SpGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=nFKhWloXahFGrSWaS/MYVzhL46dm5Tk847v+WSk1/l0=; b=e4cGhL+n5kSKOfAq7qGyP3hZ2YvF/A6fc0mHSDbmGhNNiIqfD8Z0TCvZf/bEs6uXVR RD8M9mXE3LA7fgWOrb8BCwyUHmJrlAooFJu3r8kD0jXiiZ0/4DxZ+tWRR5oVOLBRTnO7 O8/mkclhwWlO5JZJ0KUTBETlg+WGbMWDjKitD4qyeVJAovPwd8U11Uu7BKvHh9wU/xSK IxWG1WOAejjXi1QUc83qcOh2ugCRFIn2L/LoGrbNlFJyUvR2cRwGh075eA1jB2SncePC JwfCzSxw3HRPHdv7OWwN9d/SqJjVdMt/d/tEwRkuVpkLo0DXzWT7BeX02mEphrJf4Sze wGEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e21si195ejl.273.2021.06.08.08.36.15; Tue, 08 Jun 2021 08:36:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232763AbhFHPgV (ORCPT + 99 others); Tue, 8 Jun 2021 11:36:21 -0400 Received: from foss.arm.com ([217.140.110.172]:33758 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231842AbhFHPgV (ORCPT ); Tue, 8 Jun 2021 11:36:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 328426D; Tue, 8 Jun 2021 08:34:28 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.5.29]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5BCC13F73D; Tue, 8 Jun 2021 08:34:27 -0700 (PDT) Date: Tue, 8 Jun 2021 16:34:24 +0100 From: Mark Rutland To: Leo Yan Cc: Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/2] arm64: perf: Correct per-thread mode if the event is not supported Message-ID: <20210608153424.GD16585@C02TD0UTHF1T.local> References: <20210608145228.36595-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210608145228.36595-1-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 08, 2021 at 10:52:27PM +0800, Leo Yan wrote: > When the perf tool runs in per-thread mode, armpmu_event_init() defers > to handle events in armpmu_add(), the main reason is the selected PMU in > the init phase can mismatch with the CPUs when the profiled task > is scheduled on. > > For example, on an Arm big.LTTILE platform with two clusters, every > cluster has its dedicated PMU; the event initialization happens on the > LITTLE cluster and its corresponding PMU is selected, but the profiled > task is scheduled on big cluster, it's deferred to handle this case in > armpmu_add(). > > Usually, we should report failure in the first place so this can allow > users to easily locate the issue they are facing. For the per-thread > mode, the profiled task can be migrated on any CPU, therefore the event > can be enabled on any CPU. In other words, if a PMU detects it fails to > support the process-following event, it can directly returns -EOPNOTSUPP > so can stop profiling. > > This patch adds the checking for per-thread mode, if the event is not > supported, return -EOPNOTSUPP. I don't understand the rationale for this patch. We call armpmu_event_init() from perf_try_init_event(), and if we return *any* error code that will be returned to userspace, or at least that used to be the case. What problem are you trying to solve here? Is this some fallout of commit: 55bcf6ef314ae8ba ("perf: Extend PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE") ... ? Thanks, Mark. > > Signed-off-by: Leo Yan > --- > drivers/perf/arm_pmu.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c > index d4f7f1f9cc77..aedea060ca8b 100644 > --- a/drivers/perf/arm_pmu.c > +++ b/drivers/perf/arm_pmu.c > @@ -502,9 +502,9 @@ static int armpmu_event_init(struct perf_event *event) > /* > * Reject CPU-affine events for CPUs that are of a different class to > * that which this PMU handles. Process-following events (where > - * event->cpu == -1) can be migrated between CPUs, and thus we have to > - * reject them later (in armpmu_add) if they're scheduled on a > - * different class of CPU. > + * event->cpu == -1) can be migrated between CPUs, and thus we will > + * reject them when map_event() detects absent entry at below or later > + * (in armpmu_add) if they're scheduled on a different class of CPU. > */ > if (event->cpu != -1 && > !cpumask_test_cpu(event->cpu, &armpmu->supported_cpus)) > @@ -514,8 +514,16 @@ static int armpmu_event_init(struct perf_event *event) > if (has_branch_stack(event)) > return -EOPNOTSUPP; > > - if (armpmu->map_event(event) == -ENOENT) > + if (armpmu->map_event(event) == -ENOENT) { > + /* > + * Process-following event is not supported on current PMU, > + * returns -EOPNOTSUPP to stop perf at the initialization > + * phase. > + */ > + if (event->cpu == -1) > + return -EOPNOTSUPP; > return -ENOENT; > + } > > return __hw_perf_event_init(event); > } > -- > 2.25.1 >