From: Jiri Olsa <jolsa@kernel.org>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Andi Kleen <ak@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [RFC 0/8] perf/x86: Add update attribute groups
Date: Sat, 4 May 2019 14:51:59 +0200 [thread overview]
Message-ID: <20190504125207.24662-1-jolsa@kernel.org> (raw)
hi,
following up on [1], this patchset adds update attribute groups
to pmu and gets rid of the 'creative' attribute handling code.
In x86 pmu we mainly add attributes into following directories:
events, format, caps
so it seems like we could have just 3 attribute groups, but most of
the attributes presence depends on HW, which ends up with attributes
merging and all that 'creative' code we have now.
Currently, we have 'struct pmu::attr_groups', which is in its final
shape (merged) and it's added via sysfs_create_groups call when
registering the pmu:
perf_pmu_register
pmu_dev_alloc
device_add
device_add_attrs
device_add_groups
sysfs_create_groups(pmu::attr_groups)
This interface does not provide a way to have multiple attribute
groups, which could add files into same directory, all has to be
prepared ahead.
This patchset adds 'update attribute group', which is added via new
sysfs_update_groups function, after the initial set of attributes
is created. The group's is_visible function will cover its HW
dependency/visibility.
This will allow us to update "events" or "format" directories with
attributes that depend on various HW config.
For example having group_format_extra group, that updates "format"
directory, only if pmu version is 2 and higher:
static umode_t
lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
return x86_pmu.lbr_nr ? attr->mode : 0;
}
static struct attribute_group group_caps_lbr = {
.name = "caps",
.attrs = lbr_attrs,
.is_visible = lbr_is_visible,
};
Note that some of the groups are defined without 'attrs' set,
which is assigned later based on the detected cpu model.
And finally we'll end up with just a single set of attribute groups:
static const struct attribute_group *attr_update[] = {
&group_events_td,
&group_events_mem,
&group_events_tsx,
&group_caps_gen,
&group_caps_lbr,
&group_format_extra,
&group_format_extra_skl,
&group_default,
NULL,
};
that is passed to struct pmu.
Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/x86_attrs
thoughts? thanks,
jirka
[1] https://lore.kernel.org/lkml/20190318182116.17388-1-jolsa@kernel.org/
---
Jiri Olsa (8):
sysfs: Add sysfs_update_groups function
perf: Add attr_groups_update into struct pmu
perf/x86: Get rid of x86_pmu::event_attrs
perf/x86: Use the new pmu::update_attrs attribute group
perf/x86: Add is_visible attribute_group callback for base events
perf/x86: Use update attribute groups for caps
perf/x86/intel: Use update attributes for skylake format
perf/x86: Use update attribute groups for default attributes
arch/x86/events/core.c | 105 +++++++++++++++------------------------------------------------------------------------------------------
arch/x86/events/intel/core.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------
arch/x86/events/perf_event.h | 7 +------
fs/sysfs/group.c | 43 ++++++++++++++++++++++++++++---------------
include/linux/perf_event.h | 1 +
include/linux/sysfs.h | 2 ++
kernel/events/core.c | 6 ++++++
7 files changed, 145 insertions(+), 163 deletions(-)
next reply other threads:[~2019-05-04 12:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-04 12:51 Jiri Olsa [this message]
2019-05-04 12:52 ` [PATCH 1/8] sysfs: Add sysfs_update_groups function Jiri Olsa
2019-05-04 13:53 ` Greg Kroah-Hartman
2019-05-09 15:23 ` Jiri Olsa
2019-05-04 12:52 ` [PATCH 2/8] perf: Add attr_groups_update into struct pmu Jiri Olsa
2019-05-04 12:52 ` [PATCH 3/8] perf/x86: Get rid of x86_pmu::event_attrs Jiri Olsa
2019-05-04 12:52 ` [PATCH 4/8] perf/x86: Use the new pmu::update_attrs attribute group Jiri Olsa
2019-05-04 12:52 ` [PATCH 5/8] perf/x86: Add is_visible attribute_group callback for base events Jiri Olsa
2019-05-04 12:52 ` [PATCH 6/8] perf/x86: Use update attribute groups for caps Jiri Olsa
2019-05-04 12:52 ` [PATCH 7/8] perf/x86/intel: Use update attributes for skylake format Jiri Olsa
2019-05-04 12:52 ` [PATCH 8/8] perf/x86: Use update attribute groups for default attributes Jiri Olsa
2019-05-04 13:53 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190504125207.24662-1-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox