mbox series

[v2,0/3] kselftest: Add test to report device log errors

Message ID 20240705-dev-err-log-selftest-v2-0-163b9cd7b3c1@collabora.com (mailing list archive)
Headers show
Series kselftest: Add test to report device log errors | expand

Message

Nícolas F. R. A. Prado July 5, 2024, 11:29 p.m. UTC
Log errors are the most widely used mechanism for reporting issues in
the kernel. When an error is logged using the device helpers, eg
dev_err(), it gets metadata attached that identifies the subsystem and
device where the message is coming from. This series makes use of that
metadata in a new test to report which devices logged errors.

The first two patches move a test and a helper script to keep things
organized before this new test is added in the third patch.

It is expected that there might be many false-positive error messages
throughout the drivers code which will be reported by this test. By
having this test in the first place and working through the results we
can address those occurrences by adjusting the loglevel of the messages
that turn out to not be real errors that require the user's attention.
It will also motivate additional error messages to be introduced in the
code to detect real errors where they turn out to be missing, since
it will be possible to detect said issues automatically.

As an example, below you can see the test result for
mt8192-asurada-spherion. The single standing issue has been investigated
and will be addressed in an EC firmware update [1]:

TAP version 13
1..1
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `model_name' property: -6
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
 power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
not ok 1 +power_supply:sbs-8-000b
 Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0

[1] https://lore.kernel.org/all/cf4d8131-4b63-4c7a-9f27-5a0847c656c4@notapiano

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
Changes in v2:
- Rebased onto next-20240703
- Link to v1: https://lore.kernel.org/r/20240423-dev-err-log-selftest-v1-0-690c1741d68b@collabora.com

---
Nícolas F. R. A. Prado (3):
      kselftest: devices: Move discoverable devices test to subdirectory
      kselftest: Move ksft helper module to common directory
      kselftest: devices: Add test to detect device error logs

 tools/testing/selftests/Makefile                   |  4 +-
 tools/testing/selftests/devices/Makefile           |  4 -
 .../testing/selftests/devices/error_logs/Makefile  |  3 +
 .../devices/error_logs/test_device_error_logs.py   | 85 ++++++++++++++++++++++
 tools/testing/selftests/devices/probe/Makefile     |  4 +
 .../{ => probe}/boards/Dell Inc.,XPS 13 9300.yaml  |  0
 .../{ => probe}/boards/google,spherion.yaml        |  0
 .../{ => probe}/test_discoverable_devices.py       |  7 +-
 .../selftests/{devices => kselftest}/ksft.py       |  0
 9 files changed, 101 insertions(+), 6 deletions(-)
---
base-commit: 0b58e108042b0ed28a71cd7edf5175999955b233
change-id: 20240421-dev-err-log-selftest-28f5b8fc7cd0

Best regards,

Comments

Greg KH July 10, 2024, 1:11 p.m. UTC | #1
On Fri, Jul 05, 2024 at 07:29:53PM -0400, Nícolas F. R. A. Prado wrote:
> Log errors are the most widely used mechanism for reporting issues in
> the kernel. When an error is logged using the device helpers, eg
> dev_err(), it gets metadata attached that identifies the subsystem and
> device where the message is coming from. This series makes use of that
> metadata in a new test to report which devices logged errors.
> 
> The first two patches move a test and a helper script to keep things
> organized before this new test is added in the third patch.
> 
> It is expected that there might be many false-positive error messages
> throughout the drivers code which will be reported by this test. By
> having this test in the first place and working through the results we
> can address those occurrences by adjusting the loglevel of the messages
> that turn out to not be real errors that require the user's attention.
> It will also motivate additional error messages to be introduced in the
> code to detect real errors where they turn out to be missing, since
> it will be possible to detect said issues automatically.
> 
> As an example, below you can see the test result for
> mt8192-asurada-spherion. The single standing issue has been investigated
> and will be addressed in an EC firmware update [1]:
> 
> TAP version 13
> 1..1
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `model_name' property: -6
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>  power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> not ok 1 +power_supply:sbs-8-000b
>  Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
> 
> [1] https://lore.kernel.org/all/cf4d8131-4b63-4c7a-9f27-5a0847c656c4@notapiano
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Shuah Khan July 10, 2024, 9:49 p.m. UTC | #2
On 7/10/24 07:11, Greg Kroah-Hartman wrote:
> On Fri, Jul 05, 2024 at 07:29:53PM -0400, Nícolas F. R. A. Prado wrote:
>> Log errors are the most widely used mechanism for reporting issues in
>> the kernel. When an error is logged using the device helpers, eg
>> dev_err(), it gets metadata attached that identifies the subsystem and
>> device where the message is coming from. This series makes use of that
>> metadata in a new test to report which devices logged errors.
>>
>> The first two patches move a test and a helper script to keep things
>> organized before this new test is added in the third patch.
>>
>> It is expected that there might be many false-positive error messages
>> throughout the drivers code which will be reported by this test. By
>> having this test in the first place and working through the results we
>> can address those occurrences by adjusting the loglevel of the messages
>> that turn out to not be real errors that require the user's attention.
>> It will also motivate additional error messages to be introduced in the
>> code to detect real errors where they turn out to be missing, since
>> it will be possible to detect said issues automatically.
>>
>> As an example, below you can see the test result for
>> mt8192-asurada-spherion. The single standing issue has been investigated
>> and will be addressed in an EC firmware update [1]:
>>
>> TAP version 13
>> 1..1
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `model_name' property: -6
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>> not ok 1 +power_supply:sbs-8-000b
>>   Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
>>
>> [1] https://lore.kernel.org/all/cf4d8131-4b63-4c7a-9f27-5a0847c656c4@notapiano
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Is this dependent on a linux-next?

Didn't apply to linux-kselftest next.

thanks,
-- Shuah
Shuah Khan July 11, 2024, 7:53 p.m. UTC | #3
On 7/10/24 15:49, Shuah Khan wrote:
> On 7/10/24 07:11, Greg Kroah-Hartman wrote:
>> On Fri, Jul 05, 2024 at 07:29:53PM -0400, Nícolas F. R. A. Prado wrote:
>>> Log errors are the most widely used mechanism for reporting issues in
>>> the kernel. When an error is logged using the device helpers, eg
>>> dev_err(), it gets metadata attached that identifies the subsystem and
>>> device where the message is coming from. This series makes use of that
>>> metadata in a new test to report which devices logged errors.
>>>
>>> The first two patches move a test and a helper script to keep things
>>> organized before this new test is added in the third patch.
>>>
>>> It is expected that there might be many false-positive error messages
>>> throughout the drivers code which will be reported by this test. By
>>> having this test in the first place and working through the results we
>>> can address those occurrences by adjusting the loglevel of the messages
>>> that turn out to not be real errors that require the user's attention.
>>> It will also motivate additional error messages to be introduced in the
>>> code to detect real errors where they turn out to be missing, since
>>> it will be possible to detect said issues automatically.
>>>
>>> As an example, below you can see the test result for
>>> mt8192-asurada-spherion. The single standing issue has been investigated
>>> and will be addressed in an EC firmware update [1]:
>>>
>>> TAP version 13
>>> 1..1
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `model_name' property: -6
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>> not ok 1 +power_supply:sbs-8-000b
>>>   Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
>>>
>>> [1] https://lore.kernel.org/all/cf4d8131-4b63-4c7a-9f27-5a0847c656c4@notapiano
>>>
>>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>>
>> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Is this dependent on a linux-next?
> 
> Didn't apply to linux-kselftest next.
> 

I tried applying these on top of linux-kselftest next which is at
Linux 6.10-rc7 + other patches.

I am not sure what is wrong - first patch applies and the second
and third don't.

git am fails and manual patch application worked for 2/3, same thing
with 3.3 - these should apply cleanly since they don't have obvious
conflicts.

Please clean this up and send me updated series adding Greg's ack.

thanks,
-- Shuah
Nícolas F. R. A. Prado July 11, 2024, 9:44 p.m. UTC | #4
On Thu, Jul 11, 2024 at 01:53:37PM -0600, Shuah Khan wrote:
> On 7/10/24 15:49, Shuah Khan wrote:
> > On 7/10/24 07:11, Greg Kroah-Hartman wrote:
> > > On Fri, Jul 05, 2024 at 07:29:53PM -0400, Nícolas F. R. A. Prado wrote:
> > > > Log errors are the most widely used mechanism for reporting issues in
> > > > the kernel. When an error is logged using the device helpers, eg
> > > > dev_err(), it gets metadata attached that identifies the subsystem and
> > > > device where the message is coming from. This series makes use of that
> > > > metadata in a new test to report which devices logged errors.
> > > > 
> > > > The first two patches move a test and a helper script to keep things
> > > > organized before this new test is added in the third patch.
> > > > 
> > > > It is expected that there might be many false-positive error messages
> > > > throughout the drivers code which will be reported by this test. By
> > > > having this test in the first place and working through the results we
> > > > can address those occurrences by adjusting the loglevel of the messages
> > > > that turn out to not be real errors that require the user's attention.
> > > > It will also motivate additional error messages to be introduced in the
> > > > code to detect real errors where they turn out to be missing, since
> > > > it will be possible to detect said issues automatically.
> > > > 
> > > > As an example, below you can see the test result for
> > > > mt8192-asurada-spherion. The single standing issue has been investigated
> > > > and will be addressed in an EC firmware update [1]:
> > > > 
> > > > TAP version 13
> > > > 1..1
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `model_name' property: -6
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > not ok 1 +power_supply:sbs-8-000b
> > > >   Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
> > > > 
> > > > [1] https://lore.kernel.org/all/cf4d8131-4b63-4c7a-9f27-5a0847c656c4@notapiano
> > > > 
> > > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> > > 
> > > Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > 
> > Is this dependent on a linux-next?
> > 
> > Didn't apply to linux-kselftest next.
> > 
> 
> I tried applying these on top of linux-kselftest next which is at
> Linux 6.10-rc7 + other patches.
> 
> I am not sure what is wrong - first patch applies and the second
> and third don't.
> 
> git am fails and manual patch application worked for 2/3, same thing
> with 3.3 - these should apply cleanly since they don't have obvious
> conflicts.
> 
> Please clean this up and send me updated series adding Greg's ack.

Oh, now I see what happened. I recently sent another series that touches the
same file (tools/testing/selftests/devices/test_discoverable_devices.py):
"kselftest: devices: Allow running test on more platforms"
https://lore.kernel.org/all/20240613-kselftest-discoverable-probe-mt8195-kci-v1-1-7b396a9b032d@collabora.com/

That was already merged through the usb tree, and is present on next (on which I
based this series).

In this case I imagine it's best if this series gets picked through the usb
tree, right? Even if I rebase on kselftest's next, there will be conflicts.

Thanks,
Nícolas
Shuah Khan July 11, 2024, 9:56 p.m. UTC | #5
On 7/11/24 15:44, Nícolas F. R. A. Prado wrote:
> On Thu, Jul 11, 2024 at 01:53:37PM -0600, Shuah Khan wrote:
>> On 7/10/24 15:49, Shuah Khan wrote:
>>> On 7/10/24 07:11, Greg Kroah-Hartman wrote:
>>>> On Fri, Jul 05, 2024 at 07:29:53PM -0400, Nícolas F. R. A. Prado wrote:
>>>>> Log errors are the most widely used mechanism for reporting issues in
>>>>> the kernel. When an error is logged using the device helpers, eg
>>>>> dev_err(), it gets metadata attached that identifies the subsystem and
>>>>> device where the message is coming from. This series makes use of that
>>>>> metadata in a new test to report which devices logged errors.
>>>>>
>>>>> The first two patches move a test and a helper script to keep things
>>>>> organized before this new test is added in the third patch.
>>>>>
>>>>> It is expected that there might be many false-positive error messages
>>>>> throughout the drivers code which will be reported by this test. By
>>>>> having this test in the first place and working through the results we
>>>>> can address those occurrences by adjusting the loglevel of the messages
>>>>> that turn out to not be real errors that require the user's attention.
>>>>> It will also motivate additional error messages to be introduced in the
>>>>> code to detect real errors where they turn out to be missing, since
>>>>> it will be possible to detect said issues automatically.
>>>>>
>>>>> As an example, below you can see the test result for
>>>>> mt8192-asurada-spherion. The single standing issue has been investigated
>>>>> and will be addressed in an EC firmware update [1]:
>>>>>
>>>>> TAP version 13
>>>>> 1..1
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `model_name' property: -6
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>>    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
>>>>> not ok 1 +power_supply:sbs-8-000b
>>>>>    Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
>>>>>
>>>>> [1] https://lore.kernel.org/all/cf4d8131-4b63-4c7a-9f27-5a0847c656c4@notapiano
>>>>>
>>>>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>>>>
>>>> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>>
>>> Is this dependent on a linux-next?
>>>
>>> Didn't apply to linux-kselftest next.
>>>
>>
>> I tried applying these on top of linux-kselftest next which is at
>> Linux 6.10-rc7 + other patches.
>>
>> I am not sure what is wrong - first patch applies and the second
>> and third don't.
>>
>> git am fails and manual patch application worked for 2/3, same thing
>> with 3.3 - these should apply cleanly since they don't have obvious
>> conflicts.
>>
>> Please clean this up and send me updated series adding Greg's ack.
> 
> Oh, now I see what happened. I recently sent another series that touches the
> same file (tools/testing/selftests/devices/test_discoverable_devices.py):
> "kselftest: devices: Allow running test on more platforms"
> https://lore.kernel.org/all/20240613-kselftest-discoverable-probe-mt8195-kci-v1-1-7b396a9b032d@collabora.com/
> 
> That was already merged through the usb tree, and is present on next (on which I
> based this series).
> 
> In this case I imagine it's best if this series gets picked through the usb
> tree, right? Even if I rebase on kselftest's next, there will be conflicts.
> 

I see. No problem. It can go through usb tree

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
Greg KH July 12, 2024, 8:59 a.m. UTC | #6
On Thu, Jul 11, 2024 at 03:56:25PM -0600, Shuah Khan wrote:
> On 7/11/24 15:44, Nícolas F. R. A. Prado wrote:
> > On Thu, Jul 11, 2024 at 01:53:37PM -0600, Shuah Khan wrote:
> > > On 7/10/24 15:49, Shuah Khan wrote:
> > > > On 7/10/24 07:11, Greg Kroah-Hartman wrote:
> > > > > On Fri, Jul 05, 2024 at 07:29:53PM -0400, Nícolas F. R. A. Prado wrote:
> > > > > > Log errors are the most widely used mechanism for reporting issues in
> > > > > > the kernel. When an error is logged using the device helpers, eg
> > > > > > dev_err(), it gets metadata attached that identifies the subsystem and
> > > > > > device where the message is coming from. This series makes use of that
> > > > > > metadata in a new test to report which devices logged errors.
> > > > > > 
> > > > > > The first two patches move a test and a helper script to keep things
> > > > > > organized before this new test is added in the third patch.
> > > > > > 
> > > > > > It is expected that there might be many false-positive error messages
> > > > > > throughout the drivers code which will be reported by this test. By
> > > > > > having this test in the first place and working through the results we
> > > > > > can address those occurrences by adjusting the loglevel of the messages
> > > > > > that turn out to not be real errors that require the user's attention.
> > > > > > It will also motivate additional error messages to be introduced in the
> > > > > > code to detect real errors where they turn out to be missing, since
> > > > > > it will be possible to detect said issues automatically.
> > > > > > 
> > > > > > As an example, below you can see the test result for
> > > > > > mt8192-asurada-spherion. The single standing issue has been investigated
> > > > > > and will be addressed in an EC firmware update [1]:
> > > > > > 
> > > > > > TAP version 13
> > > > > > 1..1
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `model_name' property: -6
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >    power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > > not ok 1 +power_supply:sbs-8-000b
> > > > > >    Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
> > > > > > 
> > > > > > [1] https://lore.kernel.org/all/cf4d8131-4b63-4c7a-9f27-5a0847c656c4@notapiano
> > > > > > 
> > > > > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> > > > > 
> > > > > Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > > 
> > > > Is this dependent on a linux-next?
> > > > 
> > > > Didn't apply to linux-kselftest next.
> > > > 
> > > 
> > > I tried applying these on top of linux-kselftest next which is at
> > > Linux 6.10-rc7 + other patches.
> > > 
> > > I am not sure what is wrong - first patch applies and the second
> > > and third don't.
> > > 
> > > git am fails and manual patch application worked for 2/3, same thing
> > > with 3.3 - these should apply cleanly since they don't have obvious
> > > conflicts.
> > > 
> > > Please clean this up and send me updated series adding Greg's ack.
> > 
> > Oh, now I see what happened. I recently sent another series that touches the
> > same file (tools/testing/selftests/devices/test_discoverable_devices.py):
> > "kselftest: devices: Allow running test on more platforms"
> > https://lore.kernel.org/all/20240613-kselftest-discoverable-probe-mt8195-kci-v1-1-7b396a9b032d@collabora.com/
> > 
> > That was already merged through the usb tree, and is present on next (on which I
> > based this series).
> > 
> > In this case I imagine it's best if this series gets picked through the usb
> > tree, right? Even if I rebase on kselftest's next, there will be conflicts.
> > 
> 
> I see. No problem. It can go through usb tree
> 
> Acked-by: Shuah Khan <skhan@linuxfoundation.org>

Ok, taken through the usb tree now, thanks.

greg k-h
Bird, Tim July 12, 2024, 5:48 p.m. UTC | #7
> -----Original Message-----
> From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> On Thu, Jul 11, 2024 at 01:53:37PM -0600, Shuah Khan wrote:
> > On 7/10/24 15:49, Shuah Khan wrote:
> > > On 7/10/24 07:11, Greg Kroah-Hartman wrote:
> > > > On Fri, Jul 05, 2024 at 07:29:53PM -0400, Nícolas F. R. A. Prado wrote:
> > > > > Log errors are the most widely used mechanism for reporting issues in
> > > > > the kernel. When an error is logged using the device helpers, eg
> > > > > dev_err(), it gets metadata attached that identifies the subsystem and
> > > > > device where the message is coming from. This series makes use of that
> > > > > metadata in a new test to report which devices logged errors.
> > > > >
> > > > > The first two patches move a test and a helper script to keep things
> > > > > organized before this new test is added in the third patch.
> > > > >
> > > > > It is expected that there might be many false-positive error messages
> > > > > throughout the drivers code which will be reported by this test. By
> > > > > having this test in the first place and working through the results we
> > > > > can address those occurrences by adjusting the loglevel of the messages
> > > > > that turn out to not be real errors that require the user's attention.
> > > > > It will also motivate additional error messages to be introduced in the
> > > > > code to detect real errors where they turn out to be missing, since
> > > > > it will be possible to detect said issues automatically.
> > > > >
> > > > > As an example, below you can see the test result for
> > > > > mt8192-asurada-spherion. The single standing issue has been investigated
> > > > > and will be addressed in an EC firmware update [1]:
> > > > >
> > > > > TAP version 13
> > > > > 1..1
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `model_name' property: -6
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > not ok 1 +power_supply:sbs-8-000b

Sorry this feedback is coming late. 

The test description only includes the device identifier, and not a description of the testcase.
(See below for why this might be the case).

Maybe a better testcase description might be: "check that power_supply:sbs-8-000b device has no error messages"

I note that there are 3 different error messages, but only one testcase report generated.
It would be a lot of work (probably too much), for this test to interpret the error messages
and convert them into testcase language.  But it might be worthwhile to report a test result
for each type of error message generated.

> > > > >   Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
> > > > >

There are a few interesting issues that this 'test' raises.

It is not so much a test itself, as a way to convert an error log report into KTAP output.

The 'test' has no knowledge of what the testcases are, that are being reported.
That is, the actual test has occurred at runtime, inside the driver or device manager
code, which produced the error string.  This 'test' just reports that the device reported
an error. 

As currently structured, there is no way for this to report an 'ok' testcase.
I talked with Nicolas on a KernelCI conference call, it is apparently possible to try to find
all possible devices on a system, and report them as 'ok'.  But this would produce
a LOT of noise, as all the devices that did not have errors would be reported as 'ok'.
This level of verbosity is probably not desirable.  (It's similar to how a compiler does
not report the success of every test it conducts on the source code, as it is being compiled.
Rather a compiler only outputs errors and warnings for test failures.)

In terms of tracking regressions, it would be useful to identify the different things that could
cause an error message to appear or disappear.  For example, some errors related to hardware
might change due to flakiness of the hardware.  Some errors might be introduced or go away
based on a change in the kernel configuration.  This is one case, where have a long list of "ok"
lines would be useful - to disambiguate drivers that were present, but didn't have an error, from
drivers that were not present at all.

I think this test is useful, and am not NAK-ing it.  I'm just giving some feedback on the general
approach, and hopefully raising some issues to consider, to make the test more useful.

 -- Tim
Nícolas F. R. A. Prado July 12, 2024, 8:51 p.m. UTC | #8
On Fri, Jul 12, 2024 at 05:48:14PM +0000, Bird, Tim wrote:
> 
> 
> > -----Original Message-----
> > From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> > On Thu, Jul 11, 2024 at 01:53:37PM -0600, Shuah Khan wrote:
> > > On 7/10/24 15:49, Shuah Khan wrote:
> > > > On 7/10/24 07:11, Greg Kroah-Hartman wrote:
> > > > > On Fri, Jul 05, 2024 at 07:29:53PM -0400, Nícolas F. R. A. Prado wrote:
> > > > > > Log errors are the most widely used mechanism for reporting issues in
> > > > > > the kernel. When an error is logged using the device helpers, eg
> > > > > > dev_err(), it gets metadata attached that identifies the subsystem and
> > > > > > device where the message is coming from. This series makes use of that
> > > > > > metadata in a new test to report which devices logged errors.
> > > > > >
> > > > > > The first two patches move a test and a helper script to keep things
> > > > > > organized before this new test is added in the third patch.
> > > > > >
> > > > > > It is expected that there might be many false-positive error messages
> > > > > > throughout the drivers code which will be reported by this test. By
> > > > > > having this test in the first place and working through the results we
> > > > > > can address those occurrences by adjusting the loglevel of the messages
> > > > > > that turn out to not be real errors that require the user's attention.
> > > > > > It will also motivate additional error messages to be introduced in the
> > > > > > code to detect real errors where they turn out to be missing, since
> > > > > > it will be possible to detect said issues automatically.
> > > > > >
> > > > > > As an example, below you can see the test result for
> > > > > > mt8192-asurada-spherion. The single standing issue has been investigated
> > > > > > and will be addressed in an EC firmware update [1]:
> > > > > >
> > > > > > TAP version 13
> > > > > > 1..1
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `model_name' property: -6
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > >   power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
> > > > > > not ok 1 +power_supply:sbs-8-000b
> 
> Sorry this feedback is coming late. 
> 
> The test description only includes the device identifier, and not a description of the testcase.
> (See below for why this might be the case).
> 
> Maybe a better testcase description might be: "check that power_supply:sbs-8-000b device has no error messages"

Indeed that would make it more descriptive, but it would also add a lot of
redundant information. Since all the test does is check whether each device has
error messages, the only unique information for each test case is the device
identifier. In other words I considered the "check that ... device has no error
messages" implied by the test suite.

> 
> I note that there are 3 different error messages, but only one testcase report generated.
> It would be a lot of work (probably too much), for this test to interpret the error messages
> and convert them into testcase language.  But it might be worthwhile to report a test result
> for each type of error message generated.

I don't know how much value that would bring, but it might be an interesting
idea to try.

Interpreting the messages seems too much, but if we just compare the messages
for uniqueness and use them as is in the test identifiers it would be easy to
do, eg:

not ok 1 +power_supply:sbs-8-000b.power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5
not ok 2 +power_supply:sbs-8-000b.power_supply sbs-8-000b: driver failed to report `energy_full_design' property: -6
not ok 3 +power_supply:sbs-8-000b.power_supply sbs-8-000b: driver failed to report `model_name' property: -6

My concern is that I don't know if this is actually doing a good job of
portraying the issues: in this case it's actually really just one issue that
triggers those different messages, but this makes it look like there are 3
independent issues and the order of the errors is completely lost.

> 
> > > > > >   Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
> > > > > >
> 
> There are a few interesting issues that this 'test' raises.
> 
> It is not so much a test itself, as a way to convert an error log report into KTAP output.
> 
> The 'test' has no knowledge of what the testcases are, that are being reported.
> That is, the actual test has occurred at runtime, inside the driver or device manager
> code, which produced the error string.  This 'test' just reports that the device reported
> an error. 

Right. I would argue that the test suite as a whole does test something: "Did
any devices on this platform report errors?". And if the answer is yes, then the
test cases will detail this information by simply converting the error log into
KTAP.

But indeed the bulk of the testing is done by the drivers and frameworks and
this 'test' is mostly about structuring and reporting that data in a way that
is easier to identify the problematic devices on the system.

> 
> As currently structured, there is no way for this to report an 'ok' testcase.
> I talked with Nicolas on a KernelCI conference call, it is apparently possible to try to find
> all possible devices on a system, and report them as 'ok'.  But this would produce
> a LOT of noise, as all the devices that did not have errors would be reported as 'ok'.
> This level of verbosity is probably not desirable.  (It's similar to how a compiler does
> not report the success of every test it conducts on the source code, as it is being compiled.
> Rather a compiler only outputs errors and warnings for test failures.)
> 
> In terms of tracking regressions, it would be useful to identify the different things that could
> cause an error message to appear or disappear.  For example, some errors related to hardware
> might change due to flakiness of the hardware.  Some errors might be introduced or go away
> based on a change in the kernel configuration.  This is one case, where have a long list of "ok"
> lines would be useful - to disambiguate drivers that were present, but didn't have an error, from
> drivers that were not present at all.

Yes, to this I currently don't see another option... However, if we keep the
"ok" cases hidden/implicit, I think the concern about drivers not being present
at all can be mostly addressed by also running a probe test, like the DT
kselftest [1] or the ACPI kselftest [2]. That way, you would rely on the probe
test to verify whether all the devices expected on the system are there, and on
the error log test to verify whether any of the devices on the system have
issues.

> 
> I think this test is useful, and am not NAK-ing it.  I'm just giving some feedback on the general
> approach, and hopefully raising some issues to consider, to make the test more useful.

I think more important than merging or not merging the test is getting feedback
from the community on how to improve testing on the kernel, so I definitely
welcome your feedback. Thank you for taking the time to write this.

Thanks,
Nícolas

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/dt/test_unprobed_devices.sh
[2] https://lore.kernel.org/all/20240308144933.337107-1-laura.nao@collabora.com