historical-speck.lore.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: speck@linutronix.de
Subject: [MODERATED] Re: [PATCH 4/4] walnut 4
Date: Thu, 7 Mar 2019 14:56:31 +0100	[thread overview]
Message-ID: <20190307135631.GA29095@kroah.com> (raw)
In-Reply-To: <20190219155859.834625575@infradead.org>

I was working on the backport to 4.9.y and ran across merge issues with
this patch.  I understand the constraints on which you are working with
here, but please, let me do a tiny rant about how you all are doing
"extra work" with regards to the creation of sysfs files:

On Tue, Feb 19, 2019 at 04:58:11PM +0100, speck for Peter Zijlstra wrote:
> @@ -4123,8 +4179,11 @@ static struct attribute *intel_pmu_caps_
>         NULL
>  };
>  
> +DEVICE_BOOL_ATTR(allow_tsx_force_abort, 0644, allow_tsx_force_abort);
> +
>  static struct attribute *intel_pmu_attrs[] = {
>  	&dev_attr_freeze_on_smi.attr,
> +	NULL, /* &dev_attr_allow_tsx_force_abort.attr.attr */
>  	NULL,
>  };
>  
> @@ -4623,6 +4682,15 @@ __init int intel_pmu_init(void)
>  		tsx_attr = hsw_tsx_events_attrs;
>  		intel_pmu_pebs_data_source_skl(
>  			boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X);
> +
> +		if (boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT)) {
> +			x86_pmu.flags |= PMU_FL_TFA;
> +			x86_pmu.get_event_constraints = skl_get_event_constraints;
> +			x86_pmu.enable_all = intel_skl_pmu_enable_all;
> +			x86_pmu.commit_scheduling = intel_skl_commit_scheduling;
> +			intel_pmu_attrs[1] = &dev_attr_allow_tsx_force_abort.attr.attr;
> +		}
> +
>  		pr_cont("Skylake events, ");
>  		name = "skylake";
>  		break;

sysfs files have the ability to be "shown" or not, on their own.  There
is a "is_visable()" callback for every sysfs group.

This allows you to set a whole bunch of groups to a device, and then,
when the device is created, the kobject core will call back to you and
ask "should I show this file?"  At that point in time, you can do your
check for "boot_cpu_has(...)" and the like to see if you really should
be showing the file or not.

This saves you all the horrid mess of the merge_attr() function, trying
to overload NULL pointers here in this attribute list, and other such
hacks.

I guess no one stopped to think why _only_ the perf cpu code has a
function like merge_attr(), and how the rest of the kernel could get
away without needing a hack like that :(

Anyway, rant over.  I'll see if I can squeze this into the 4.9.y tree as
it was before the major revamp of the perf cpu sysfs files.

In the future, someone should just switch all of this to attribute
groups, like the rest of the kernel uses, so no such crazyness is
needed.

thanks,

greg k-h

  parent reply	other threads:[~2019-03-07 14:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 15:58 [MODERATED] [PATCH 0/4] walnut 0 Peter Zijlstra
2019-02-19 15:58 ` [MODERATED] [PATCH 1/4] walnut 1 Peter Zijlstra
2019-02-19 15:58 ` [MODERATED] [PATCH 2/4] walnut 2 Peter Zijlstra
2019-02-19 15:58 ` [MODERATED] [PATCH 3/4] walnut 3 Peter Zijlstra
2019-02-19 15:58 ` [MODERATED] [PATCH 4/4] walnut 4 Peter Zijlstra
2019-02-19 16:10   ` [MODERATED] " Peter Zijlstra
2019-02-20 22:31     ` Nelson D'Souza
2019-02-22 22:58       ` [MODERATED] Fwd: " Nelson D'Souza
2019-02-22 23:19         ` Nelson D'Souza
2019-02-19 18:49   ` [MODERATED] Linus Torvalds
2019-02-20 14:37     ` Peter Zijlstra
2019-03-07 13:56   ` Greg KH [this message]
2019-03-07 14:34     ` [MODERATED] Re: [PATCH 4/4] walnut 4 Peter Zijlstra
2019-03-07 15:09     ` mark gross
2019-02-20 18:10 ` [MODERATED] Re: [PATCH 0/4] walnut 0 mark gross
2019-02-22 19:20   ` Nelson D'Souza
2019-03-01 18:59 ` mark gross

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=20190307135631.GA29095@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=speck@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).