From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59AFDC77B7C for ; Fri, 26 May 2023 09:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242893AbjEZJ1X (ORCPT ); Fri, 26 May 2023 05:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242632AbjEZJ1K (ORCPT ); Fri, 26 May 2023 05:27:10 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29AFB135; Fri, 26 May 2023 02:27:09 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4QSKFY2DVYz6H7kP; Fri, 26 May 2023 17:22:25 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 26 May 2023 10:27:06 +0100 Date: Fri, 26 May 2023 10:27:05 +0100 From: Jonathan Cameron To: Namhyung Kim CC: Liang Kan , , , , , , , , , , , Davidlohr Bueso , "Dave Jiang" , Stephane Eranian Subject: Re: [PATCH v6 4/5] perf: CXL Performance Monitoring Unit driver Message-ID: <20230526102705.00003345@Huawei.com> In-Reply-To: References: <20230413142617.15995-1-Jonathan.Cameron@huawei.com> <20230413142617.15995-5-Jonathan.Cameron@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Namhyung, > > +static int cxl_pmu_event_init(struct perf_event *event) > > +{ > > + struct cxl_pmu_info *info = pmu_to_cxl_pmu_info(event->pmu); > > + > > + event->cpu = info->on_cpu; > > Why not change the event->cpu after validation is done? Sure. Whilst I think it's harmless, it logically makes more sense to do it a few lines later so I'll move it to the end of this function. > > Thanks, > Namhyung > > > > + /* Top level type sanity check - is this a Hardware Event being requested */ > > + if (event->attr.type != event->pmu->type) > > + return -ENOENT; > > + > > + if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) > > + return -EOPNOTSUPP; > > + /* TODO: Validation of any filter */ > > + > > + /* > > + * Verify that it is possible to count what was requested. Either must > > + * be a fixed counter that is a precise match or a configurable counter > > + * where this is a subset. > > + */ > > + return cxl_pmu_get_event_idx(event, NULL, NULL); > > +}