public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Daniel Sedlak <daniel@sedlak.dev>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	rust-for-linux@vger.kernel.org
Subject: Re: [RFC PATCH 0/3] rust abstractions for interacting with sysfs
Date: Mon, 9 Dec 2024 17:38:04 +0100	[thread overview]
Message-ID: <2024120958-antihero-slideshow-e30b@gregkh> (raw)
In-Reply-To: <dab64690-ec96-4980-81e7-aae87b53dc02@sedlak.dev>

On Mon, Dec 09, 2024 at 05:12:44PM +0100, Daniel Sedlak wrote:
> 
> On 12/8/24 2:34 PM, Greg KH wrote:
> 
> > > I implemented a sample to present the API I have chosen for the Rust part.
> > > It is a straightforward example that does not represent all capabilities
> > > of the sysfs. The documentation will be potentially improved, but I would
> > > like to first settle the abstractions.
> > 
> > What exactly do you want to represent in sysfs here?  Start with that
> > and we can work backwards to say what types of bindings are needed.
> 
> Great question, I should have started with that earlier. Lets say I wrote a
> module that attaches some hooks to kernel function calls and the module does
> some accounting on that.

Modules do not add hooks to function calls :)

> What is the correct way to expose the statistics
> from that module?

debugfs.

> From my point of view this module does not fit into any
> subsystem already defined in `/sys/`, and procfs should be abandoned. Should
> I use debugfs for that?

As it sounds like you are attempting to be a "security module", just use
securityfs instead.

And really, don't hook function calls, or if you must, just use ebpf and
the functionality it provides (all the stats you could ask for!)  No
need to write a kernel module at all.

sysfs is for drivers and the devices they bind to (and devices that do
not have drivers) and sometimes filesystems and occasionally memory
stuff as well (mm is really just a driver for memory).  Don't use it for
things it is not designed for (i.e. module-wide things.)

thanks,

greg k-h

      reply	other threads:[~2024-12-09 16:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-08 13:15 [RFC PATCH 0/3] rust abstractions for interacting with sysfs Daniel Sedlak
2024-12-08 13:15 ` [RFC PATCH 1/3] rust: kernel: types: add mode wrapper Daniel Sedlak
2024-12-09  7:21   ` Alice Ryhl
2024-12-09 16:19     ` Daniel Sedlak
2024-12-08 13:15 ` [RFC PATCH 2/3] rust: kernel: kobject: basic sysfs implementation Daniel Sedlak
2024-12-08 13:43   ` Greg KH
2024-12-09 15:04     ` Daniel Sedlak
2024-12-08 13:56   ` Greg KH
2024-12-08 13:15 ` [RFC PATCH 3/3] samples: rust: add kobject sample Daniel Sedlak
2024-12-08 13:46   ` Greg KH
2024-12-09 15:17     ` Daniel Sedlak
2024-12-08 13:34 ` [RFC PATCH 0/3] rust abstractions for interacting with sysfs Greg KH
2024-12-09 16:12   ` Daniel Sedlak
2024-12-09 16:38     ` Greg KH [this message]

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=2024120958-antihero-slideshow-e30b@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=daniel@sedlak.dev \
    --cc=gary@garyguo.net \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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