Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 07 Mar 2019 14:00:16 -0000 Received: from mail.kernel.org ([198.145.29.99]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1h1tVp-0005Vc-B9 for speck@linutronix.de; Thu, 07 Mar 2019 14:56:41 +0100 Date: Thu, 7 Mar 2019 14:56:31 +0100 From: Greg KH Subject: [MODERATED] Re: [PATCH 4/4] walnut 4 Message-ID: <20190307135631.GA29095@kroah.com> References: <20190219155807.878855982@infradead.org> <20190219155859.834625575@infradead.org> MIME-Version: 1.0 In-Reply-To: <20190219155859.834625575@infradead.org> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: 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