All of lore.kernel.org
 help / color / mirror / Atom feed
* Userland breakage from "Modify the device name as devfreq(X) for sysfs"
@ 2018-05-08 23:17 ` John Stultz
  2018-05-09  2:28   ` Chanwoo Choi
  0 siblings, 1 reply; 8+ messages in thread
From: John Stultz @ 2018-05-08 23:17 UTC (permalink / raw)
  To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park
  Cc: Dmitry Shmidt, Leo Yan, Jean Wangtao, lkml, Greg KH

Hey folks,
  I wanted to bring up an issue we've recently tripped over, which was
caused by 4585fbcb5331f ("PM / devfreq: Modify the device name as
devfreq(X) for sysfs").
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4585fbcb5331fc910b7e553ad3efd0dd7b320d14

That patch replaced paths like:
   /sys/class/devfreq/ddr_devfreq/min_freq
and
  /sys/class/devfreq/e82c0000.mali/min_freq

With
  /sys/class/devfreq/devfreq(0)/min_freq
and
  /sys/class/devfreq/devfreq(1)/min_freq


This broke userspace we have that needs to work on 4.4, 4.9 and 4.14 (and on).

I wanted to try to ask to understand more about the rational for this
patch, as it doesn't make much sense to me, particularly as now it is
less obvious as to which path is for which device  - and more
worrisome it could change depending on initialization order.

Unfortunately, this wasn't noticed very quickly, as the patch has been
upstream now for some time.  But I wanted to better understand why
this change was made, and see if we might consider reverting it, or
alternatively consider provide multiple sysfs links (both dev_name and
devfreq(N)) so that we can preserve compatibility?

Thoughts?
-john

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

* Re: Userland breakage from "Modify the device name as devfreq(X) for sysfs"
  2018-05-08 23:17 ` Userland breakage from "Modify the device name as devfreq(X) for sysfs" John Stultz
@ 2018-05-09  2:28   ` Chanwoo Choi
  2018-05-09 14:12     ` Kevin Wangtao
  2018-05-30  5:14     ` John Stultz
  0 siblings, 2 replies; 8+ messages in thread
From: Chanwoo Choi @ 2018-05-09  2:28 UTC (permalink / raw)
  To: John Stultz, MyungJoo Ham, Kyungmin Park
  Cc: Leo Yan, Jean Wangtao, lkml, Greg KH

Hi John,

On 2018년 05월 09일 08:17, John Stultz wrote:
> Hey folks,
>   I wanted to bring up an issue we've recently tripped over, which was
> caused by 4585fbcb5331f ("PM / devfreq: Modify the device name as
> devfreq(X) for sysfs").
>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4585fbcb5331fc910b7e553ad3efd0dd7b320d14
> 
> That patch replaced paths like:
>    /sys/class/devfreq/ddr_devfreq/min_freq
> and
>   /sys/class/devfreq/e82c0000.mali/min_freq
> 
> With
>   /sys/class/devfreq/devfreq(0)/min_freq
> and
>   /sys/class/devfreq/devfreq(1)/min_freq
> 
> 
> This broke userspace we have that needs to work on 4.4, 4.9 and 4.14 (and on).

Firstly, I'm sorry to make some problem on userland.

> 
> I wanted to try to ask to understand more about the rational for this
> patch, as it doesn't make much sense to me, particularly as now it is
> less obvious as to which path is for which device  - and more
> worrisome it could change depending on initialization order.

Some linux framework used the their own prefix under "/sys/class/"
for device such as input/pwm/hwmon/regulator and so on.
(But, some linux framework used the device name directly without any changes)

I thought that devfreq better to use use the consistent name.
If user wanted to access the specific device with device name,
the user can access the path of '/sys/devices/platform/...'.

[Example on Exynos5433-based TM2 board]
root@localhost:~# ls -al /sys/class/devfreq
total 0
drwxr-xr-x  2 root root 0 Jul 26 04:49 .
drwxr-xr-x 50 root root 0 Jan  1  1970 ..
lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq0 -> ../../devices/platform/soc/soc:bus0/devfreq/devfreq0
lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq1 -> ../../devices/platform/soc/soc:bus1/devfreq/devfreq1
(skip)

- User can access the devfreq device with specific device name.
root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# pwd
/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0

root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# ls
available_frequencies  device    min_freq          subsystem    uevent
available_governors    governor  polling_interval  target_freq
cur_freq               max_freq  power             trans_stat

root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# cat min_freq 
160000000


But, there is one of my mistake. The /sys/class/devfreq/devfreq(X)
doesn't have the 'name' attribute. So, the user cannot find the required
device. It is my mistake. I'll add the 'name' attribute as following:
- /sys/class/devfreq/devfreqX/name

> 
> Unfortunately, this wasn't noticed very quickly, as the patch has been
> upstream now for some time.  But I wanted to better understand why
> this change was made, and see if we might consider reverting it, or
> alternatively consider provide multiple sysfs links (both dev_name and
> devfreq(N)) so that we can preserve compatibility?

Unfortunately, there are no frameworks which provide the both dev_name and
[defined prefix](N) link under /sys/class/. I'm not sure this way.

As you comment, devfreq(number) is not fixed as the initialization order.
After adding the 'name' attribute, the user can find the specific device.

How about using the 'name' attribute to find the device
after adding new 'name' attribute when access device through /sys/class?


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

* Re: Userland breakage from "Modify the device name as devfreq(X) for sysfs"
  2018-05-09  2:28   ` Chanwoo Choi
@ 2018-05-09 14:12     ` Kevin Wangtao
  2018-05-30  5:14     ` John Stultz
  1 sibling, 0 replies; 8+ messages in thread
From: Kevin Wangtao @ 2018-05-09 14:12 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: John Stultz, MyungJoo Ham, Kyungmin Park, Leo Yan, lkml, Greg KH

Hi Chanwoo Choi,

>From my point of view, if it is a new framework, you can use either
the consistent name or device name,
but as a framework has been used for several kernel version, you
should not change the device name
easily if there is no special reason, It will bring no benefits except
for confusion and compatibility issues.
Hope you reconsider.

Regards,
Kevin

On 9 May 2018 at 10:28, Chanwoo Choi <cw00.choi@samsung.com> wrote:
> Hi John,
>
> On 2018년 05월 09일 08:17, John Stultz wrote:
>> Hey folks,
>>   I wanted to bring up an issue we've recently tripped over, which was
>> caused by 4585fbcb5331f ("PM / devfreq: Modify the device name as
>> devfreq(X) for sysfs").
>>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4585fbcb5331fc910b7e553ad3efd0dd7b320d14
>>
>> That patch replaced paths like:
>>    /sys/class/devfreq/ddr_devfreq/min_freq
>> and
>>   /sys/class/devfreq/e82c0000.mali/min_freq
>>
>> With
>>   /sys/class/devfreq/devfreq(0)/min_freq
>> and
>>   /sys/class/devfreq/devfreq(1)/min_freq
>>
>>
>> This broke userspace we have that needs to work on 4.4, 4.9 and 4.14 (and on).
>
> Firstly, I'm sorry to make some problem on userland.
>
>>
>> I wanted to try to ask to understand more about the rational for this
>> patch, as it doesn't make much sense to me, particularly as now it is
>> less obvious as to which path is for which device  - and more
>> worrisome it could change depending on initialization order.
>
> Some linux framework used the their own prefix under "/sys/class/"
> for device such as input/pwm/hwmon/regulator and so on.
> (But, some linux framework used the device name directly without any changes)
>
> I thought that devfreq better to use use the consistent name.
> If user wanted to access the specific device with device name,
> the user can access the path of '/sys/devices/platform/...'.
>
> [Example on Exynos5433-based TM2 board]
> root@localhost:~# ls -al /sys/class/devfreq
> total 0
> drwxr-xr-x  2 root root 0 Jul 26 04:49 .
> drwxr-xr-x 50 root root 0 Jan  1  1970 ..
> lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq0 -> ../../devices/platform/soc/soc:bus0/devfreq/devfreq0
> lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq1 -> ../../devices/platform/soc/soc:bus1/devfreq/devfreq1
> (skip)
>
> - User can access the devfreq device with specific device name.
> root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# pwd
> /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
>
> root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# ls
> available_frequencies  device    min_freq          subsystem    uevent
> available_governors    governor  polling_interval  target_freq
> cur_freq               max_freq  power             trans_stat
>
> root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# cat min_freq
> 160000000
>
>
> But, there is one of my mistake. The /sys/class/devfreq/devfreq(X)
> doesn't have the 'name' attribute. So, the user cannot find the required
> device. It is my mistake. I'll add the 'name' attribute as following:
> - /sys/class/devfreq/devfreqX/name
>
>>
>> Unfortunately, this wasn't noticed very quickly, as the patch has been
>> upstream now for some time.  But I wanted to better understand why
>> this change was made, and see if we might consider reverting it, or
>> alternatively consider provide multiple sysfs links (both dev_name and
>> devfreq(N)) so that we can preserve compatibility?
>
> Unfortunately, there are no frameworks which provide the both dev_name and
> [defined prefix](N) link under /sys/class/. I'm not sure this way.
>
> As you comment, devfreq(number) is not fixed as the initialization order.
> After adding the 'name' attribute, the user can find the specific device.
>
> How about using the 'name' attribute to find the device
> after adding new 'name' attribute when access device through /sys/class?
>
>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics

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

* Re: Userland breakage from "Modify the device name as devfreq(X) for sysfs"
  2018-05-09  2:28   ` Chanwoo Choi
  2018-05-09 14:12     ` Kevin Wangtao
@ 2018-05-30  5:14     ` John Stultz
  2018-05-30  5:33       ` Greg KH
  1 sibling, 1 reply; 8+ messages in thread
From: John Stultz @ 2018-05-30  5:14 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: MyungJoo Ham, Kyungmin Park, Leo Yan, Jean Wangtao, lkml, Greg KH

On Tue, May 8, 2018 at 7:28 PM, Chanwoo Choi <cw00.choi@samsung.com> wrote:
> On 2018년 05월 09일 08:17, John Stultz wrote:
>> Hey folks,
>>   I wanted to bring up an issue we've recently tripped over, which was
>> caused by 4585fbcb5331f ("PM / devfreq: Modify the device name as
>> devfreq(X) for sysfs").
>>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4585fbcb5331fc910b7e553ad3efd0dd7b320d14
>>
>> That patch replaced paths like:
>>    /sys/class/devfreq/ddr_devfreq/min_freq
>> and
>>   /sys/class/devfreq/e82c0000.mali/min_freq
>>
>> With
>>   /sys/class/devfreq/devfreq(0)/min_freq
>> and
>>   /sys/class/devfreq/devfreq(1)/min_freq
>>
>>
>> This broke userspace we have that needs to work on 4.4, 4.9 and 4.14 (and on).
>
> Firstly, I'm sorry to make some problem on userland.
>
>>
>> I wanted to try to ask to understand more about the rational for this
>> patch, as it doesn't make much sense to me, particularly as now it is
>> less obvious as to which path is for which device  - and more
>> worrisome it could change depending on initialization order.
>
> Some linux framework used the their own prefix under "/sys/class/"
> for device such as input/pwm/hwmon/regulator and so on.
> (But, some linux framework used the device name directly without any changes)
>
> I thought that devfreq better to use use the consistent name.
> If user wanted to access the specific device with device name,
> the user can access the path of '/sys/devices/platform/...'.
>
> [Example on Exynos5433-based TM2 board]
> root@localhost:~# ls -al /sys/class/devfreq
> total 0
> drwxr-xr-x  2 root root 0 Jul 26 04:49 .
> drwxr-xr-x 50 root root 0 Jan  1  1970 ..
> lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq0 -> ../../devices/platform/soc/soc:bus0/devfreq/devfreq0
> lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq1 -> ../../devices/platform/soc/soc:bus1/devfreq/devfreq1
> (skip)
>
> - User can access the devfreq device with specific device name.
> root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# pwd
> /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
>
> root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# ls
> available_frequencies  device    min_freq          subsystem    uevent
> available_governors    governor  polling_interval  target_freq
> cur_freq               max_freq  power             trans_stat
>
> root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# cat min_freq
> 160000000
>

Sorry to not get back to you sooner on this. Was on vacation then this
discussion got buried in my inbox.

I do agree that it the consistency with other subsystems is an
improvement, but it still doesn't help our situation that userspace
applications can't consistently work between kernel versions, as even
if we go with the /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
path rather then the /sys/class/devfreq/ path, in older kernels the
/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0 doesn't exist.

> But, there is one of my mistake. The /sys/class/devfreq/devfreq(X)
> doesn't have the 'name' attribute. So, the user cannot find the required
> device. It is my mistake. I'll add the 'name' attribute as following:
> - /sys/class/devfreq/devfreqX/name

I agree that would be an improvement.

>> Unfortunately, this wasn't noticed very quickly, as the patch has been
>> upstream now for some time.  But I wanted to better understand why
>> this change was made, and see if we might consider reverting it, or
>> alternatively consider provide multiple sysfs links (both dev_name and
>> devfreq(N)) so that we can preserve compatibility?
>
> Unfortunately, there are no frameworks which provide the both dev_name and
> [defined prefix](N) link under /sys/class/. I'm not sure this way.
>
> As you comment, devfreq(number) is not fixed as the initialization order.
> After adding the 'name' attribute, the user can find the specific device.
>
> How about using the 'name' attribute to find the device
> after adding new 'name' attribute when access device through /sys/class?

I agree we need a name attribute so folks can tell the difference
between devices.

I'm also not too much of a stickler that the old ABI broke, as long as
we have some solution that works across kernels. So I'd request that
you at least make older -stable kernels (4.4 and 4.9) behavior
consistent with upstream.

thanks
-john

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

* Re: Userland breakage from "Modify the device name as devfreq(X) for sysfs"
  2018-05-30  5:14     ` John Stultz
@ 2018-05-30  5:33       ` Greg KH
  2018-05-30  6:52         ` John Stultz
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2018-05-30  5:33 UTC (permalink / raw)
  To: John Stultz
  Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Leo Yan, Jean Wangtao, lkml

On Tue, May 29, 2018 at 10:14:35PM -0700, John Stultz wrote:
> On Tue, May 8, 2018 at 7:28 PM, Chanwoo Choi <cw00.choi@samsung.com> wrote:
> > On 2018년 05월 09일 08:17, John Stultz wrote:
> >> Hey folks,
> >>   I wanted to bring up an issue we've recently tripped over, which was
> >> caused by 4585fbcb5331f ("PM / devfreq: Modify the device name as
> >> devfreq(X) for sysfs").
> >>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4585fbcb5331fc910b7e553ad3efd0dd7b320d14
> >>
> >> That patch replaced paths like:
> >>    /sys/class/devfreq/ddr_devfreq/min_freq
> >> and
> >>   /sys/class/devfreq/e82c0000.mali/min_freq
> >>
> >> With
> >>   /sys/class/devfreq/devfreq(0)/min_freq
> >> and
> >>   /sys/class/devfreq/devfreq(1)/min_freq
> >>
> >>
> >> This broke userspace we have that needs to work on 4.4, 4.9 and 4.14 (and on).
> >
> > Firstly, I'm sorry to make some problem on userland.
> >
> >>
> >> I wanted to try to ask to understand more about the rational for this
> >> patch, as it doesn't make much sense to me, particularly as now it is
> >> less obvious as to which path is for which device  - and more
> >> worrisome it could change depending on initialization order.
> >
> > Some linux framework used the their own prefix under "/sys/class/"
> > for device such as input/pwm/hwmon/regulator and so on.
> > (But, some linux framework used the device name directly without any changes)
> >
> > I thought that devfreq better to use use the consistent name.
> > If user wanted to access the specific device with device name,
> > the user can access the path of '/sys/devices/platform/...'.
> >
> > [Example on Exynos5433-based TM2 board]
> > root@localhost:~# ls -al /sys/class/devfreq
> > total 0
> > drwxr-xr-x  2 root root 0 Jul 26 04:49 .
> > drwxr-xr-x 50 root root 0 Jan  1  1970 ..
> > lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq0 -> ../../devices/platform/soc/soc:bus0/devfreq/devfreq0
> > lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq1 -> ../../devices/platform/soc/soc:bus1/devfreq/devfreq1
> > (skip)
> >
> > - User can access the devfreq device with specific device name.
> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# pwd
> > /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
> >
> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# ls
> > available_frequencies  device    min_freq          subsystem    uevent
> > available_governors    governor  polling_interval  target_freq
> > cur_freq               max_freq  power             trans_stat
> >
> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# cat min_freq
> > 160000000
> >
> 
> Sorry to not get back to you sooner on this. Was on vacation then this
> discussion got buried in my inbox.
> 
> I do agree that it the consistency with other subsystems is an
> improvement, but it still doesn't help our situation that userspace
> applications can't consistently work between kernel versions, as even
> if we go with the /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
> path rather then the /sys/class/devfreq/ path, in older kernels the
> /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0 doesn't exist.

Ick, that's not ok.  The sys/class/ path should always work for old and
new.  If not, it's broken and should be reverted.

And it seems like it still works, just that the "names" are now
different in the class path, of the device, right?  And that should be
fine, what is breaking when a device name changes?

> > But, there is one of my mistake. The /sys/class/devfreq/devfreq(X)
> > doesn't have the 'name' attribute. So, the user cannot find the required
> > device. It is my mistake. I'll add the 'name' attribute as following:
> > - /sys/class/devfreq/devfreqX/name
> 
> I agree that would be an improvement.
> 
> >> Unfortunately, this wasn't noticed very quickly, as the patch has been
> >> upstream now for some time.  But I wanted to better understand why
> >> this change was made, and see if we might consider reverting it, or
> >> alternatively consider provide multiple sysfs links (both dev_name and
> >> devfreq(N)) so that we can preserve compatibility?
> >
> > Unfortunately, there are no frameworks which provide the both dev_name and
> > [defined prefix](N) link under /sys/class/. I'm not sure this way.
> >
> > As you comment, devfreq(number) is not fixed as the initialization order.
> > After adding the 'name' attribute, the user can find the specific device.
> >
> > How about using the 'name' attribute to find the device
> > after adding new 'name' attribute when access device through /sys/class?
> 
> I agree we need a name attribute so folks can tell the difference
> between devices.
> 
> I'm also not too much of a stickler that the old ABI broke, as long as
> we have some solution that works across kernels. So I'd request that
> you at least make older -stable kernels (4.4 and 4.9) behavior
> consistent with upstream.

No, I don't want to backport api changes like that as then users of
those kernels that were working just fine break :)

So I think mainline needs to revert this.

thanks,

greg k-h

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

* Re: Userland breakage from "Modify the device name as devfreq(X) for sysfs"
  2018-05-30  5:33       ` Greg KH
@ 2018-05-30  6:52         ` John Stultz
  2018-05-30  7:31           ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: John Stultz @ 2018-05-30  6:52 UTC (permalink / raw)
  To: Greg KH
  Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Leo Yan, Jean Wangtao, lkml

On Tue, May 29, 2018 at 10:33 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Tue, May 29, 2018 at 10:14:35PM -0700, John Stultz wrote:
>> On Tue, May 8, 2018 at 7:28 PM, Chanwoo Choi <cw00.choi@samsung.com> wrote:
>> > On 2018년 05월 09일 08:17, John Stultz wrote:
>> >> Hey folks,
>> >>   I wanted to bring up an issue we've recently tripped over, which was
>> >> caused by 4585fbcb5331f ("PM / devfreq: Modify the device name as
>> >> devfreq(X) for sysfs").
>> >>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4585fbcb5331fc910b7e553ad3efd0dd7b320d14
>> >>
>> >> That patch replaced paths like:
>> >>    /sys/class/devfreq/ddr_devfreq/min_freq
>> >> and
>> >>   /sys/class/devfreq/e82c0000.mali/min_freq
>> >>
>> >> With
>> >>   /sys/class/devfreq/devfreq(0)/min_freq
>> >> and
>> >>   /sys/class/devfreq/devfreq(1)/min_freq
>> >>
>> >>
>> >> This broke userspace we have that needs to work on 4.4, 4.9 and 4.14 (and on).
>> >
>> > Firstly, I'm sorry to make some problem on userland.
>> >
>> >>
>> >> I wanted to try to ask to understand more about the rational for this
>> >> patch, as it doesn't make much sense to me, particularly as now it is
>> >> less obvious as to which path is for which device  - and more
>> >> worrisome it could change depending on initialization order.
>> >
>> > Some linux framework used the their own prefix under "/sys/class/"
>> > for device such as input/pwm/hwmon/regulator and so on.
>> > (But, some linux framework used the device name directly without any changes)
>> >
>> > I thought that devfreq better to use use the consistent name.
>> > If user wanted to access the specific device with device name,
>> > the user can access the path of '/sys/devices/platform/...'.
>> >
>> > [Example on Exynos5433-based TM2 board]
>> > root@localhost:~# ls -al /sys/class/devfreq
>> > total 0
>> > drwxr-xr-x  2 root root 0 Jul 26 04:49 .
>> > drwxr-xr-x 50 root root 0 Jan  1  1970 ..
>> > lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq0 -> ../../devices/platform/soc/soc:bus0/devfreq/devfreq0
>> > lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq1 -> ../../devices/platform/soc/soc:bus1/devfreq/devfreq1
>> > (skip)
>> >
>> > - User can access the devfreq device with specific device name.
>> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# pwd
>> > /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
>> >
>> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# ls
>> > available_frequencies  device    min_freq          subsystem    uevent
>> > available_governors    governor  polling_interval  target_freq
>> > cur_freq               max_freq  power             trans_stat
>> >
>> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# cat min_freq
>> > 160000000
>> >
>>
>> Sorry to not get back to you sooner on this. Was on vacation then this
>> discussion got buried in my inbox.
>>
>> I do agree that it the consistency with other subsystems is an
>> improvement, but it still doesn't help our situation that userspace
>> applications can't consistently work between kernel versions, as even
>> if we go with the /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
>> path rather then the /sys/class/devfreq/ path, in older kernels the
>> /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0 doesn't exist.
>
> Ick, that's not ok.  The sys/class/ path should always work for old and
> new.  If not, it's broken and should be reverted.
>
> And it seems like it still works, just that the "names" are now
> different in the class path, of the device, right?  And that should be
> fine, what is breaking when a device name changes?

Well, code that is looking for:
/sys/class/devfreq/ddr_devfreq/min_freq

won't work with newer kernels unless its changed to look for:
/sys/class/devfreq/devfreq0/min_freq

(assuming the ddr_devfreq driver loaded before the mali one :)

>> I agree we need a name attribute so folks can tell the difference
>> between devices.
>>
>> I'm also not too much of a stickler that the old ABI broke, as long as
>> we have some solution that works across kernels. So I'd request that
>> you at least make older -stable kernels (4.4 and 4.9) behavior
>> consistent with upstream.
>
> No, I don't want to backport api changes like that as then users of
> those kernels that were working just fine break :)
>
> So I think mainline needs to revert this.

The trouble is that the break happened awhile back (4.10) so if we
revert its likely to break any new users since then.

That's why I suggested we find some way to have both paths work. But I
don't know enough sysfs tricks to have a good suggestion on how to
easily do so.

thanks
-john

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

* Re: Userland breakage from "Modify the device name as devfreq(X) for sysfs"
  2018-05-30  6:52         ` John Stultz
@ 2018-05-30  7:31           ` Greg KH
  2018-05-30 17:00             ` John Stultz
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2018-05-30  7:31 UTC (permalink / raw)
  To: John Stultz
  Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Leo Yan, Jean Wangtao, lkml

On Tue, May 29, 2018 at 11:52:37PM -0700, John Stultz wrote:
> On Tue, May 29, 2018 at 10:33 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> > On Tue, May 29, 2018 at 10:14:35PM -0700, John Stultz wrote:
> >> On Tue, May 8, 2018 at 7:28 PM, Chanwoo Choi <cw00.choi@samsung.com> wrote:
> >> > On 2018년 05월 09일 08:17, John Stultz wrote:
> >> >> Hey folks,
> >> >>   I wanted to bring up an issue we've recently tripped over, which was
> >> >> caused by 4585fbcb5331f ("PM / devfreq: Modify the device name as
> >> >> devfreq(X) for sysfs").
> >> >>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4585fbcb5331fc910b7e553ad3efd0dd7b320d14
> >> >>
> >> >> That patch replaced paths like:
> >> >>    /sys/class/devfreq/ddr_devfreq/min_freq
> >> >> and
> >> >>   /sys/class/devfreq/e82c0000.mali/min_freq
> >> >>
> >> >> With
> >> >>   /sys/class/devfreq/devfreq(0)/min_freq
> >> >> and
> >> >>   /sys/class/devfreq/devfreq(1)/min_freq
> >> >>
> >> >>
> >> >> This broke userspace we have that needs to work on 4.4, 4.9 and 4.14 (and on).
> >> >
> >> > Firstly, I'm sorry to make some problem on userland.
> >> >
> >> >>
> >> >> I wanted to try to ask to understand more about the rational for this
> >> >> patch, as it doesn't make much sense to me, particularly as now it is
> >> >> less obvious as to which path is for which device  - and more
> >> >> worrisome it could change depending on initialization order.
> >> >
> >> > Some linux framework used the their own prefix under "/sys/class/"
> >> > for device such as input/pwm/hwmon/regulator and so on.
> >> > (But, some linux framework used the device name directly without any changes)
> >> >
> >> > I thought that devfreq better to use use the consistent name.
> >> > If user wanted to access the specific device with device name,
> >> > the user can access the path of '/sys/devices/platform/...'.
> >> >
> >> > [Example on Exynos5433-based TM2 board]
> >> > root@localhost:~# ls -al /sys/class/devfreq
> >> > total 0
> >> > drwxr-xr-x  2 root root 0 Jul 26 04:49 .
> >> > drwxr-xr-x 50 root root 0 Jan  1  1970 ..
> >> > lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq0 -> ../../devices/platform/soc/soc:bus0/devfreq/devfreq0
> >> > lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq1 -> ../../devices/platform/soc/soc:bus1/devfreq/devfreq1
> >> > (skip)
> >> >
> >> > - User can access the devfreq device with specific device name.
> >> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# pwd
> >> > /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
> >> >
> >> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# ls
> >> > available_frequencies  device    min_freq          subsystem    uevent
> >> > available_governors    governor  polling_interval  target_freq
> >> > cur_freq               max_freq  power             trans_stat
> >> >
> >> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# cat min_freq
> >> > 160000000
> >> >
> >>
> >> Sorry to not get back to you sooner on this. Was on vacation then this
> >> discussion got buried in my inbox.
> >>
> >> I do agree that it the consistency with other subsystems is an
> >> improvement, but it still doesn't help our situation that userspace
> >> applications can't consistently work between kernel versions, as even
> >> if we go with the /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
> >> path rather then the /sys/class/devfreq/ path, in older kernels the
> >> /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0 doesn't exist.
> >
> > Ick, that's not ok.  The sys/class/ path should always work for old and
> > new.  If not, it's broken and should be reverted.
> >
> > And it seems like it still works, just that the "names" are now
> > different in the class path, of the device, right?  And that should be
> > fine, what is breaking when a device name changes?
> 
> Well, code that is looking for:
> /sys/class/devfreq/ddr_devfreq/min_freq
> 
> won't work with newer kernels unless its changed to look for:
> /sys/class/devfreq/devfreq0/min_freq
> 
> (assuming the ddr_devfreq driver loaded before the mali one :)

Ugh.  In working with sysfs you should never care about the device name,
you should be iterating over:
	/sys/class/devfreq/*/min_freq

and just picking up the one you find that has a link back to whatever
you want it to be.  Device names are not deterministic, as you even
claim here as you were somehow depending on the module load order :)

So if/when a device name changes, userspace always has to handle that
properly.

What tool/script is failing here?  What package is it part of so that we
can fix it to use sysfs "properly"?

Now if somehow we can not figure out _which_ devfreq class device is
associated with the "correct" real device, then that's a problem and
needs to be fixed.  But changing the naming scheme is not the proper fix
for that.

> >> I agree we need a name attribute so folks can tell the difference
> >> between devices.
> >>
> >> I'm also not too much of a stickler that the old ABI broke, as long as
> >> we have some solution that works across kernels. So I'd request that
> >> you at least make older -stable kernels (4.4 and 4.9) behavior
> >> consistent with upstream.
> >
> > No, I don't want to backport api changes like that as then users of
> > those kernels that were working just fine break :)
> >
> > So I think mainline needs to revert this.
> 
> The trouble is that the break happened awhile back (4.10) so if we
> revert its likely to break any new users since then.
> 
> That's why I suggested we find some way to have both paths work. But I
> don't know enough sysfs tricks to have a good suggestion on how to
> easily do so.

We have compatible symlinks all over the place in sysfs, usually we try
to bury them behind config options for when you have to run new kernels
on old userspace implementations.  But sometimes we just let them live
on for forever...

What exactly would need to be linked to what in order to keep this
working?

thanks,

greg k-h

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

* Re: Userland breakage from "Modify the device name as devfreq(X) for sysfs"
  2018-05-30  7:31           ` Greg KH
@ 2018-05-30 17:00             ` John Stultz
  0 siblings, 0 replies; 8+ messages in thread
From: John Stultz @ 2018-05-30 17:00 UTC (permalink / raw)
  To: Greg KH
  Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Leo Yan, Jean Wangtao, lkml

On Wed, May 30, 2018 at 12:31 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Tue, May 29, 2018 at 11:52:37PM -0700, John Stultz wrote:
>> On Tue, May 29, 2018 at 10:33 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> > On Tue, May 29, 2018 at 10:14:35PM -0700, John Stultz wrote:
>> >> On Tue, May 8, 2018 at 7:28 PM, Chanwoo Choi <cw00.choi@samsung.com> wrote:
>> >> > On 2018년 05월 09일 08:17, John Stultz wrote:
>> >> >> Hey folks,
>> >> >>   I wanted to bring up an issue we've recently tripped over, which was
>> >> >> caused by 4585fbcb5331f ("PM / devfreq: Modify the device name as
>> >> >> devfreq(X) for sysfs").
>> >> >>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4585fbcb5331fc910b7e553ad3efd0dd7b320d14
>> >> >>
>> >> >> That patch replaced paths like:
>> >> >>    /sys/class/devfreq/ddr_devfreq/min_freq
>> >> >> and
>> >> >>   /sys/class/devfreq/e82c0000.mali/min_freq
>> >> >>
>> >> >> With
>> >> >>   /sys/class/devfreq/devfreq(0)/min_freq
>> >> >> and
>> >> >>   /sys/class/devfreq/devfreq(1)/min_freq
>> >> >>
>> >> >>
>> >> >> This broke userspace we have that needs to work on 4.4, 4.9 and 4.14 (and on).
>> >> >
>> >> > Firstly, I'm sorry to make some problem on userland.
>> >> >
>> >> >>
>> >> >> I wanted to try to ask to understand more about the rational for this
>> >> >> patch, as it doesn't make much sense to me, particularly as now it is
>> >> >> less obvious as to which path is for which device  - and more
>> >> >> worrisome it could change depending on initialization order.
>> >> >
>> >> > Some linux framework used the their own prefix under "/sys/class/"
>> >> > for device such as input/pwm/hwmon/regulator and so on.
>> >> > (But, some linux framework used the device name directly without any changes)
>> >> >
>> >> > I thought that devfreq better to use use the consistent name.
>> >> > If user wanted to access the specific device with device name,
>> >> > the user can access the path of '/sys/devices/platform/...'.
>> >> >
>> >> > [Example on Exynos5433-based TM2 board]
>> >> > root@localhost:~# ls -al /sys/class/devfreq
>> >> > total 0
>> >> > drwxr-xr-x  2 root root 0 Jul 26 04:49 .
>> >> > drwxr-xr-x 50 root root 0 Jan  1  1970 ..
>> >> > lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq0 -> ../../devices/platform/soc/soc:bus0/devfreq/devfreq0
>> >> > lrwxrwxrwx  1 root root 0 Jul 26 04:49 devfreq1 -> ../../devices/platform/soc/soc:bus1/devfreq/devfreq1
>> >> > (skip)
>> >> >
>> >> > - User can access the devfreq device with specific device name.
>> >> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# pwd
>> >> > /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
>> >> >
>> >> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# ls
>> >> > available_frequencies  device    min_freq          subsystem    uevent
>> >> > available_governors    governor  polling_interval  target_freq
>> >> > cur_freq               max_freq  power             trans_stat
>> >> >
>> >> > root@localhost:/sys/devices/platform/soc/soc:bus0/devfreq/devfreq0# cat min_freq
>> >> > 160000000
>> >> >
>> >>
>> >> Sorry to not get back to you sooner on this. Was on vacation then this
>> >> discussion got buried in my inbox.
>> >>
>> >> I do agree that it the consistency with other subsystems is an
>> >> improvement, but it still doesn't help our situation that userspace
>> >> applications can't consistently work between kernel versions, as even
>> >> if we go with the /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0
>> >> path rather then the /sys/class/devfreq/ path, in older kernels the
>> >> /sys/devices/platform/soc/soc:bus0/devfreq/devfreq0 doesn't exist.
>> >
>> > Ick, that's not ok.  The sys/class/ path should always work for old and
>> > new.  If not, it's broken and should be reverted.
>> >
>> > And it seems like it still works, just that the "names" are now
>> > different in the class path, of the device, right?  And that should be
>> > fine, what is breaking when a device name changes?
>>
>> Well, code that is looking for:
>> /sys/class/devfreq/ddr_devfreq/min_freq
>>
>> won't work with newer kernels unless its changed to look for:
>> /sys/class/devfreq/devfreq0/min_freq
>>
>> (assuming the ddr_devfreq driver loaded before the mali one :)
>
> Ugh.  In working with sysfs you should never care about the device name,
> you should be iterating over:
>         /sys/class/devfreq/*/min_freq
>
> and just picking up the one you find that has a link back to whatever
> you want it to be.  Device names are not deterministic, as you even
> claim here as you were somehow depending on the module load order :)

Well, previously it used the dev name, which was somewhat
deterministic (e82c0000.mali or ddr_devfreq) regardless of module load
order. Now, its just devfreqN, which obviously isn't deterministic.

Part of the trouble, as Chanwoo mentioned is there is no name entry,
so even iterating over the the devices, the devfreqN sysfs dirs are
indistinguishable.


> So if/when a device name changes, userspace always has to handle that
> properly.
>
> What tool/script is failing here?  What package is it part of so that we
> can fix it to use sysfs "properly"?

Its an Android PowerHAL for HiKey960 devices. I'm happy to change it
to make it work properly, but we do want it to work with 4.4, 4.9,
4.14 and mainline.

> Now if somehow we can not figure out _which_ devfreq class device is
> associated with the "correct" real device, then that's a problem and
> needs to be fixed.  But changing the naming scheme is not the proper fix
> for that.

Ok. So maybe if we get name entries added to both upstream and -stable
kernels, we can iterate over the directories if they are named
e82c0000.mali or devfreq0 all the same, and that might work out.


>> >> I agree we need a name attribute so folks can tell the difference
>> >> between devices.
>> >>
>> >> I'm also not too much of a stickler that the old ABI broke, as long as
>> >> we have some solution that works across kernels. So I'd request that
>> >> you at least make older -stable kernels (4.4 and 4.9) behavior
>> >> consistent with upstream.
>> >
>> > No, I don't want to backport api changes like that as then users of
>> > those kernels that were working just fine break :)
>> >
>> > So I think mainline needs to revert this.
>>
>> The trouble is that the break happened awhile back (4.10) so if we
>> revert its likely to break any new users since then.
>>
>> That's why I suggested we find some way to have both paths work. But I
>> don't know enough sysfs tricks to have a good suggestion on how to
>> easily do so.
>
> We have compatible symlinks all over the place in sysfs, usually we try
> to bury them behind config options for when you have to run new kernels
> on old userspace implementations.  But sometimes we just let them live
> on for forever...

Ok. I'll try to look that up.

> What exactly would need to be linked to what in order to keep this
> working?

I was thinking just having both dev_name() and devfreqN entries, but
with the name node added (to both newer and older kernels) we can
probably adapt to make it work w/o compatibility links.

thanks
-john

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

end of thread, other threads:[~2018-05-30 17:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180508231744epcas2p1251a2e35591e9d2624337d4c8f1d6974@epcas2p1.samsung.com>
2018-05-08 23:17 ` Userland breakage from "Modify the device name as devfreq(X) for sysfs" John Stultz
2018-05-09  2:28   ` Chanwoo Choi
2018-05-09 14:12     ` Kevin Wangtao
2018-05-30  5:14     ` John Stultz
2018-05-30  5:33       ` Greg KH
2018-05-30  6:52         ` John Stultz
2018-05-30  7:31           ` Greg KH
2018-05-30 17:00             ` John Stultz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.