Re: [PATCH v2] kobject: add kernel/uevent_features sysfs file

From: Peter Rajnoha
Date: Fri Dec 07 2018 - 07:28:57 EST


On 12/7/18 1:01 PM, Greg KH wrote:
> On Fri, Dec 07, 2018 at 12:46:07PM +0100, Peter Rajnoha wrote:
>> This patch adds /sys/kernel/uevent_features file which currently lists
>> 'synthargs' string to denote that the kernel is able to recognize the
>> extended synthetic uevent arguments. Userspace can easily check for
>> the feature then.
>
> So this is just to try to have userspace detect what type of feature the
> kernel has? Why can't you just go off of the other sysfs file itself?
> You shouldn't need a "this is a feature list" for the kernel, otherwise
> we would be on a huge slippery slope trying to document everything.
>
> Who is going to use this thing? And what else would go into it?
>
> Isn't there some other way you can detect this from userspace (like
> writing to the file and it fails?)
>

Yes, it's for userspace to be sure that uevent interface has certain
features available that it can use.

For now, it's just that "synthetic uevent arguments" that is the
extension of the original uevent interface. That applies to both input
(writing to /sys/.../uevent file) and output (related extra variables
that appear in generated uevents).

The obvious user of this is going to be systemd/udev that will add extra
variables to identify various synthetic uevents it produces (coming as
result of the WATCH udev rule, coming from the udevadm trigger call and
other specific uses where it needs to generate synthetic uevents). Other
users I know of involve storage handling tools which need to generate
these synthetic uevents whenever a change happens and it needs to
synchronize with udevd processing (e.g. waiting on refresh to get
reflected in udev database).

I understand that there is an argument that we can just use kernel
version check, but this is not acceptable for all unfortunately (see
also https://github.com/systemd/systemd/pull/7294#issuecomment-343491015).

The issue with checking the return code after writing to /sys/.../uevent
is that it doesn't work with older kernel releases because there, it
always returned success, no matter if the input string was correct or
not or whether the arguments were recognized (unfortunately, this was
like that from beginning, it seems). Even though, I've fixed this return
code with df44b479 recently, but still, there are possible older
releases out there... And still, there might be new variables introduced
in the future that don't necessarily need to be direct result of writing
to /sys/.../uevent file.

--
Peter