Re: [PATCH v2 5/6] debugfs: add debugfs_create_atomic64_t for atomic64_t

From: Linus Torvalds
Date: Wed Apr 05 2023 - 12:29:38 EST


On Wed, Apr 5, 2023 at 9:11 AM Luis Chamberlain <mcgrof@xxxxxxxxxx> wrote:
>
> Oh but I don't get the atomic incs, so we'd need debugfs_create_atomic_long_t().

No, you misunderstand what I meant.

Just use "atomic_long_t" in the module code.

But then the debugfs code should do

debugfs_create_ulong(... &val->counter ..);

to expose said atomic_long values.

No need for new debugfs interfaces.

Because "atomic_long" is just a regular "long" as far as plain
read/set operations are concerned - which is all that the debugfs code
does anyway.

So I think you can do something like

atomic_long_t total_mod_size;

...

debugfs_create_ulong("total_mod_size",
0400, mod_debugfs_root,
&total_mod_size.counter);

but I didn't actually try to compile that kind of version.

(I think "counter" is actually a _signed_ long, so maybe the types don't match).

Linus