kselftest/alsa: Decrease pcm-test duration to avoid timeouts
Subsystems (3)
cover kselftest/alsa: Decrease pcm-test duration to avoid timeouts
This series decreases the pcm-test duration in order to avoid timeouts by first moving the audio stream duration to a variable and subsequently decreasing it.
Nícolas F. R. A. Prado (2):
kselftest/alsa: pcm-test: Move stream duration and margin to variables kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
tools/testing/selftests/alsa/pcm-test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/2 kselftest/alsa: pcm-test: Move stream duration and margin to variables
The duration to stream for and time margin to consider the stream failed are currently hardcoded values. Move them to variables so they can be reused and more easily changed.
---
tools/testing/selftests/alsa/pcm-test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/testing/selftests/alsa/pcm-test.c +5 -3
@@ -258,6 +258,8 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class, const char *test_name, snd_config_t *pcm_cfg) { char name[64], key[128], msg[256]; +const int duration_s =4 , margin_ms =100 ; +const int duration_ms = duration_s *1000 ;const char *cs;int i, err;snd_pcm_t *handle =NULL ;
@@ -442,7 +444,7 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class, skip = false;timestamp_now (&tstamp); -for (i =0 ; i <4 ; i++) { +for (i =0 ; i < duration_s; i++) {if (data->stream ==SND_PCM_STREAM_PLAYBACK ) { frames =snd_pcm_writei (handle, samples, rate);if (frames <0 ) {
@@ -472,8 +474,8 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class,snd_pcm_drain (handle); ms =timestamp_diff_ms (&tstamp); -if (ms <3900 || ms >4100 ) { -snprintf (msg,sizeof (msg),"time mismatch: expected 4000ms got %lld" , ms); +if (ms < duration_ms - margin_ms || ms > duration_ms + margin_ms) { +snprintf (msg,sizeof (msg),"time mismatch: expected %dms got %lld" , duration_ms, ms); goto __close; }
Signature · 1 line
2.41.0
Re: [PATCH 1/2] kselftest/alsa: pcm-test: Move stream duration and margin to variables
Il 21/06/23 00:08, Nícolas F. R. A. Prado ha scritto:
Quoted 6 lines
The duration to stream for and time margin to consider the stream failed are currently hardcoded values. Move them to variables so they can be reused and more easily changed.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 2/2 kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
In reply to Nícolas F. R. A. PradoCurrently test_pcm_time() streams audio on each PCM with each configuration for 4 seconds. This time can add up, and with the current 45 second kselftest timeout, some machines like mt8192-asurada-spherion can't even run to completion. Lower the duration to 2 seconds to cut the test duration in half, without reducing the test coverage.
---
tools/testing/selftests/alsa/pcm-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/alsa/pcm-test.c +1 -1
@@ -258,7 +258,7 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class, const char *test_name, snd_config_t *pcm_cfg) { char name[64], key[128], msg[256]; -const int duration_s =4 , margin_ms =100 ; +const int duration_s =2 , margin_ms =100 ;const int duration_ms = duration_s *1000 ;const char *cs;int i, err;
Signature · 1 line
2.41.0
Mark Brown
maintainerRe: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
tools/testing/selftests/alsa/pcm-test.c static void test_pcm_time(struct pcm_data *data, enum test_class class, · line 261
Quoted 2 lines · Nícolas F. R. A. Prado
tools/testing/selftests/alsa/pcm-test.c +1
-1-const int duration_s =4 , margin_ms =100 ; +const int duration_s =2 , margin_ms =100 ;
This doesn't scale the margin with the duration which will affect the sensitivity of the test to misclocking. It should make it less sensitive which is *probably* safer but at least worth noting.
We might also have issues with some of the lower sample rates, IIRC some devices are constrained in ways that mean they want a minimum buffer size which is harder to satisfy with very short playbacks and low sample rates.
I don't know why Jaroslav picked the 4s number here.
Jaroslav Kysela
maintainerRe: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 9 lines · Mark Brown
tools/testing/selftests/alsa/pcm-test.c static void test_pcm_time(struct pcm_data *data, enum test_class class, · line 261
Quoted 2 lines · Nícolas F. R. A. Prado
tools/testing/selftests/alsa/pcm-test.c +1
-1-const int duration_s =4 , margin_ms =100 ; +const int duration_s =2 , margin_ms =100 ;This doesn't scale the margin with the duration which will affect the sensitivity of the test to misclocking. It should make it less sensitive which is *probably* safer but at least worth noting.
Quoted 6 lines
We might also have issues with some of the lower sample rates, IIRC some devices are constrained in ways that mean they want a minimum buffer size which is harder to satisfy with very short playbacks and low sample rates.
I don't know why Jaroslav picked the 4s number here.
You basically replied yourself. The values (time + margin) were picked to do the DMA test for a reasonable time - based on my experience.
I think that the problem is somewhere else here. The overall test timeout should be calculated dynamically. All tests may be queried for the maximal expected interval based on the hardware/software capabilities. It's a bit pitfall to have a fixed time limit where the realtime tests depend on the number of devices.
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Mark Brown
maintainerRe: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 5 lines · Jaroslav Kysela
I think that the problem is somewhere else here. The overall test timeout should be calculated dynamically. All tests may be queried for the maximal expected interval based on the hardware/software capabilities. It's a bit pitfall to have a fixed time limit where the realtime tests depend on the number of devices.
I tend to agree here, unfortunately Shuah hasn't responded to queries from Nícolas about this which I imagine is what inspired this patch. We also have problems with mixer-test on one of the Dialog CODECs with a couple of 64k value controls and no cache only mode.
Re: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 8 lines · Mark Brown
Quoted 5 lines · Jaroslav Kysela
I think that the problem is somewhere else here. The overall test timeout should be calculated dynamically. All tests may be queried for the maximal expected interval based on the hardware/software capabilities. It's a bit pitfall to have a fixed time limit where the realtime tests depend on the number of devices.
Quoted 4 lines
I tend to agree here, unfortunately Shuah hasn't responded to queries from Nícolas about this which I imagine is what inspired this patch. We also have problems with mixer-test on one of the Dialog CODECs with a couple of 64k value controls and no cache only mode.
Yes, exactly. I've tried increasing the timeout for this test to a larger fixed value previously, and later asked for more information on how to deal with the kselftest timeout. [1]
Since I didn't hear back, I thought this patch would be a way to at least mitigate the issue for now, without limiting the test coverage, which was a concern with having limited scopes for the test.
I've just noticed that in the mean time a way to override the timeout when running kselftest has been introduced [2], so I suppose we could use that to work around the timeout limitation in CI systems and be able to run through completion on the different hardware at the lab. But I still believe, like you do, that calculating the timeout at runtime based on the hardware would make much more sense, though if there's such a desire to keep kselftests under the 45s mark, I'm not sure if it would be acceptable.
[1] https://lore.kernel.org/all/5302e70d-cb58-4e70-b44f-ff81b138a2e1@notapiano/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6a01213e3f8
Thanks,
Nícolas
Re: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 31 lines · Nícolas F. R. A. Prado
Quoted 8 lines · Mark Brown
Quoted 5 lines · Jaroslav Kysela
I think that the problem is somewhere else here. The overall test timeout should be calculated dynamically. All tests may be queried for the maximal expected interval based on the hardware/software capabilities. It's a bit pitfall to have a fixed time limit where the realtime tests depend on the number of devices.
Quoted 4 lines
I tend to agree here, unfortunately Shuah hasn't responded to queries from Nícolas about this which I imagine is what inspired this patch. We also have problems with mixer-test on one of the Dialog CODECs with a couple of 64k value controls and no cache only mode.
Yes, exactly. I've tried increasing the timeout for this test to a larger fixed value previously, and later asked for more information on how to deal with the kselftest timeout. [1]
Since I didn't hear back, I thought this patch would be a way to at least mitigate the issue for now, without limiting the test coverage, which was a concern with having limited scopes for the test.
I've just noticed that in the mean time a way to override the timeout when running kselftest has been introduced [2], so I suppose we could use that to work around the timeout limitation in CI systems and be able to run through completion on the different hardware at the lab. But I still believe, like you do, that calculating the timeout at runtime based on the hardware would make much more sense, though if there's such a desire to keep kselftests under the 45s mark, I'm not sure if it would be acceptable.
Quoted 2 lines
[1] https://lore.kernel.org/all/5302e70d-cb58-4e70-b44f-ff81b138a2e1@notapiano/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6a01213e3f8
So, we're back to square... Unless anyone has a strong objection, I'm inclined to take this as a workaround for 6.5 for now, as the merge window deadline is coming. We can improve things at the same time for the future kernel, too.
thanks,
Takashi
Mark Brown
maintainerRe: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 4 lines · Takashi Iwai
So, we're back to square... Unless anyone has a strong objection, I'm inclined to take this as a workaround for 6.5 for now, as the merge window deadline is coming. We can improve things at the same time for the future kernel, too.
It feels like it might be good to let it cook for a bit longer before going to Linus (eg, applying after the merge window) so we've more chance to see what the impact is on other boards?
Re: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 11 lines · Mark Brown
Quoted 4 lines · Takashi Iwai
So, we're back to square... Unless anyone has a strong objection, I'm inclined to take this as a workaround for 6.5 for now, as the merge window deadline is coming. We can improve things at the same time for the future kernel, too.
It feels like it might be good to let it cook for a bit longer before going to Linus (eg, applying after the merge window) so we've more chance to see what the impact is on other boards?
I'm fine with that option, too. Are most of selftests performed on linux-next basis, or rather on Linus tree?
Takashi
Mark Brown
maintainerRe: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
It feels like it might be good to let it cook for a bit longer before going to Linus (eg, applying after the merge window) so we've more chance to see what the impact is on other boards?
I'm fine with that option, too. Are most of selftests performed on linux-next basis, or rather on Linus tree?
For KernelCI we've got coverage on both. I can also run stuff on the boards I have in my lab on demand of course, but there's more coverage in KernelCI.
Re: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 8 lines · Mark Brown
Quoted 5 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
It feels like it might be good to let it cook for a bit longer before going to Linus (eg, applying after the merge window) so we've more chance to see what the impact is on other boards?
Quoted 6 lines
Quoted 2 lines
I'm fine with that option, too. Are most of selftests performed on linux-next basis, or rather on Linus tree?
For KernelCI we've got coverage on both. I can also run stuff on the boards I have in my lab on demand of course, but there's more coverage in KernelCI.
OK, now I applied those two patches to for-next branch (i.e. for 6.6 kernel). Let's watch out.
thanks,
Takashi
Mark Brown
maintainerRe: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
For KernelCI we've got coverage on both. I can also run stuff on the boards I have in my lab on demand of course, but there's more coverage in KernelCI.
OK, now I applied those two patches to for-next branch (i.e. for 6.6 kernel). Let's watch out.
I'm seeing failures on my i.MX6 boards, both the Q and DL have started failing in the same way:
# default.time3.0.0.0.PLAYBACK - 44.1kHz stereo large periods
# default.time3.0.0.0.PLAYBACK hw_params.RW_INTERLEAVED.S16_LE.44100.2.16383.131064 sw_params.131064 not ok 10 default.time3.0.0.0.PLAYBACK
# time mismatch: expected 2000ms got 2229
reliably (the actual time drifts by a few ms). The other boards I've got coverage of seem fine, and I didn't check any broader CI yet.
Re: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 14 lines · Mark Brown
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
For KernelCI we've got coverage on both. I can also run stuff on the boards I have in my lab on demand of course, but there's more coverage in KernelCI.
OK, now I applied those two patches to for-next branch (i.e. for 6.6 kernel). Let's watch out.
I'm seeing failures on my i.MX6 boards, both the Q and DL have started failing in the same way:
Quoted 7 lines
# default.time3.0.0.0.PLAYBACK - 44.1kHz stereo large periods
# default.time3.0.0.0.PLAYBACK hw_params.RW_INTERLEAVED.S16_LE.44100.2.16383.131064 sw_params.131064 not ok 10 default.time3.0.0.0.PLAYBACK# time mismatch: expected 2000ms got 2229reliably (the actual time drifts by a few ms). The other boards I've got coverage of seem fine, and I didn't check any broader CI yet.
Interesting. With the current patch, we rather extended the margin in proportion; formerly 4 sec +/- 0.1s, now 2 sec +/- 0.1s. And it exceeded out of sudden.
I guess this rather caught a problem of the driver itself.
thanks,
Takashi
Mark Brown
maintainerRe: [PATCH 2/2] kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 seconds
Quoted 7 lines · Takashi Iwai
Quoted 4 lines · Mark Brown
# default.time3.0.0.0.PLAYBACK - 44.1kHz stereo large periods
# default.time3.0.0.0.PLAYBACK hw_params.RW_INTERLEAVED.S16_LE.44100.2.16383.131064 sw_params.131064 not ok 10 default.time3.0.0.0.PLAYBACK# time mismatch: expected 2000ms got 2229
Quoted 6 lines
Quoted 2 lines
reliably (the actual time drifts by a few ms). The other boards I've got coverage of seem fine, and I didn't check any broader CI yet.
Interesting. With the current patch, we rather extended the margin in proportion; formerly 4 sec +/- 0.1s, now 2 sec +/- 0.1s. And it exceeded out of sudden.
Right.
Quoted 1 line
I guess this rather caught a problem of the driver itself.
Well, there's doubtless something driver/hardware related going on but I'm not sure if it's a problem there or not. The results from the 4s runtime were:
# default.time3.0.0.0.PLAYBACK - 44.1kHz stereo large periods
# default.time3.0.0.0.PLAYBACK hw_params.RW_INTERLEAVED.S16_LE.44100.2.16383.131064 sw_params.131064 ok 10 default.time3.0.0.0.PLAYBACK
so the same buffer sizes and so on, and the period size is only 10ms unless I miscalculated which should be quite a long way off from the 100ms of margin we give ourselves. It does seem a little suspect that it's the large periods test that's falling over though.