diff mbox series

[LEDE-DEV,V1,RFC,procd] udevtrigger: trigger devices w/o dev sysfs entry

Message ID 1521732138-10688-1-git-send-email-sakib@darkstar.site
State New
Headers show
Series [LEDE-DEV,V1,RFC,procd] udevtrigger: trigger devices w/o dev sysfs entry | expand

Commit Message

Sergiy Kibrik March 22, 2018, 3:22 p.m. UTC
A lot of devices aren't represented via major/minor numbers
and thus don't have dev entry in their sysfs directory, like
network devices, USB, power supplies etc.
It looks to be the rigth thing to trigger them as well.

Anyway, it's up to the hotplug daemon to decide what to do with devices,
it needs full vision of what's present in the system.

Signed-off-by: Sergiy Kibrik <sakib@darkstar.site>
---
 plug/udevtrigger.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

John Crispin May 5, 2018, 5:48 a.m. UTC | #1
On 22/03/18 16:22, Sergiy Kibrik wrote:
> A lot of devices aren't represented via major/minor numbers
> and thus don't have dev entry in their sysfs directory, like
> network devices, USB, power supplies etc.
> It looks to be the rigth thing to trigger them as well.
>
> Anyway, it's up to the hotplug daemon to decide what to do with devices,
> it needs full vision of what's present in the system.
>
> Signed-off-by: Sergiy Kibrik <sakib@darkstar.site>

Hi,
sorry for the late reply. i just ran this patch on a router and it slows 
boot down by ~1sec due to having to process a huge pile of extra events.

--- before ---
[    5.124584] random: procd: uninitialized urandom read (4 bytes read)
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[    7.489347] procd: - early -

--- after ---
[    5.128390] random: procd: uninitialized urandom read (4 bytes read)
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[    8.345346] procd: - early -

are you trying to grab events for a specific device type ? maybe we can 
narrow this down a bit more and not process all events during coldplug.

     John
> ---
>   plug/udevtrigger.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/plug/udevtrigger.c b/plug/udevtrigger.c
> index f87a95e..d6c4c4c 100644
> --- a/plug/udevtrigger.c
> +++ b/plug/udevtrigger.c
> @@ -161,9 +161,8 @@ static int device_list_insert(const char *path)
>   
>   	dbg("add '%s'" , path);
>   
> -	/* we only have a device, if we have a dev and an uevent file */
> -	if (!device_has_attribute(path, "/dev", S_IRUSR) ||
> -	    !device_has_attribute(path, "/uevent", S_IWUSR))
> +	/* we only have a device, if we have an uevent file */
> +	if (!device_has_attribute(path, "/uevent", S_IWUSR))
>   		return -1;
>   
>   	strlcpy(devpath, &path[4], sizeof(devpath));
Sergiy Kibrik May 7, 2018, 8:25 p.m. UTC | #2
hi John,

On 5/5/18 8:48 AM, John Crispin wrote:
> 
> 
> On 22/03/18 16:22, Sergiy Kibrik wrote:
>> A lot of devices aren't represented via major/minor numbers
>> and thus don't have dev entry in their sysfs directory, like
>> network devices, USB, power supplies etc.
>> It looks to be the rigth thing to trigger them as well.
>>
>> Anyway, it's up to the hotplug daemon to decide what to do with devices,
>> it needs full vision of what's present in the system.
>>
>> Signed-off-by: Sergiy Kibrik <sakib@darkstar.site>
> 
> Hi,
> sorry for the late reply. i just ran this patch on a router and it slows
> boot down by ~1sec due to having to process a huge pile of extra events.
> 
> --- before ---
> [    5.124584] random: procd: uninitialized urandom read (4 bytes read)
> Press the [f] key and hit [enter] to enter failsafe mode
> Press the [1], [2], [3] or [4] key and hit [enter] to select the debug
> level
> [    7.489347] procd: - early -
> 
> --- after ---
> [    5.128390] random: procd: uninitialized urandom read (4 bytes read)
> Press the [f] key and hit [enter] to enter failsafe mode
> Press the [1], [2], [3] or [4] key and hit [enter] to select the debug
> level
> [    8.345346] procd: - early -
> 
> are you trying to grab events for a specific device type ? maybe we can
> narrow this down a bit more and not process all events during coldplug.
> 

I'm detecting a hotplug (or disconnect) of USB OTG power supply.
Device classes which aren't represented by dev entry seem to be left w/o
a sensible way to handle events from them...

--
regards,
Sergiy
diff mbox series

Patch

diff --git a/plug/udevtrigger.c b/plug/udevtrigger.c
index f87a95e..d6c4c4c 100644
--- a/plug/udevtrigger.c
+++ b/plug/udevtrigger.c
@@ -161,9 +161,8 @@  static int device_list_insert(const char *path)
 
 	dbg("add '%s'" , path);
 
-	/* we only have a device, if we have a dev and an uevent file */
-	if (!device_has_attribute(path, "/dev", S_IRUSR) ||
-	    !device_has_attribute(path, "/uevent", S_IWUSR))
+	/* we only have a device, if we have an uevent file */
+	if (!device_has_attribute(path, "/uevent", S_IWUSR))
 		return -1;
 
 	strlcpy(devpath, &path[4], sizeof(devpath));