Re: [RFC PATCH 1/2] debugfs: add small file operations for most files

From: Johannes Berg
Date: Wed Oct 09 2024 - 13:37:20 EST


On Wed, 2024-10-09 at 19:33 +0200, Greg Kroah-Hartman wrote:
> On Wed, Oct 09, 2024 at 06:13:39PM +0200, Johannes Berg wrote:
> > From: Johannes Berg <johannes.berg@xxxxxxxxx>
> >
> > As struct file_operations is really big, but (most) debugfs
> > files only use simple_open, read and write, and don't need
> > anything else, this wastes a lot of space for NULL pointers.
>
> You added llseek too, I'm guessing you need/want that?

Oh, right. I had it without llseek originally, but then I thought we
might be worried about breaking the API on debugfs files, even if most
of the time really it's not used. But if people were worried that'd
severely limit where this could be used, vs. another pointer.

Just forgot to add it above when I edited the commit message.

> > Add a struct debugfs_short_fops and some bookkeeping code in
> > debugfs so that users can use that with debugfs_create_file()
> > using _Generic to figure out which function to use.
>
> That's crazy, but nice work!

Yeah it's a bit crazy, I agree. With _Generic() it's actually nice to
use though, and the conversions are mostly trivial as you can see in the
other patch. So glad we moved to C11 :-)

johannes