All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/9] perf/x86: Add update attribute groups
@ 2019-05-12 15:55 Jiri Olsa
  2019-05-12 15:55 ` [PATCH 1/9] sysfs: Add sysfs_update_groups function Jiri Olsa
                   ` (9 more replies)
  0 siblings, 10 replies; 26+ messages in thread
From: Jiri Olsa @ 2019-05-12 15:55 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra, Andi Kleen, Greg Kroah-Hartman

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.

v2 changes:
  - updated changelogs
  - added Greg's Reviewed-by tag for sysfs change
  - split "caps" update change into 2 patches

Also available in:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/x86_attrs

thanks,
jirka


[1] https://lore.kernel.org/lkml/20190318182116.17388-1-jolsa@kernel.org/
---
Jiri Olsa (9):
      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: Use update attribute groups for extra format
      perf/x86/intel: Use update attributes for skylake format
      perf/x86: Use update attribute groups for default attributes

 arch/x86/events/core.c       | 106 +++++++++++++------------------------------------------------------------------------
 arch/x86/events/intel/core.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------
 arch/x86/events/perf_event.h |   7 +-----
 fs/sysfs/group.c             |  54 +++++++++++++++++++++++++++++++-------------
 include/linux/perf_event.h   |   1 +
 include/linux/sysfs.h        |   2 ++
 kernel/events/core.c         |   6 +++++
 7 files changed, 161 insertions(+), 166 deletions(-)

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2019-06-17 14:41 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-12 15:55 [PATCHv2 0/9] perf/x86: Add update attribute groups Jiri Olsa
2019-05-12 15:55 ` [PATCH 1/9] sysfs: Add sysfs_update_groups function Jiri Olsa
2019-06-03 13:25   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 2/9] perf: Add attr_groups_update into struct pmu Jiri Olsa
2019-06-03 13:26   ` [tip:perf/core] perf/core: " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 3/9] perf/x86: Get rid of x86_pmu::event_attrs Jiri Olsa
2019-06-03 13:26   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 4/9] perf/x86: Use the new pmu::update_attrs attribute group Jiri Olsa
2019-06-03 13:27   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 5/9] perf/x86: Add is_visible attribute_group callback for base events Jiri Olsa
2019-06-03 13:28   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 6/9] perf/x86: Use update attribute groups for caps Jiri Olsa
2019-06-03 13:28   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 7/9] perf/x86: Use update attribute groups for extra format Jiri Olsa
2019-06-03 13:29   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 8/9] perf/x86/intel: Use update attributes for skylake format Jiri Olsa
2019-06-03 13:30   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 9/9] perf/x86: Use update attribute groups for default attributes Jiri Olsa
2019-05-13  9:35   ` Peter Zijlstra
2019-05-13 10:13     ` Jiri Olsa
2019-05-24 13:21     ` [PATCH] perf/x86/intel: Use is_visible callback for default group Jiri Olsa
2019-06-14 10:20       ` Jiri Olsa
2019-06-14 12:34         ` Peter Zijlstra
2019-06-17 14:40       ` [tip:perf/core] perf/x86/intel: Use ->is_visible " tip-bot for Jiri Olsa
2019-06-03 13:31   ` [tip:perf/core] perf/x86: Use update attribute groups for default attributes tip-bot for Jiri Olsa
2019-05-13  9:38 ` [PATCHv2 0/9] perf/x86: Add update attribute groups Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.