Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3249318pxb; Tue, 20 Apr 2021 04:13:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAVF4ptpkN11IjL8iAkLZUKNPShhtaZsVwpwn8199yKgLRNOEbWGXrbdqxiO6ae1k8lgFN X-Received: by 2002:a05:6402:1588:: with SMTP id c8mr30788375edv.37.1618917183615; Tue, 20 Apr 2021 04:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618917183; cv=none; d=google.com; s=arc-20160816; b=fk32kC/llxJALQ4BQvJ6RE8CU3RGrBzHQSFOVt5k87SP+TgAzE+OTWETsNVf9tAmxW Wm8HJTRA/9eFRKqxWeVSgYhYdr4cSHHQw4VEij1a+lI63pYs7B2D4b0pUGKaEGtvE3Tl IVWzCb/qngyC+KRGxdZ01V95yT0SsFHPLG7nLwC+Q5y4jfsZP6WcJBT7ZTLj+ip3N99Z FCf57IgGmZ3gzDMjEvpBp5ODFYrpfQy7YVLYJY2k9RF/8PMafm962FYf5tfaIkYLzVLJ ILD9ykNwJ1xPnPXB4zTxbe+kRhat1/SFFIXG3dysT+nM9Z0GbQczhFarnQml8UGZzdDe sMvQ== 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:dkim-signature; bh=zsuQH97gxZ0t267lLz84+/n9DleMZ4H1bKGljUoc16g=; b=bGahLnG+wlC2PBJlGbR5ws7VbL6wUR8RIYKTqdjepxsUfjKA+aVKbSgPn9rxp2MCp7 ef6PWOYclZqVEAwoADqSz1i9dTyMr1j30/V55E5Y5ctRK5bafcpGpT1xTCDaagp9A2Mn q/2EHaqrexiW6oGe5URRy3st1BCZZL6tc6mmeXxUeKUPhsU7jlB0BpGsYgFGgAqoz7Ir tCEW7q5UBgDK1le5L/bZsq7p7SlG9S0wGV46gZuXKoYWaRTrSnU7c7z4zNoRUHopnk7q UC0HUgyrLhsXG64OUZxaXjfI8183NVWBVjVjva6/vNEaWwN9Z47GV4E0bGX6Eyf1Jgwn CZqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z6cwQmEM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si14825823ejz.305.2021.04.20.04.12.39; Tue, 20 Apr 2021 04:13:03 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z6cwQmEM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231750AbhDTLMB (ORCPT + 99 others); Tue, 20 Apr 2021 07:12:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:44700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbhDTLMA (ORCPT ); Tue, 20 Apr 2021 07:12:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A23961354; Tue, 20 Apr 2021 11:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618917089; bh=BNW3MtqZ8adN3h4rDrUM0FUx8nm3g6xveqFpE6MpLT8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z6cwQmEMiqsPtZpZYvgil/xeEI1AHtTvR+BRd5BC+kiOusnWAHv4WejvSFlJ2PkpW QW8Yez6c8Hlwvp8WkEeOVSDJwUEwfYw8+ltM9pocZwZ+OLDesqPIlkhfvhu9vni/NE MFmJa0kQlFoyBekJK9qCdPp0TPZJukIWhr+Z7BUXPKgjN4mFkOHyTkD3OjaBqe82YQ 1SufCIMMIu4FmAvZ0C0ETVM9mrFCYdU8HGXhqRA3p3FN2zoXSIOdQSEQIQCUx2yrZn wGw2oVv6JOWIZbbBhjigi63PoFp4QHU4uJFVhS+2SK2lbUvC6Ou72UwdKpOJVTlsO6 u4WspBHPuVTlg== Date: Tue, 20 Apr 2021 16:41:25 +0530 From: Vinod Koul To: Tom Zanussi Cc: peterz@infradead.org, acme@kernel.org, mingo@kernel.org, kan.liang@linux.intel.com, dave.jiang@intel.com, tony.luck@intel.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Subject: Re: [PATCH v2 1/1] dmaengine: idxd: Add IDXD performance monitor support Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03-04-21, 11:45, Tom Zanussi wrote: > +config INTEL_IDXD_PERFMON > + bool "Intel Data Accelerators performance monitor support" > + depends on INTEL_IDXD > + default y default y..? > /* IDXD software descriptor */ > @@ -369,4 +399,19 @@ int idxd_cdev_get_major(struct idxd_device *idxd); > int idxd_wq_add_cdev(struct idxd_wq *wq); > void idxd_wq_del_cdev(struct idxd_wq *wq); > > +/* perfmon */ > +#ifdef CONFIG_INTEL_IDXD_PERFMON maybe use IS_ENABLED() > @@ -556,6 +562,8 @@ static int __init idxd_init_module(void) > for (i = 0; i < IDXD_TYPE_MAX; i++) > idr_init(&idxd_idrs[i]); > > + perfmon_init(); > + > err = idxd_register_bus_type(); > if (err < 0) > return err; > @@ -589,5 +597,6 @@ static void __exit idxd_exit_module(void) > pci_unregister_driver(&idxd_pci_driver); > idxd_cdev_remove(); > idxd_unregister_bus_type(); > + perfmon_exit(); Ideally would make sense to add perfmon module first and then add use in idxd.. > +static ssize_t cpumask_show(struct device *dev, struct device_attribute *attr, > + char *buf); > + > +static cpumask_t perfmon_dsa_cpu_mask; > +static bool cpuhp_set_up; > +static enum cpuhp_state cpuhp_slot; > + > +static DEVICE_ATTR_RO(cpumask); Pls document these new attributes added > +static int perfmon_collect_events(struct idxd_pmu *idxd_pmu, > + struct perf_event *leader, > + bool dogrp) dogrp..? > +static int perfmon_validate_group(struct idxd_pmu *pmu, > + struct perf_event *event) > +{ > + struct perf_event *leader = event->group_leader; > + struct idxd_pmu *fake_pmu; > + int i, ret = 0, n; > + > + fake_pmu = kzalloc(sizeof(*fake_pmu), GFP_KERNEL); > + if (!fake_pmu) > + return -ENOMEM; > + > + fake_pmu->pmu.name = pmu->pmu.name; > + fake_pmu->n_counters = pmu->n_counters; > + > + n = perfmon_collect_events(fake_pmu, leader, true); > + if (n < 0) { > + ret = n; > + goto out; > + } > + > + fake_pmu->n_events = n; > + n = perfmon_collect_events(fake_pmu, event, false); > + if (n < 0) { > + ret = n; > + goto out; > + } > + > + fake_pmu->n_events = n; > + > + for (i = 0; i < n; i++) { > + int idx; lets move it to top of the function please > +static inline u64 perfmon_pmu_read_counter(struct perf_event *event) > +{ > + struct hw_perf_event *hwc = &event->hw; > + struct idxd_device *idxd; > + int cntr = hwc->idx; > + u64 cntrdata; > + > + idxd = event_to_idxd(event); > + > + cntrdata = ioread64(CNTRDATA_REG(idxd, cntr)); > + > + return cntrdata; return ioread64() ? -- ~Vinod