Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5573938ybv; Tue, 11 Feb 2020 19:00:20 -0800 (PST) X-Google-Smtp-Source: APXvYqyT/zhbGqNr1t2gL8KW+8NpANkwh8KnEyWGfca33KIiNHyLAYddJF50S8TnsdyGdus+jV1q X-Received: by 2002:a9d:5786:: with SMTP id q6mr7337470oth.164.1581476420395; Tue, 11 Feb 2020 19:00:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581476420; cv=none; d=google.com; s=arc-20160816; b=yG/4pMrWh3whPdQ4HW5tURzfTg/0BpIMintyBMr5+jvAaC6BqTAlXs5FEoZcBbKtxP RVfAIqDOHU6u9BMflyu/stoup8xlZqFKF4q63LQhCUyyezE9AqTNlqoEtcWNnZrWZS2y nhA1YmHe/hlbGP7bZIzztk+Zxm1PLTErceZdDmec6P9wkoWoaGlar0BzrsEaY+APL+o0 RYtWghmjmOwPXxi+jLFzKE8dNII8QX5RlbJI1Ce/b5Ya29rM9wJPidXCh1OXgGLMEqb/ 7LiVNn7EjI+BlIWo/ccOupnNx7npVcxATBkLAmYqSlVvnkZuogQmAff71ckK5pNFK58H vwwA== 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; bh=va0t6cMoTiS2EZTalQJm/Nn7R2OzAdlRIEW8fGB3Aic=; b=QjnZhK7HUOrp/M059DHadwdDPnVz8HvsF4+B0m06OdDKVIp+G6aV2sxglSlwUeajTe t5fl1bwFlWc8KucRVKkobsDVFHSJ9j5cHJIeGuo75AOzBvycX9H0RsnPJ/Wsd7H9PA2w WNCbvk39v1X3UZSiVlE7D2cjS+iPkFByuQbAzoyxe4rkUrPGwvmu+5zwdkLgdF/88UFV GM2/SncxmZEvrh9YTUy1X1pXR0Oq8kMaH8jjEHt6jQoCfVCYO+JWMkEHU4H6dNYWz5/X BLdiq1adZrUz0UjnmXfycRDM3RdoK+j4Gp1Vu6Oq/7IUWhnUBMVhFzz4cVbMccItI7QJ ng/Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10si2883111oia.232.2020.02.11.19.00.08; Tue, 11 Feb 2020 19:00:20 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727754AbgBLC76 (ORCPT + 99 others); Tue, 11 Feb 2020 21:59:58 -0500 Received: from mga12.intel.com ([192.55.52.136]:4514 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727608AbgBLC76 (ORCPT ); Tue, 11 Feb 2020 21:59:58 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 18:59:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,428,1574150400"; d="scan'208";a="226681713" Received: from hao-dev.bj.intel.com (HELO localhost) ([10.238.157.65]) by fmsmga007.fm.intel.com with ESMTP; 11 Feb 2020 18:59:55 -0800 Date: Wed, 12 Feb 2020 10:39:13 +0800 From: Wu Hao To: Greg KH Cc: mdf@kernel.org, will@kernel.org, mark.rutland@arm.com, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, atull@kernel.org, yilun.xu@intel.com, Luwei Kang Subject: Re: [PATCH v7 2/2] fpga: dfl: fme: add performance reporting support Message-ID: <20200212023913.GA5645@hao-dev> References: <1581306469-22629-1-git-send-email-hao.wu@intel.com> <1581306469-22629-3-git-send-email-hao.wu@intel.com> <20200210205618.GA1347752@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200210205618.GA1347752@kroah.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 10, 2020 at 12:56:18PM -0800, Greg KH wrote: > On Mon, Feb 10, 2020 at 11:47:49AM +0800, Wu Hao wrote: > > +What: /sys/bus/event_source/devices/fmeX/format > > +Date: February 2020 > > +KernelVersion: 5.7 > > +Contact: Wu Hao > > +Description: Read-only. Attribute group to describe the magic bits > > + that go into perf_event_attr.config for a particular pmu. > > + (See ABI/testing/sysfs-bus-event_source-devices-format). > > + > > + Each attribute under this group defines a bit range of the > > + perf_event_attr.config. All supported attributes are listed > > + below. > > + > > + event = "config:0-11" - event ID > > + evtype = "config:12-15" - event type > > + portid = "config:16-23" - event source > > + > > + For example, > > + > > + fab_mmio_read = "event=0x06,evtype=0x02,portid=0xff" > > Are perf sysfs files always this bad "multiple values per file"? Or is > that unique to this driver? If not unique, do you have specific > examples in the kernel that currently do this today? Hi Greg, Thanks a lot for the review. : ) Perf sysfs files allow this kind of output, so some perf drivers are using the similar format for their jobs. Examples from my machine. # cat /sys/bus/event_source/devices/cpu/events/cycles-ct event=0x3c,in_tx=1,in_tx_cp=1 # cat /sys/bus/event_source/devices/cpu/events/el-start event=0xc8,umask=0x1 # cat /sys/bus/event_source/devices/cpu/events/instructions event=0xc0 # cat /sys/bus/event_source/devices/cpu/events/branch-instructions event=0xc4 See arch/x86/events/intel/core.c EVENT_ATTR_STR(cycles-ct, cycles_ct, "event=0x3c,in_tx=1,in_tx_cp=1"); ... And descriptions/examples from ABI/testing/sysfs-bus-event_source-devices-events What: /sys/bus/event_source/devices//events/ Date: 2014/02/24 Contact: Linux kernel mailing list Description: Per-pmu performance monitoring events specific to the running system Each file (except for some of those with a '.' in them, '.unit' and '.scale') in the 'events' directory describes a single performance monitoring event supported by the . The name of the file is the name of the event. File contents: [=][,[=]]... Where is one of the terms listed under /sys/bus/event_source/devices//format/ and is a number is base-16 format with a '0x' prefix (lowercase only). If a is specified alone (without an assigned value), it is implied that 0x1 is assigned to that . Examples (each of these lines would be in a seperate file): event=0x2abc event=0x423,inv,cmask=0x3 domain=0x1,offset=0x8,starting_index=0xffff domain=0x1,offset=0x8,core=? Each of the assignments indicates a value to be assigned to a particular set of bits (as defined by the format file corresponding to the ) in the perf_event structure passed to the perf_open syscall. In the case of the last example, a value replacing "?" would need to be provided by the user selecting the particular event. This is referred to as "event parameterization". Event parameters have the format 'param=?'. So this is not something new introduced by this patch. > > > > +static struct attribute *fme_perf_events_attrs_empty[] = { > > + NULL, > > Huh? > > > +}; > > + > > +static struct attribute_group fme_perf_events_group = { > > + .name = "events", > > + .attrs = fme_perf_events_attrs_empty, > > You create an empty directory? Why? What goes in here? > > very odd... Actually events are filled into this "events" from several different groups via pmu->attr_update[1]. pmu->attr_update = fme_perf_events_groups; pmu->attr_update allows us to update "events" directories with attributes that depend on various HW conditions. In our case, several different groups with different is_visible functions are filled into "events" using this method. And several existing pmu drivers (e.g. arch/x86/events/intel/cstate.c) are using the same way (having an empty directory first and update it using pmu->attr_update). But I have to admit that I should add some comments there to avoid confusion, sorry, will do that in the next version. [1] https://lkml.org/lkml/2019/5/4/188 Thanks Hao > > greg k-h