Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp929946rwd; Thu, 1 Jun 2023 08:18:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7iVW6RaTqncGT93wBt52O9YpgkkSLlr/kenm8jIxB3HjVXBsWMc0paj5g/hzeQyc7Dyo3G X-Received: by 2002:a17:90a:41:b0:258:ad45:936d with SMTP id 1-20020a17090a004100b00258ad45936dmr1237249pjb.19.1685632680056; Thu, 01 Jun 2023 08:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685632680; cv=none; d=google.com; s=arc-20160816; b=L222sZNoxxiRmqJS8EJcHe/wznmDKMQkW9QF9t4FMzLQk5ovN9eVvcunpHzXi3fXdh jv7/27sJdWKV1XavUNMlJUJTfJC//DQnHP6/UrT6iLWVnTnhNi1sL/1zmAaCfqvtjCuA FIXblVEAWC2gK57TnZoqYJPI/IkDmhIRLS6Oi39WYnztY8URI629RlyqmHF6pFELaSoh AYzv0S34cjFzaKW8y2eRfvQnN/wasp18kL7B6cG2oQjt3unUGl+TAxi+Hi1hVtOH46y1 CVi8wB7wj5vF680ys5+gJHU/rIeLPU85aLSF02NypyVUShkSfwAdThF1u96v+jClRq8y 1tjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=EiW6z55v65vntJGP9VsqXbf4j++fwOFsxe2I5gc2/yI=; b=wLPaDEdep4pn+pInAJcaIKt8tB3HATsUuDlu77d3tcNsYYdZmigudDw1QNXG3pNDdW 7yVRlGR0dmirH08FG8NMkk+HnKfwQ3/60s0X3tSB+5RmuEP8RRmJY/P/QWbK77f+t0KF bgK7t8ejI+iJyg8npYWT3/N6zyoVHc/cBKdCp9gt0iRFV9Tx68KrrVQjTtNKD5HxNWC4 M4wDxnaGfqadKJdpAhaYuvy2bFKUtkfuwbkXP2b6RQGCG7lCIrdn5WRIdEAuKv1vGLf9 ihziWaRAsxUEd1r6tN/Hx9hcP+RF5OljPYZV2ADvo3AayHmowUQvOjgFN7BKbPgnrSG1 7xuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020a17090abf8600b00255b7adb2d8si1279328pjs.90.2023.06.01.08.17.47; Thu, 01 Jun 2023 08:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234679AbjFAPKw (ORCPT + 99 others); Thu, 1 Jun 2023 11:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234099AbjFAPKp (ORCPT ); Thu, 1 Jun 2023 11:10:45 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 05069E74; Thu, 1 Jun 2023 08:10:23 -0700 (PDT) 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 C3D851063; Thu, 1 Jun 2023 08:10:46 -0700 (PDT) Received: from [10.57.84.85] (unknown [10.57.84.85]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EDC563F663; Thu, 1 Jun 2023 08:09:59 -0700 (PDT) Message-ID: <2a081ab9-f1f3-569e-72e8-1c743e8357a1@arm.com> Date: Thu, 1 Jun 2023 16:09:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH v2 4/5] perf: arm_cspmu: Support implementation specific event validation Content-Language: en-GB To: Ilkka Koskinen , Jonathan Corbet , Will Deacon , Mark Rutland , Besar Wicaksono , Suzuki K Poulose Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20230601030144.3458136-1-ilkka@os.amperecomputing.com> <20230601030144.3458136-5-ilkka@os.amperecomputing.com> From: Robin Murphy In-Reply-To: <20230601030144.3458136-5-ilkka@os.amperecomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-06-01 04:01, Ilkka Koskinen wrote: > Some platforms may use e.g. different filtering mechanism and, thus, > may need different way to validate the events. > > Signed-off-by: Ilkka Koskinen > --- > drivers/perf/arm_cspmu/arm_cspmu.c | 4 ++++ > drivers/perf/arm_cspmu/arm_cspmu.h | 2 ++ > 2 files changed, 6 insertions(+) > > diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c > index b4c4ef81c719..a26f484e06b1 100644 > --- a/drivers/perf/arm_cspmu/arm_cspmu.c > +++ b/drivers/perf/arm_cspmu/arm_cspmu.c > @@ -593,6 +593,10 @@ static int arm_cspmu_get_event_idx(struct arm_cspmu_hw_events *hw_events, > if (idx >= cspmu->num_logical_ctrs) > return -EAGAIN; > > + if (cspmu->impl.ops.validate_event && > + !cspmu->impl.ops.validate_event(cspmu, event)) > + return -EAGAIN; Seems like this should be -EINVAL, or maybe the callback should return int so it can make its own distinction (yes, I know the outer logic doesn't actually propagate it, but there's no reason that couldn't improve at some point as well). Another thought is that once we get into imp-def conditions for whether an event is valid in itself, we presumably also need to consider imp-def conditions for whether a given pair of events are compatible to be grouped? Thanks, Robin. > + > set_bit(idx, hw_events->used_ctrs); > > return idx; > diff --git a/drivers/perf/arm_cspmu/arm_cspmu.h b/drivers/perf/arm_cspmu/arm_cspmu.h > index 4a29b921f7e8..0e5c316c96f9 100644 > --- a/drivers/perf/arm_cspmu/arm_cspmu.h > +++ b/drivers/perf/arm_cspmu/arm_cspmu.h > @@ -106,6 +106,8 @@ struct arm_cspmu_impl_ops { > void (*set_ev_filter)(struct arm_cspmu *cspmu, > struct hw_perf_event *hwc, > u32 filter); > + /* Implementation specific event validation */ > + bool (*validate_event)(struct arm_cspmu *cspmu, struct perf_event *new); > /* Hide/show unsupported events */ > umode_t (*event_attr_is_visible)(struct kobject *kobj, > struct attribute *attr, int unused);