lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190504125207.24662-1-jolsa@kernel.org>
Date:   Sat,  4 May 2019 14:51:59 +0200
From:   Jiri Olsa <jolsa@...nel.org>
To:     Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:     lkml <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: [RFC 0/8] perf/x86: Add update attribute groups

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(-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ