kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* What's tha KOBJ_MAX action used for?
@ 2020-07-13 11:17 Garrit Franke
  2020-07-13 12:35 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Garrit Franke @ 2020-07-13 11:17 UTC (permalink / raw)
  To: kernelnewbies

Hi all,

I was wondering, what the KOBJ_MAX action in the kobject.h file does. 
It is self explainatory what KOBJ_ADD, KOBJ_REMOVE etc. are used for, but KOBJ_MAX puzzles me.

On top of that, it is never referenced somewhere in the sourcecode (https://elixir.bootlin.com/linux/v5.7.8/C/ident/KOBJ_MAX).

Can it maybe even be removed?

Regards,
Garrit Franke

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: What's tha KOBJ_MAX action used for?
  2020-07-13 11:17 What's tha KOBJ_MAX action used for? Garrit Franke
@ 2020-07-13 12:35 ` Greg KH
  2020-07-14  2:15   ` Valdis Klētnieks
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2020-07-13 12:35 UTC (permalink / raw)
  To: Garrit Franke; +Cc: kernelnewbies

On Mon, Jul 13, 2020 at 01:17:25PM +0200, Garrit Franke wrote:
> Hi all,
> 
> I was wondering, what the KOBJ_MAX action in the kobject.h file does. 
> It is self explainatory what KOBJ_ADD, KOBJ_REMOVE etc. are used for, but KOBJ_MAX puzzles me.
> 
> On top of that, it is never referenced somewhere in the sourcecode (https://elixir.bootlin.com/linux/v5.7.8/C/ident/KOBJ_MAX).
> 
> Can it maybe even be removed?

Maybe it can, try it and see!

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: What's tha KOBJ_MAX action used for?
  2020-07-13 12:35 ` Greg KH
@ 2020-07-14  2:15   ` Valdis Klētnieks
  2020-07-14 14:36     ` Garrit Franke
  0 siblings, 1 reply; 5+ messages in thread
From: Valdis Klētnieks @ 2020-07-14  2:15 UTC (permalink / raw)
  To: Greg KH; +Cc: Garrit Franke, kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 840 bytes --]

On Mon, 13 Jul 2020 14:35:23 +0200, Greg KH said:
> On Mon, Jul 13, 2020 at 01:17:25PM +0200, Garrit Franke wrote:
> > Hi all,
> >
> > I was wondering, what the KOBJ_MAX action in the kobject.h file does.
> > It is self explainatory what KOBJ_ADD, KOBJ_REMOVE etc. are used for, but KOBJ_MAX puzzles me.

> > Can it maybe even be removed?
>
> Maybe it can, try it and see!

I suspect that this line:
        for (action = 0; action < ARRAY_SIZE(kobject_actions); action++) {
in lib/kobject_uenvent.c:kobject_action_type()  combined with the fact that
kobject_actions[] does *not* actually match the enum regardless of the comment
above it, result in it being superfluous.

Figuring out why is left as an exercise for the student.

Oh, and if I had a dollar for every time I've been surprised by creative abuse of
the cpp ## operator... :)


[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: What's tha KOBJ_MAX action used for?
  2020-07-14  2:15   ` Valdis Klētnieks
@ 2020-07-14 14:36     ` Garrit Franke
  2020-07-14 16:12       ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Garrit Franke @ 2020-07-14 14:36 UTC (permalink / raw)
  To: Valdis Klētnieks; +Cc: Greg KH, Linux Kernel List

Thanks for your replies. Also, thanks greg for your thorough review on my
corresponding patch (https://lkml.org/lkml/2020/7/14/84), I learned a lot!

I have been digging around about Kobjects a bit. They are nicely documented.
Still, no documentation exists about this KOBJ_MAX action.
This post on stackoverflow mentions that it's a "special" field that marks the
end of the enum (if I understand correctly):
https://stackoverflow.com/a/23149574/9046809
This lead me to think that this is a convention I'm not aware of, but
I could not find any
resources that described such a thing, so I discarded that idea.

If I understand correctly, this action can in fact be passed to userspace by the
kobject_uevent function, so it would be a bad idea to remove it. Is my
reasoning correct?

regards,
Garrit


Am Di., 14. Juli 2020 um 04:15 Uhr schrieb Valdis Klētnieks
<valdis.kletnieks@vt.edu>:
>
> On Mon, 13 Jul 2020 14:35:23 +0200, Greg KH said:
> > On Mon, Jul 13, 2020 at 01:17:25PM +0200, Garrit Franke wrote:
> > > Hi all,
> > >
> > > I was wondering, what the KOBJ_MAX action in the kobject.h file does.
> > > It is self explainatory what KOBJ_ADD, KOBJ_REMOVE etc. are used for, but KOBJ_MAX puzzles me.
>
> > > Can it maybe even be removed?
> >
> > Maybe it can, try it and see!
>
> I suspect that this line:
>         for (action = 0; action < ARRAY_SIZE(kobject_actions); action++) {
> in lib/kobject_uenvent.c:kobject_action_type()  combined with the fact that
> kobject_actions[] does *not* actually match the enum regardless of the comment
> above it, result in it being superfluous.
>
> Figuring out why is left as an exercise for the student.
>
> Oh, and if I had a dollar for every time I've been surprised by creative abuse of
> the cpp ## operator... :)
>

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: What's tha KOBJ_MAX action used for?
  2020-07-14 14:36     ` Garrit Franke
@ 2020-07-14 16:12       ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2020-07-14 16:12 UTC (permalink / raw)
  To: Garrit Franke; +Cc: Valdis Klētnieks, Linux Kernel List

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Tue, Jul 14, 2020 at 04:36:15PM +0200, Garrit Franke wrote:
> Thanks for your replies. Also, thanks greg for your thorough review on my
> corresponding patch (https://lkml.org/lkml/2020/7/14/84), I learned a lot!
> 
> I have been digging around about Kobjects a bit. They are nicely documented.
> Still, no documentation exists about this KOBJ_MAX action.

Please look at commit 60a96a59569b ("Driver core: accept all valid
action-strings in uevent-trigger") in the tree.  That's when it was
added, and it was used.

Then a short bit later, 5c5daf657cb5 ("Driver core: exclude
kobject_uevent.c for !CONFIG_HOTPLUG") stopped using it in the .c files,
and no one noticed that it should have been removed.


> This post on stackoverflow mentions that it's a "special" field that marks the
> end of the enum (if I understand correctly):
> https://stackoverflow.com/a/23149574/9046809
> This lead me to think that this is a convention I'm not aware of, but
> I could not find any
> resources that described such a thing, so I discarded that idea.
> 
> If I understand correctly, this action can in fact be passed to userspace by the
> kobject_uevent function, so it would be a bad idea to remove it. Is my
> reasoning correct?

Yes, if it did get passed to userspace.  But it doesn't, as you can see
by the last commit I referenced above.  We pass strings to userspace for
the kobject events and we take that same string sent to us from
userspace to send "fake" kobject uevents as well.

Also, the loop that we checked for KOBJ_MAX is no longer present, we do
a much more sane ARRAY_SIZE() check, right?  So I don't think it's
needed.

Can you rewrite your changelog text with all of this new information and
resend it?  I'll be glad to take the patch then.

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-14 16:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 11:17 What's tha KOBJ_MAX action used for? Garrit Franke
2020-07-13 12:35 ` Greg KH
2020-07-14  2:15   ` Valdis Klētnieks
2020-07-14 14:36     ` Garrit Franke
2020-07-14 16:12       ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).