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 15:58:38 -0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1h1u6E-0006f1-1Z for speck@linutronix.de; Thu, 07 Mar 2019 15:34:18 +0100 Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1u6C-0006H2-PS for speck@linutronix.de; Thu, 07 Mar 2019 14:34:17 +0000 Date: Thu, 7 Mar 2019 15:34:14 +0100 From: Peter Zijlstra Subject: [MODERATED] Re: [PATCH 4/4] walnut 4 Message-ID: <20190307143414.GH32477@hirez.programming.kicks-ass.net> References: <20190219155807.878855982@infradead.org> <20190219155859.834625575@infradead.org> <20190307135631.GA29095@kroah.com> MIME-Version: 1.0 In-Reply-To: <20190307135631.GA29095@kroah.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Thu, Mar 07, 2019 at 02:56:31PM +0100, speck for Greg KH wrote: > 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. Right; that would be a really nice cleanup. I suppose nobody who touched all that (very much including me) knew about that is_visible() thing. I'll try and not forget and make someone clean that up.