diff mbox series

[V2,5/5] dmaengine: Documentation: Add documentation for multi chan testing

Message ID 1535713424-11322-6-git-send-email-seraj.alijan@sondrel.com (mailing list archive)
State Changes Requested
Headers show
Series dmaengine: dmatest: Add multi chan and new params | expand

Commit Message

Seraj Alijan Aug. 31, 2018, 11:03 a.m. UTC
Modify documentation to add multi channel testing support.

Signed-off-by: Seraj Alijan <seraj.alijan@sondrel.com>
---
 Documentation/driver-api/dmaengine/dmatest.rst | 27 ++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

Comments

Peter Ujfalusi Aug. 31, 2018, 11:17 a.m. UTC | #1
Hi,

On 2018-08-31 14:03, Seraj Alijan wrote:
> Modify documentation to add multi channel testing support.
> 
> Signed-off-by: Seraj Alijan <seraj.alijan@sondrel.com>
> ---
>  Documentation/driver-api/dmaengine/dmatest.rst | 27 ++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/driver-api/dmaengine/dmatest.rst b/Documentation/driver-api/dmaengine/dmatest.rst
> index 7ce5e71..0a7e4c3 100644
> --- a/Documentation/driver-api/dmaengine/dmatest.rst
> +++ b/Documentation/driver-api/dmaengine/dmatest.rst
> @@ -26,28 +26,43 @@ Part 2 - When dmatest is built as a module
>  
>  Example of usage::
>  
> -    % modprobe dmatest channel=dma0chan0 timeout=2000 iterations=1 run=1
> +    % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1
>  
>  ...or::
>  
>      % modprobe dmatest
> -    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>      % echo 2000 > /sys/module/dmatest/parameters/timeout
>      % echo 1 > /sys/module/dmatest/parameters/iterations
> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>      % echo 1 > /sys/module/dmatest/parameters/run
>  
>  ...or on the kernel command line::
>  
> -    dmatest.channel=dma0chan0 dmatest.timeout=2000 dmatest.iterations=1 dmatest.run=1
> +    dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1
> +
> +Example of multi-channel test usage:
> +    % modprobe dmatest
> +    % echo 2000 > /sys/module/dmatest/parameters/timeout
> +    % echo 1 > /sys/module/dmatest/parameters/iterations
> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
> +    % echo dma0chan1 > /sys/module/dmatest/parameters/channel
> +    % echo dma0chan2 > /sys/module/dmatest/parameters/channel

Can I still use:
echo "" > /sys/module/dmatest/parameters/channel

to stop dmatest to run on the specific channel(s) or do I need to reboot
the machine to do so?

I normally test multi channel memcpy with:
echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
echo 2000 > /sys/module/dmatest/parameters/timeout
echo 20 > /sys/module/dmatest/parameters/iterations
echo 20 > /sys/module/dmatest/parameters/max_channels
echo 1 > /sys/module/dmatest/parameters/run

So it will start running memtest on 20 channels.

If I do a test on specific channel (different DMA controller) I set the
channel run the test and then with "" I can revert back to normal
torture test.

> +    % echo 1 > /sys/module/dmatest/parameters/run
>  
> +Note: the channel parameter should always be the last parameter set prior to
> +running the test (setting run=1), this is because upon setting the channel
> +parameter, that specific channel is requested using the dmaengine and a thread
> +is created with the existing parameters. This thread is set as pending
> +and will be executed once run is set to 1. Any parameters set after the thread
> +is created are not applied.
>  .. hint::
>    available channel list could be extracted by running the following command::
>  
>      % ls -1 /sys/class/dma/
>  
> -Once started a message like "dmatest: Started 1 threads using dma0chan0" is
> -emitted. After that only test failure messages are reported until the test
> -stops.
> +Once started a message like " dmatest: Added 1 threads using dma0chan0" is
> +emitted. A thread for that specific channel is created and is now pending, the
> +pending thread is started once run is to 1.
>  
>  Note that running a new test will not stop any in progress test.
>  
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Peter Ujfalusi Aug. 31, 2018, 11:29 a.m. UTC | #2
Hi,

On 2018-08-31 14:03, Seraj Alijan wrote:
> Modify documentation to add multi channel testing support.
> 
> Signed-off-by: Seraj Alijan <seraj.alijan@sondrel.com>
> ---
>  Documentation/driver-api/dmaengine/dmatest.rst | 27 ++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/driver-api/dmaengine/dmatest.rst b/Documentation/driver-api/dmaengine/dmatest.rst
> index 7ce5e71..0a7e4c3 100644
> --- a/Documentation/driver-api/dmaengine/dmatest.rst
> +++ b/Documentation/driver-api/dmaengine/dmatest.rst
> @@ -26,28 +26,43 @@ Part 2 - When dmatest is built as a module
>  
>  Example of usage::
>  
> -    % modprobe dmatest channel=dma0chan0 timeout=2000 iterations=1 run=1
> +    % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1
>  
>  ...or::
>  
>      % modprobe dmatest
> -    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>      % echo 2000 > /sys/module/dmatest/parameters/timeout
>      % echo 1 > /sys/module/dmatest/parameters/iterations
> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>      % echo 1 > /sys/module/dmatest/parameters/run
>  
>  ...or on the kernel command line::
>  
> -    dmatest.channel=dma0chan0 dmatest.timeout=2000 dmatest.iterations=1 dmatest.run=1
> +    dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1
> +
> +Example of multi-channel test usage:
> +    % modprobe dmatest
> +    % echo 2000 > /sys/module/dmatest/parameters/timeout
> +    % echo 1 > /sys/module/dmatest/parameters/iterations
> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
> +    % echo dma0chan1 > /sys/module/dmatest/parameters/channel
> +    % echo dma0chan2 > /sys/module/dmatest/parameters/channel
> +    % echo 1 > /sys/module/dmatest/parameters/run
>  
> +Note: the channel parameter should always be the last parameter set prior to
> +running the test (setting run=1), this is because upon setting the channel
> +parameter, that specific channel is requested using the dmaengine and a thread
> +is created with the existing parameters.

When the channel is going to be released after this change?

It is a bit awkward currently that after the test finished the
channel(s) are still requested and it can be released by
cat /sys/module/dmatest/parameters/run

or to run the test again and before the next run the channel(s) are
going to be released just to be requested again.

> This thread is set as pending
> +and will be executed once run is set to 1. Any parameters set after the thread
> +is created are not applied.
>  .. hint::
>    available channel list could be extracted by running the following command::
>  
>      % ls -1 /sys/class/dma/
>  
> -Once started a message like "dmatest: Started 1 threads using dma0chan0" is
> -emitted. After that only test failure messages are reported until the test
> -stops.
> +Once started a message like " dmatest: Added 1 threads using dma0chan0" is
> +emitted. A thread for that specific channel is created and is now pending, the
> +pending thread is started once run is to 1.
>  
>  Note that running a new test will not stop any in progress test.
>  
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Seraj Mohammed Aug. 31, 2018, 1:41 p.m. UTC | #3
Hello,

On 31/08/18 12:17, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-31 14:03, Seraj Alijan wrote:
>> Modify documentation to add multi channel testing support.
>>
>> Signed-off-by: Seraj Alijan <seraj.alijan@sondrel.com>
>> ---
>>  Documentation/driver-api/dmaengine/dmatest.rst | 27 ++++++++++++++++++++------
>>  1 file changed, 21 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/driver-api/dmaengine/dmatest.rst b/Documentation/driver-api/dmaengine/dmatest.rst
>> index 7ce5e71..0a7e4c3 100644
>> --- a/Documentation/driver-api/dmaengine/dmatest.rst
>> +++ b/Documentation/driver-api/dmaengine/dmatest.rst
>> @@ -26,28 +26,43 @@ Part 2 - When dmatest is built as a module
>>  
>>  Example of usage::
>>  
>> -    % modprobe dmatest channel=dma0chan0 timeout=2000 iterations=1 run=1
>> +    % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1
>>  
>>  ...or::
>>  
>>      % modprobe dmatest
>> -    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>      % echo 2000 > /sys/module/dmatest/parameters/timeout
>>      % echo 1 > /sys/module/dmatest/parameters/iterations
>> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>      % echo 1 > /sys/module/dmatest/parameters/run
>>  
>>  ...or on the kernel command line::
>>  
>> -    dmatest.channel=dma0chan0 dmatest.timeout=2000 dmatest.iterations=1 dmatest.run=1
>> +    dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1
>> +
>> +Example of multi-channel test usage:
>> +    % modprobe dmatest
>> +    % echo 2000 > /sys/module/dmatest/parameters/timeout
>> +    % echo 1 > /sys/module/dmatest/parameters/iterations
>> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>> +    % echo dma0chan1 > /sys/module/dmatest/parameters/channel
>> +    % echo dma0chan2 > /sys/module/dmatest/parameters/channel
> 
> Can I still use:
> echo "" > /sys/module/dmatest/parameters/channel
> 
> to stop dmatest to run on the specific channel(s) or do I need to reboot
> the machine to do so?

is this behavior documented somewhere? or did you discover this from your
experience with using the module?
The short answer to your question is no, with this change you cannot stop
a test by echoing an empty string to the channel parameter, you will either
have to run the test, or reboot the machine.

Setting the channel parameter to an empty string will request all
channels up to "max_channels" parameter value. This is because with this
change, editing the channel parameter will invoke the process of allocating
a thread for the specified channel and storing that thread in a thread
list, after that, setting run to 1 will simply iterate through the thread
list and start all pending threads.

> I normally test multi channel memcpy with:
> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
> echo 2000 > /sys/module/dmatest/parameters/timeout
> echo 20 > /sys/module/dmatest/parameters/iterations
> echo 20 > /sys/module/dmatest/parameters/max_channels
> echo 1 > /sys/module/dmatest/parameters/run
> 
> So it will start running memtest on 20 channels.
> 
> If I do a test on specific channel (different DMA controller) I set the
> channel run the test and then with "" I can revert back to normal
> torture test.

Yes, but the problem is that you either run a test on all channels, or
a single channel. This change makes it possible to specify a list of
channels to test, for example we can now launch a test on channels 0,3,5,6
by doing

echo dma0chan0 > /sys/module/dmatest/parameters/channel
echo dma0chan3 > /sys/module/dmatest/parameters/channel
echo dma0chan5 > /sys/module/dmatest/parameters/channel
echo dma0chan6 > /sys/module/dmatest/parameters/channel
echo 1 > /sys/module/dmatest/parameters/run

as far as I'm aware this functionality was not possible before.

You can still run your torture test with a simple modification:

echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
echo 2000 > /sys/module/dmatest/parameters/timeout
echo 20 > /sys/module/dmatest/parameters/iterations
echo 20 > /sys/module/dmatest/parameters/max_channels
echo "" > /sys/module/dmatest/parameters/channel << allocates 20 channels
echo 1 > /sys/module/dmatest/parameters/run

>> +    % echo 1 > /sys/module/dmatest/parameters/run
>>  
>> +Note: the channel parameter should always be the last parameter set prior to
>> +running the test (setting run=1), this is because upon setting the channel
>> +parameter, that specific channel is requested using the dmaengine and a thread
>> +is created with the existing parameters. This thread is set as pending
>> +and will be executed once run is set to 1. Any parameters set after the thread
>> +is created are not applied.
>>  .. hint::
>>    available channel list could be extracted by running the following command::
>>  
>>      % ls -1 /sys/class/dma/
>>  
>> -Once started a message like "dmatest: Started 1 threads using dma0chan0" is
>> -emitted. After that only test failure messages are reported until the test
>> -stops.
>> +Once started a message like " dmatest: Added 1 threads using dma0chan0" is
>> +emitted. A thread for that specific channel is created and is now pending, the
>> +pending thread is started once run is to 1.
>>  
>>  Note that running a new test will not stop any in progress test.
>>  
>>
> 
> - Péter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

- Seraj
Peter Ujfalusi Aug. 31, 2018, 2:02 p.m. UTC | #4
Hi Seraj,

On 2018-08-31 16:41, Seraj Mohammed wrote:
> Hello,
> 
> On 31/08/18 12:17, Peter Ujfalusi wrote:
>> Hi,
>>
>> On 2018-08-31 14:03, Seraj Alijan wrote:
>>> Modify documentation to add multi channel testing support.
>>>
>>> Signed-off-by: Seraj Alijan <seraj.alijan@sondrel.com>
>>> ---
>>>  Documentation/driver-api/dmaengine/dmatest.rst | 27 ++++++++++++++++++++------
>>>  1 file changed, 21 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/Documentation/driver-api/dmaengine/dmatest.rst b/Documentation/driver-api/dmaengine/dmatest.rst
>>> index 7ce5e71..0a7e4c3 100644
>>> --- a/Documentation/driver-api/dmaengine/dmatest.rst
>>> +++ b/Documentation/driver-api/dmaengine/dmatest.rst
>>> @@ -26,28 +26,43 @@ Part 2 - When dmatest is built as a module
>>>  
>>>  Example of usage::
>>>  
>>> -    % modprobe dmatest channel=dma0chan0 timeout=2000 iterations=1 run=1
>>> +    % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1
>>>  
>>>  ...or::
>>>  
>>>      % modprobe dmatest
>>> -    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>>      % echo 2000 > /sys/module/dmatest/parameters/timeout
>>>      % echo 1 > /sys/module/dmatest/parameters/iterations
>>> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>>      % echo 1 > /sys/module/dmatest/parameters/run
>>>  
>>>  ...or on the kernel command line::
>>>  
>>> -    dmatest.channel=dma0chan0 dmatest.timeout=2000 dmatest.iterations=1 dmatest.run=1
>>> +    dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1
>>> +
>>> +Example of multi-channel test usage:
>>> +    % modprobe dmatest
>>> +    % echo 2000 > /sys/module/dmatest/parameters/timeout
>>> +    % echo 1 > /sys/module/dmatest/parameters/iterations
>>> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>> +    % echo dma0chan1 > /sys/module/dmatest/parameters/channel
>>> +    % echo dma0chan2 > /sys/module/dmatest/parameters/channel
>>
>> Can I still use:
>> echo "" > /sys/module/dmatest/parameters/channel
>>
>> to stop dmatest to run on the specific channel(s) or do I need to reboot
>> the machine to do so?
> 
> is this behavior documented somewhere? or did you discover this from your
> experience with using the module?
> The short answer to your question is no, with this change you cannot stop
> a test by echoing an empty string to the channel parameter, you will either
> have to run the test, or reboot the machine.
> 
> Setting the channel parameter to an empty string will request all
> channels up to "max_channels" parameter value. This is because with this
> change, editing the channel parameter will invoke the process of allocating
> a thread for the specified channel and storing that thread in a thread
> list, after that, setting run to 1 will simply iterate through the thread
> list and start all pending threads.
> 
>> I normally test multi channel memcpy with:
>> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
>> echo 2000 > /sys/module/dmatest/parameters/timeout
>> echo 20 > /sys/module/dmatest/parameters/iterations
>> echo 20 > /sys/module/dmatest/parameters/max_channels
>> echo 1 > /sys/module/dmatest/parameters/run
>>
>> So it will start running memtest on 20 channels.
>>
>> If I do a test on specific channel (different DMA controller) I set the
>> channel run the test and then with "" I can revert back to normal
>> torture test.
> 
> Yes, but the problem is that you either run a test on all channels, or
> a single channel. This change makes it possible to specify a list of
> channels to test, for example we can now launch a test on channels 0,3,5,6
> by doing
> 
> echo dma0chan0 > /sys/module/dmatest/parameters/channel
> echo dma0chan3 > /sys/module/dmatest/parameters/channel
> echo dma0chan5 > /sys/module/dmatest/parameters/channel
> echo dma0chan6 > /sys/module/dmatest/parameters/channel
> echo 1 > /sys/module/dmatest/parameters/run
> 
> as far as I'm aware this functionality was not possible before.

True and it is something which would be nice to have. I could construct
single test run for channels on different DMA controller. That is pretty
cool.

However, if I got it right I need to reboot the machine if I want to
change any of the parameters for a re-run.
Let's say I want to run tests on 6 channel with 50K buffers, 100K 1M, 10M.
I can not do this without rebooting, right?

Would not be possible to:

echo "dma0chan0 dma0chan3 dma0chan5 dma0chan6" >
/sys/module/dmatest/parameters/channel

and use the same logic already existing for max_channels to start off
the tests on different channels?

> You can still run your torture test with a simple modification:
> 
> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
> echo 2000 > /sys/module/dmatest/parameters/timeout
> echo 20 > /sys/module/dmatest/parameters/iterations
> echo 20 > /sys/module/dmatest/parameters/max_channels
> echo "" > /sys/module/dmatest/parameters/channel << allocates 20 channels
> echo 1 > /sys/module/dmatest/parameters/run

Sure, but if I test something on a specific channels I need to reboot.
Or if I want to change parameters for a next run...

> 
>>> +    % echo 1 > /sys/module/dmatest/parameters/run
>>>  
>>> +Note: the channel parameter should always be the last parameter set prior to
>>> +running the test (setting run=1), this is because upon setting the channel
>>> +parameter, that specific channel is requested using the dmaengine and a thread
>>> +is created with the existing parameters. This thread is set as pending
>>> +and will be executed once run is set to 1. Any parameters set after the thread
>>> +is created are not applied.
>>>  .. hint::
>>>    available channel list could be extracted by running the following command::
>>>  
>>>      % ls -1 /sys/class/dma/
>>>  
>>> -Once started a message like "dmatest: Started 1 threads using dma0chan0" is
>>> -emitted. After that only test failure messages are reported until the test
>>> -stops.
>>> +Once started a message like " dmatest: Added 1 threads using dma0chan0" is
>>> +emitted. A thread for that specific channel is created and is now pending, the
>>> +pending thread is started once run is to 1.
>>>  
>>>  Note that running a new test will not stop any in progress test.
>>>  
>>>
>>
>> - Péter
>>
>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>
> 
> - Seraj
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Peter Ujfalusi Aug. 31, 2018, 2:22 p.m. UTC | #5
Hi,

On 2018-08-31 16:41, Seraj Mohammed wrote:
>> Can I still use:
>> echo "" > /sys/module/dmatest/parameters/channel
>>
>> to stop dmatest to run on the specific channel(s) or do I need to reboot
>> the machine to do so?
> 
> is this behavior documented somewhere? or did you discover this from your
> experience with using the module?

If the channels is "" then it is not set. We can change the channels
currently and there is no difference between selecting a channel or
selecting none.

> The short answer to your question is no, with this change you cannot stop
> a test by echoing an empty string to the channel parameter, you will either
> have to run the test, or reboot the machine.
> 
> Setting the channel parameter to an empty string will request all
> channels up to "max_channels" parameter value.

Yes, and it is very useful. What would be even more useful is if via the
channel I could select the starting channel from where the max_channels
will start...

> This is because with this
> change, editing the channel parameter will invoke the process of allocating
> a thread for the specified channel and storing that thread in a thread
> list, after that, setting run to 1 will simply iterate through the thread
> list and start all pending threads.

We have automated regression tests via dmatest's memcpy, it does changes
parameters between runs to gather the data for different transfer sizes,
runs in selected channels and runs also with different max_channels.

It is a regression if we need to reboot between every test to change
parameters, channels, etc.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Seraj Mohammed Aug. 31, 2018, 3:01 p.m. UTC | #6
On 31/08/18 15:02, Peter Ujfalusi wrote:
> Hi Seraj,
> 
> On 2018-08-31 16:41, Seraj Mohammed wrote:
>> Hello,
>>
>> On 31/08/18 12:17, Peter Ujfalusi wrote:
>>> Hi,
>>>
>>> On 2018-08-31 14:03, Seraj Alijan wrote:
>>>> Modify documentation to add multi channel testing support.
>>>>
>>>> Signed-off-by: Seraj Alijan <seraj.alijan@sondrel.com>
>>>> ---
>>>>  Documentation/driver-api/dmaengine/dmatest.rst | 27 ++++++++++++++++++++------
>>>>  1 file changed, 21 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/Documentation/driver-api/dmaengine/dmatest.rst b/Documentation/driver-api/dmaengine/dmatest.rst
>>>> index 7ce5e71..0a7e4c3 100644
>>>> --- a/Documentation/driver-api/dmaengine/dmatest.rst
>>>> +++ b/Documentation/driver-api/dmaengine/dmatest.rst
>>>> @@ -26,28 +26,43 @@ Part 2 - When dmatest is built as a module
>>>>  
>>>>  Example of usage::
>>>>  
>>>> -    % modprobe dmatest channel=dma0chan0 timeout=2000 iterations=1 run=1
>>>> +    % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1
>>>>  
>>>>  ...or::
>>>>  
>>>>      % modprobe dmatest
>>>> -    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>>>      % echo 2000 > /sys/module/dmatest/parameters/timeout
>>>>      % echo 1 > /sys/module/dmatest/parameters/iterations
>>>> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>>>      % echo 1 > /sys/module/dmatest/parameters/run
>>>>  
>>>>  ...or on the kernel command line::
>>>>  
>>>> -    dmatest.channel=dma0chan0 dmatest.timeout=2000 dmatest.iterations=1 dmatest.run=1
>>>> +    dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1
>>>> +
>>>> +Example of multi-channel test usage:
>>>> +    % modprobe dmatest
>>>> +    % echo 2000 > /sys/module/dmatest/parameters/timeout
>>>> +    % echo 1 > /sys/module/dmatest/parameters/iterations
>>>> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>>> +    % echo dma0chan1 > /sys/module/dmatest/parameters/channel
>>>> +    % echo dma0chan2 > /sys/module/dmatest/parameters/channel
>>>
>>> Can I still use:
>>> echo "" > /sys/module/dmatest/parameters/channel
>>>
>>> to stop dmatest to run on the specific channel(s) or do I need to reboot
>>> the machine to do so?
>>
>> is this behavior documented somewhere? or did you discover this from your
>> experience with using the module?
>> The short answer to your question is no, with this change you cannot stop
>> a test by echoing an empty string to the channel parameter, you will either
>> have to run the test, or reboot the machine.
>>
>> Setting the channel parameter to an empty string will request all
>> channels up to "max_channels" parameter value. This is because with this
>> change, editing the channel parameter will invoke the process of allocating
>> a thread for the specified channel and storing that thread in a thread
>> list, after that, setting run to 1 will simply iterate through the thread
>> list and start all pending threads.
>>
>>> I normally test multi channel memcpy with:
>>> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
>>> echo 2000 > /sys/module/dmatest/parameters/timeout
>>> echo 20 > /sys/module/dmatest/parameters/iterations
>>> echo 20 > /sys/module/dmatest/parameters/max_channels
>>> echo 1 > /sys/module/dmatest/parameters/run
>>>
>>> So it will start running memtest on 20 channels.
>>>
>>> If I do a test on specific channel (different DMA controller) I set the
>>> channel run the test and then with "" I can revert back to normal
>>> torture test.
>>
>> Yes, but the problem is that you either run a test on all channels, or
>> a single channel. This change makes it possible to specify a list of
>> channels to test, for example we can now launch a test on channels 0,3,5,6
>> by doing
>>
>> echo dma0chan0 > /sys/module/dmatest/parameters/channel
>> echo dma0chan3 > /sys/module/dmatest/parameters/channel
>> echo dma0chan5 > /sys/module/dmatest/parameters/channel
>> echo dma0chan6 > /sys/module/dmatest/parameters/channel
>> echo 1 > /sys/module/dmatest/parameters/run
>>
>> as far as I'm aware this functionality was not possible before.
> 
> True and it is something which would be nice to have. I could construct
> single test run for channels on different DMA controller. That is pretty
> cool.
> 
> However, if I got it right I need to reboot the machine if I want to
> change any of the parameters for a re-run.
> Let's say I want to run tests on 6 channel with 50K buffers, 100K 1M, 10M.
> I can not do this without rebooting, right?

You only need to reboot the machine if you want to change paameters after
allocating the channels.

Example:

echo 4096 > /sys/module/dmatest/parameters/test_buf_size
echo 1 > /sys/module/dmatest/parameters/iterations
echo 6 > /sys/module/dmatest/parameters/alignment
echo 0 > /sys/module/dmatest/parameters/noverify
echo 0 > /sys/module/dmatest/parameters/norandom
echo 1 > /sys/module/dmatest/parameters/threads_per_chan
echo 20000 > /sys/module/dmatest/parameters/timeout

At the is point, you can still change any of the parameters above without
rebooting

echo dma0chan0 > /sys/module/dmatest/parameters/channel
[   31.465240] dmatest: Added 1 threads using dma0chan0
echo dma0chan1 > /sys/module/dmatest/parameters/channel
[   33.142020] dmatest: Added 1 threads using dma0chan1
echo dma0chan2 > /sys/module/dmatest/parameters/channel
[   34.402123] dmatest: Added 1 threads using dma0chan2

As you can see now channels 0,1, 2 have already been allocated and their
respective threads are pending. At this point if you want to change
any parameters you have to reboot, because the channels have already been
requested with the properties set above.

echo 1 > /sys/module/dmatest/parameters/run
dmatest: dma0chan0-copy0: summary 1 tests, 0 failures 285.71 iops 571
KB/s (0)
dmatest: dma0chan2-copy0: summary 1 tests, 0 failures 142.85 iops 285
KB/s (0)
dmatest: dma0chan1-copy0: summary 1 tests, 0 failures 142.85 iops 428
KB/s (0)

At this point the test is finished and you can run a new test with
completely different parameters without having to reboot.

> Would not be possible to:
> 
> echo "dma0chan0 dma0chan3 dma0chan5 dma0chan6" >
> /sys/module/dmatest/parameters/channel
> 
> and use the same logic already existing for max_channels to start off
> the tests on different channels?

It is possible, but i wouldn't make it possible to start all threads at
once, which is what i want to do. If i do it this way, the test would have
have extract the channels one by one and allocate and start them
sequentially. My patch ensures that when I set run to 1, all channels fire
off at the same time, or as close as possible without having the overhead
of allocating channels inbetween transfers.

>> You can still run your torture test with a simple modification:
>>
>> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
>> echo 2000 > /sys/module/dmatest/parameters/timeout
>> echo 20 > /sys/module/dmatest/parameters/iterations
>> echo 20 > /sys/module/dmatest/parameters/max_channels
>> echo "" > /sys/module/dmatest/parameters/channel << allocates 20 channels
>> echo 1 > /sys/module/dmatest/parameters/run
> 
> Sure, but if I test something on a specific channels I need to reboot.
> Or if I want to change parameters for a next run...
> 
>>
>>>> +    % echo 1 > /sys/module/dmatest/parameters/run
>>>>  
>>>> +Note: the channel parameter should always be the last parameter set prior to
>>>> +running the test (setting run=1), this is because upon setting the channel
>>>> +parameter, that specific channel is requested using the dmaengine and a thread
>>>> +is created with the existing parameters. This thread is set as pending
>>>> +and will be executed once run is set to 1. Any parameters set after the thread
>>>> +is created are not applied.
>>>>  .. hint::
>>>>    available channel list could be extracted by running the following command::
>>>>  
>>>>      % ls -1 /sys/class/dma/
>>>>  
>>>> -Once started a message like "dmatest: Started 1 threads using dma0chan0" is
>>>> -emitted. After that only test failure messages are reported until the test
>>>> -stops.
>>>> +Once started a message like " dmatest: Added 1 threads using dma0chan0" is
>>>> +emitted. A thread for that specific channel is created and is now pending, the
>>>> +pending thread is started once run is to 1.
>>>>  
>>>>  Note that running a new test will not stop any in progress test.
>>>>  
>>>>
>>>
>>> - Péter
>>>
>>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>>
>>
>> - Seraj
>>
> 
> - Péter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
Seraj Mohammed Aug. 31, 2018, 3:42 p.m. UTC | #7
On 31/08/18 12:29, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-31 14:03, Seraj Alijan wrote:
>> Modify documentation to add multi channel testing support.
>>
>> Signed-off-by: Seraj Alijan <seraj.alijan@sondrel.com>
>> ---
>>  Documentation/driver-api/dmaengine/dmatest.rst | 27 ++++++++++++++++++++------
>>  1 file changed, 21 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/driver-api/dmaengine/dmatest.rst b/Documentation/driver-api/dmaengine/dmatest.rst
>> index 7ce5e71..0a7e4c3 100644
>> --- a/Documentation/driver-api/dmaengine/dmatest.rst
>> +++ b/Documentation/driver-api/dmaengine/dmatest.rst
>> @@ -26,28 +26,43 @@ Part 2 - When dmatest is built as a module
>>  
>>  Example of usage::
>>  
>> -    % modprobe dmatest channel=dma0chan0 timeout=2000 iterations=1 run=1
>> +    % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1
>>  
>>  ...or::
>>  
>>      % modprobe dmatest
>> -    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>      % echo 2000 > /sys/module/dmatest/parameters/timeout
>>      % echo 1 > /sys/module/dmatest/parameters/iterations
>> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>>      % echo 1 > /sys/module/dmatest/parameters/run
>>  
>>  ...or on the kernel command line::
>>  
>> -    dmatest.channel=dma0chan0 dmatest.timeout=2000 dmatest.iterations=1 dmatest.run=1
>> +    dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1
>> +
>> +Example of multi-channel test usage:
>> +    % modprobe dmatest
>> +    % echo 2000 > /sys/module/dmatest/parameters/timeout
>> +    % echo 1 > /sys/module/dmatest/parameters/iterations
>> +    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
>> +    % echo dma0chan1 > /sys/module/dmatest/parameters/channel
>> +    % echo dma0chan2 > /sys/module/dmatest/parameters/channel
>> +    % echo 1 > /sys/module/dmatest/parameters/run
>>  
>> +Note: the channel parameter should always be the last parameter set prior to
>> +running the test (setting run=1), this is because upon setting the channel
>> +parameter, that specific channel is requested using the dmaengine and a thread
>> +is created with the existing parameters.
> 
> When the channel is going to be released after this change?
> 
> It is a bit awkward currently that after the test finished the
> channel(s) are still requested and it can be released by
> cat /sys/module/dmatest/parameters/run

This patch does not tackle this issue, after the test is run these
channels remain requested, you can still clear them the same way.

> or to run the test again and before the next run the channel(s) are
> going to be released just to be requested again.

With this change, after you run your test, the channels remain requested
but their respective threads are no longer considered pending. So when
you issue:
echo 1 > /sys/module/dmatest/parameters/run

The test will check if it has any pending threads, if it sees that the
thread list is populated, but non of the threads are pending, it will
clear them all. You would have to requested the channels again before
attempting to start another run.

This same behavior is applied when you request a channel after running a
test, it will clear all previous threads before requesting new channels.

example scenario 1: issuing run command after completing test
echo 2000 > /sys/module/dmatest/parameters/timeout
echo 1 > /sys/module/dmatest/parameters/iterations
echo dma0chan0 > /sys/module/dmatest/parameters/channel
[ 1295.534205] dmatest: Added 1 threads using dma0chan0
echo dma0chan1 > /sys/module/dmatest/parameters/channel
[ 1295.543496] dmatest: Added 1 threads using dma0chan1
echo dma0chan2 > /sys/module/dmatest/parameters/channel
[ 1295.549113] dmatest: Added 1 threads using dma0chan2
echo 1 > /sys/module/dmatest/parameters/run
[ 1296.436301] dmatest: dma0chan1-copy0: summary 1 tests, 0 failures
400.00 iops 0 KB/s (0)
[ 1296.441081] dmatest: dma0chan2-copy0: summary 1 tests, 0 failures
181.81 iops 363 KB/s (0)
[ 1296.441590] dmatest: dma0chan0-copy0: summary 1 tests, 0 failures
222.22 iops 666 KB/s (0)
echo 1 > /sys/module/dmatest/parameters/run

As you can see, issuing the run command again does nothing, it simply
checked that it had no pending threads, so it cleared all channels.

example scenarios 2: requesting channel after completing test
echo dma0chan0 > /sys/module/dmatest/parameters/channel
[ 1394.279145] dmatest: Added 1 threads using dma0chan0
echo dma0chan1 > /sys/module/dmatest/parameters/channel
[ 1395.877829] dmatest: Added 1 threads using dma0chan1
echo dma0chan2 > /sys/module/dmatest/parameters/channel
[ 1396.776893] dmatest: Added 1 threads using dma0chan2
echo 1 > /sys/module/dmatest/parameters/run
[ 1400.798124] dmatest: dma0chan1-copy0: summary 1 tests, 0 failures
345.33 iops 758 KB/s (0)
[ 1400.799443] dmatest: dma0chan0-copy0: summary 1 tests, 0 failures
333.33 iops 1000 KB/s (0)
[ 1400.799688] dmatest: dma0chan2-copy0: summary 1 tests, 0 failures
333.33 iops 666 KB/s (0)

echo dma0chan1 > /sys/module/dmatest/parameters/channel
[ 1405.373603] dmatest: Added 1 threads using dma0chan1
echo 1 > /sys/module/dmatest/parameters/run
[ 1406.512495] dmatest: dma0chan1-copy0: summary 1 tests, 0 failures
200.00 iops 400 KB/s (0)

In this example you can see that you can request a new channel after
completing a test, the test has automatically identified that it has a
list of non pending threads from the previous run, it cleared them, and
allocated the new channel.

>> This thread is set as pending
>> +and will be executed once run is set to 1. Any parameters set after the thread
>> +is created are not applied.
>>  .. hint::
>>    available channel list could be extracted by running the following command::
>>  
>>      % ls -1 /sys/class/dma/
>>  
>> -Once started a message like "dmatest: Started 1 threads using dma0chan0" is
>> -emitted. After that only test failure messages are reported until the test
>> -stops.
>> +Once started a message like " dmatest: Added 1 threads using dma0chan0" is
>> +emitted. A thread for that specific channel is created and is now pending, the
>> +pending thread is started once run is to 1.
>>  
>>  Note that running a new test will not stop any in progress test.
>>  
>>
> 
> - Péter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
Seraj Mohammed Aug. 31, 2018, 3:48 p.m. UTC | #8
Hi,

On 31/08/18 15:22, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-31 16:41, Seraj Mohammed wrote:
>>> Can I still use:
>>> echo "" > /sys/module/dmatest/parameters/channel
>>>
>>> to stop dmatest to run on the specific channel(s) or do I need to reboot
>>> the machine to do so?
>>
>> is this behavior documented somewhere? or did you discover this from your
>> experience with using the module?
> 
> If the channels is "" then it is not set. We can change the channels
> currently and there is no difference between selecting a channel or
> selecting none.
> 
>> The short answer to your question is no, with this change you cannot stop
>> a test by echoing an empty string to the channel parameter, you will either
>> have to run the test, or reboot the machine.
>>
>> Setting the channel parameter to an empty string will request all
>> channels up to "max_channels" parameter value.
> 
> Yes, and it is very useful. What would be even more useful is if via the
> channel I could select the starting channel from where the max_channels
> will start...

Since this patch already allows you to specifically select which
channels to run on, i don't see the benefit in allocating channels using
ranges.

>> This is because with this
>> change, editing the channel parameter will invoke the process of allocating
>> a thread for the specified channel and storing that thread in a thread
>> list, after that, setting run to 1 will simply iterate through the thread
>> list and start all pending threads.
> 
> We have automated regression tests via dmatest's memcpy, it does changes
> parameters between runs to gather the data for different transfer sizes,
> runs in selected channels and runs also with different max_channels.
> 
> It is a regression if we need to reboot between every test to change
> parameters, channels, etc.

Once you have successfully completed a test, you don't need to reboot to
start a new one with different parameters.

> - Péter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
Peter Ujfalusi Sept. 3, 2018, 8:19 a.m. UTC | #9
Hi,

On 2018-08-31 18:01, Seraj Mohammed wrote:
>> However, if I got it right I need to reboot the machine if I want to
>> change any of the parameters for a re-run.
>> Let's say I want to run tests on 6 channel with 50K buffers, 100K 1M, 10M.
>> I can not do this without rebooting, right?
> 
> You only need to reboot the machine if you want to change paameters after
> allocating the channels.

Instead of reboot running the test is fine to clear things up.

> Example:
> 
> echo 4096 > /sys/module/dmatest/parameters/test_buf_size
> echo 1 > /sys/module/dmatest/parameters/iterations
> echo 6 > /sys/module/dmatest/parameters/alignment
> echo 0 > /sys/module/dmatest/parameters/noverify
> echo 0 > /sys/module/dmatest/parameters/norandom
> echo 1 > /sys/module/dmatest/parameters/threads_per_chan
> echo 20000 > /sys/module/dmatest/parameters/timeout
> 
> At the is point, you can still change any of the parameters above without
> rebooting

But I can not do:
echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
echo 2000 > /sys/module/dmatest/parameters/timeout
echo 20 > /sys/module/dmatest/parameters/iterations
echo 20 > /sys/module/dmatest/parameters/max_channels
echo 1 > /sys/module/dmatest/parameters/run

it will _not_ start 20 iteration tests on 20 channels.

> 
> echo dma0chan0 > /sys/module/dmatest/parameters/channel
> [   31.465240] dmatest: Added 1 threads using dma0chan0
> echo dma0chan1 > /sys/module/dmatest/parameters/channel
> [   33.142020] dmatest: Added 1 threads using dma0chan1
> echo dma0chan2 > /sys/module/dmatest/parameters/channel
> [   34.402123] dmatest: Added 1 threads using dma0chan2

I need to:
echo dma0chan10 > /sys/module/dmatest/parameters/channel
cat /sys/module/dmatest/parameters/channel
dma0chan10

echo dma0chan11 > /sys/module/dmatest/parameters/channel
cat /sys/module/dmatest/parameters/channel
dma0chan11

^ it tells me that only dma0chan11 is in channels while in fact I have
dma0chan10 and dma0chan11 selected.

then I run the test:
echo 1 > /sys/module/dmatest/parameters/run
[  514.370959] dmatest: dma0chan10-copy: summary 1 tests, 0 failures
7692 iops 15384 KB/s (0)
[  514.371099] dmatest: dma0chan11-copy: summary 1 tests, 0 failures
11111 iops 22222 KB/s (0)

After this:
cat /sys/module/dmatest/parameters/channel returns nothing, which I
believe is correct. So I could be able to run the 20 iteration on 20
channels, but I can not:
echo 20 > /sys/module/dmatest/parameters/iterations
echo 20 > /sys/module/dmatest/parameters/max_channels
echo 1 > /sys/module/dmatest/parameters/run

The patch effectively breaks the batch mode via max_channels.

> As you can see now channels 0,1, 2 have already been allocated and their
> respective threads are pending. At this point if you want to change
> any parameters you have to reboot, because the channels have already been
> requested with the properties set above.
> 
> echo 1 > /sys/module/dmatest/parameters/run
> dmatest: dma0chan0-copy0: summary 1 tests, 0 failures 285.71 iops 571
> KB/s (0)
> dmatest: dma0chan2-copy0: summary 1 tests, 0 failures 142.85 iops 285
> KB/s (0)
> dmatest: dma0chan1-copy0: summary 1 tests, 0 failures 142.85 iops 428
> KB/s (0)
> 
> At this point the test is finished and you can run a new test with
> completely different parameters without having to reboot.

That's fine.

If I want to just repeat the same test then I would put the same
channels back in a loop and run it again to run them overnight for example.

But it is still unclear how the channels will be released..
cat /sys/class/dma/dma0chan10/in_use
0
echo dma0chan10 > /sys/module/dmatest/parameters/channel
cat /sys/class/dma/dma0chan10/in_use
1
echo 1 > /sys/module/dmatest/parameters/run
[  690.326039] dmatest: dma0chan10-copy: summary 20 tests, 0 failures 71
iops 290511 KB/s (0)
cat /sys/class/dma/dma0chan10/in_use
1
echo 1 > /sys/module/dmatest/parameters/run
# will not run any tests
cat /sys/class/dma/dma0chan10/in_use
1

echo dma0chan12 > /sys/module/dmatest/parameters/channel
cat /sys/class/dma/dma0chan10/in_use
0
cat /sys/class/dma/dma0chan12/in_use
1


So it appears that the channel is going to be released when a new
channel is added, right?

Which brought up some interesting thing:
echo "" > /sys/module/dmatest/parameters/channel

Will add the 20 channels to the test :o

One thing would be really nice is to print something when we hit run and
the dmatest actually going to do something or if the dmatest is not
configured properly and will not going to run any test.


> 
>> Would not be possible to:
>>
>> echo "dma0chan0 dma0chan3 dma0chan5 dma0chan6" >
>> /sys/module/dmatest/parameters/channel
>>
>> and use the same logic already existing for max_channels to start off
>> the tests on different channels?
> 
> It is possible, but i wouldn't make it possible to start all threads at
> once, which is what i want to do. If i do it this way, the test would have
> have extract the channels one by one and allocate and start them
> sequentially. My patch ensures that when I set run to 1, all channels fire
> off at the same time, or as close as possible without having the overhead
> of allocating channels inbetween transfers.
> 
>>> You can still run your torture test with a simple modification:
>>>
>>> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
>>> echo 2000 > /sys/module/dmatest/parameters/timeout
>>> echo 20 > /sys/module/dmatest/parameters/iterations
>>> echo 20 > /sys/module/dmatest/parameters/max_channels
>>> echo "" > /sys/module/dmatest/parameters/channel << allocates 20 channels
>>> echo 1 > /sys/module/dmatest/parameters/run
>>
>> Sure, but if I test something on a specific channels I need to reboot.
>> Or if I want to change parameters for a next run...
>>
>>>
>>>>> +    % echo 1 > /sys/module/dmatest/parameters/run
>>>>>  
>>>>> +Note: the channel parameter should always be the last parameter set prior to
>>>>> +running the test (setting run=1), this is because upon setting the channel
>>>>> +parameter, that specific channel is requested using the dmaengine and a thread
>>>>> +is created with the existing parameters. This thread is set as pending
>>>>> +and will be executed once run is set to 1. Any parameters set after the thread
>>>>> +is created are not applied.
>>>>>  .. hint::
>>>>>    available channel list could be extracted by running the following command::
>>>>>  
>>>>>      % ls -1 /sys/class/dma/
>>>>>  
>>>>> -Once started a message like "dmatest: Started 1 threads using dma0chan0" is
>>>>> -emitted. After that only test failure messages are reported until the test
>>>>> -stops.
>>>>> +Once started a message like " dmatest: Added 1 threads using dma0chan0" is
>>>>> +emitted. A thread for that specific channel is created and is now pending, the
>>>>> +pending thread is started once run is to 1.
>>>>>  
>>>>>  Note that running a new test will not stop any in progress test.
>>>>>  
>>>>>
>>>>
>>>> - Péter
>>>>
>>>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>>>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>>>
>>>
>>> - Seraj
>>>
>>
>> - Péter
>>
>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Seraj Mohammed Sept. 3, 2018, 2:49 p.m. UTC | #10
Hi,

On 03/09/18 09:19, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-31 18:01, Seraj Mohammed wrote:
>>> However, if I got it right I need to reboot the machine if I want to
>>> change any of the parameters for a re-run.
>>> Let's say I want to run tests on 6 channel with 50K buffers, 100K 1M, 10M.
>>> I can not do this without rebooting, right?
>>
>> You only need to reboot the machine if you want to change paameters after
>> allocating the channels.
> 
> Instead of reboot running the test is fine to clear things up.
> 
>> Example:
>>
>> echo 4096 > /sys/module/dmatest/parameters/test_buf_size
>> echo 1 > /sys/module/dmatest/parameters/iterations
>> echo 6 > /sys/module/dmatest/parameters/alignment
>> echo 0 > /sys/module/dmatest/parameters/noverify
>> echo 0 > /sys/module/dmatest/parameters/norandom
>> echo 1 > /sys/module/dmatest/parameters/threads_per_chan
>> echo 20000 > /sys/module/dmatest/parameters/timeout
>>
>> At the is point, you can still change any of the parameters above without
>> rebooting
> 
> But I can not do:
> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
> echo 2000 > /sys/module/dmatest/parameters/timeout
> echo 20 > /sys/module/dmatest/parameters/iterations
> echo 20 > /sys/module/dmatest/parameters/max_channels
> echo 1 > /sys/module/dmatest/parameters/run
> 
> it will _not_ start 20 iteration tests on 20 channels.

This is correct behavior, because issuing
echo 1 > /sys/module/dmatest/parameters/run
will no longer handle channel allocation with this patch, all
functionality dealing with allocating channels has been stripped off
from the run callback and put into a new callback that is triggered by
the channel parameter.

So under the new change, you can do the same by:
echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
echo 2000 > /sys/module/dmatest/parameters/timeout
echo 20 > /sys/module/dmatest/parameters/iterations
echo 20 > /sys/module/dmatest/parameters/max_channels
echo "" > /sys/module/dmatest/parameters/channel << Will trigger call
back to allocate up to max_channels if invoked with empty string
echo 1 > /sys/module/dmatest/parameters/run

With this change setting run to 1 will only launch threads that have
already been allocated by invoking the channel parameter by either
echoing an empty string, or a specific channel. If no channels are
allocated, setting run to 1 will not do anything.
>>
>> echo dma0chan0 > /sys/module/dmatest/parameters/channel
>> [   31.465240] dmatest: Added 1 threads using dma0chan0
>> echo dma0chan1 > /sys/module/dmatest/parameters/channel
>> [   33.142020] dmatest: Added 1 threads using dma0chan1
>> echo dma0chan2 > /sys/module/dmatest/parameters/channel
>> [   34.402123] dmatest: Added 1 threads using dma0chan2
> 
> I need to:
> echo dma0chan10 > /sys/module/dmatest/parameters/channel
> cat /sys/module/dmatest/parameters/channel
> dma0chan10
> 
> echo dma0chan11 > /sys/module/dmatest/parameters/channel
> cat /sys/module/dmatest/parameters/channel
> dma0chan11
> 
> ^ it tells me that only dma0chan11 is in channels while in fact I have
> dma0chan10 and dma0chan11 selected.

Correct, reading the channel parameter will report back the name of the
LAST channel that was allocated, not a string containing all channels.

> then I run the test:
> echo 1 > /sys/module/dmatest/parameters/run
> [  514.370959] dmatest: dma0chan10-copy: summary 1 tests, 0 failures
> 7692 iops 15384 KB/s (0)
> [  514.371099] dmatest: dma0chan11-copy: summary 1 tests, 0 failures
> 11111 iops 22222 KB/s (0)
> 
> After this:
> cat /sys/module/dmatest/parameters/channel returns nothing, which I
> believe is correct. So I could be able to run the 20 iteration on 20
> channels, but I can not:
> echo 20 > /sys/module/dmatest/parameters/iterations
> echo 20 > /sys/module/dmatest/parameters/max_channels
> echo 1 > /sys/module/dmatest/parameters/run
> 
> The patch effectively breaks the batch mode via max_channels.

It doesn't matter if the channel string is empty, you need to invoke the
channel parameter to allocate channels prior to running the test.

This should work

echo 20 > /sys/module/dmatest/parameters/iterations
echo 20 > /sys/module/dmatest/parameters/max_channels
echo "" > /sys/module/dmatest/parameters/channel
echo 1 > /sys/module/dmatest/parameters/run


>> As you can see now channels 0,1, 2 have already been allocated and their
>> respective threads are pending. At this point if you want to change
>> any parameters you have to reboot, because the channels have already been
>> requested with the properties set above.
>>
>> echo 1 > /sys/module/dmatest/parameters/run
>> dmatest: dma0chan0-copy0: summary 1 tests, 0 failures 285.71 iops 571
>> KB/s (0)
>> dmatest: dma0chan2-copy0: summary 1 tests, 0 failures 142.85 iops 285
>> KB/s (0)
>> dmatest: dma0chan1-copy0: summary 1 tests, 0 failures 142.85 iops 428
>> KB/s (0)
>>
>> At this point the test is finished and you can run a new test with
>> completely different parameters without having to reboot.
> 
> That's fine.
> 
> If I want to just repeat the same test then I would put the same
> channels back in a loop and run it again to run them overnight for example.
> 
> But it is still unclear how the channels will be released..
> cat /sys/class/dma/dma0chan10/in_use
> 0
> echo dma0chan10 > /sys/module/dmatest/parameters/channel
> cat /sys/class/dma/dma0chan10/in_use
> 1
> echo 1 > /sys/module/dmatest/parameters/run
> [  690.326039] dmatest: dma0chan10-copy: summary 20 tests, 0 failures 71
> iops 290511 KB/s (0)
> cat /sys/class/dma/dma0chan10/in_use
> 1
> echo 1 > /sys/module/dmatest/parameters/run
> # will not run any tests
> cat /sys/class/dma/dma0chan10/in_use
> 1
> 
> echo dma0chan12 > /sys/module/dmatest/parameters/channel
> cat /sys/class/dma/dma0chan10/in_use
> 0
> cat /sys/class/dma/dma0chan12/in_use
> 1
> 
> 
> So it appears that the channel is going to be released when a new
> channel is added, right?

Correct, after completing a test, adding a new channel will clear all
previously allocated channels to ensure the new test is not polluted
with residual parameters from prior test runs.

Another way of clearing channels from previous test run is to query the
run parameter:

cat /sys/module/dmatest/parameters/run

should clear all channels allocated by previous test run.
> Which brought up some interesting thing:
> echo "" > /sys/module/dmatest/parameters/channel
> 
> Will add the 20 channels to the test :o
> 
> One thing would be really nice is to print something when we hit run and
> the dmatest actually going to do something or if the dmatest is not
> configured properly and will not going to run any test.

Good idea, adding a message informing user should clear up any confusion.

> 
>>
>>> Would not be possible to:
>>>
>>> echo "dma0chan0 dma0chan3 dma0chan5 dma0chan6" >
>>> /sys/module/dmatest/parameters/channel
>>>
>>> and use the same logic already existing for max_channels to start off
>>> the tests on different channels?
>>
>> It is possible, but i wouldn't make it possible to start all threads at
>> once, which is what i want to do. If i do it this way, the test would have
>> have extract the channels one by one and allocate and start them
>> sequentially. My patch ensures that when I set run to 1, all channels fire
>> off at the same time, or as close as possible without having the overhead
>> of allocating channels inbetween transfers.
>>
>>>> You can still run your torture test with a simple modification:
>>>>
>>>> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
>>>> echo 2000 > /sys/module/dmatest/parameters/timeout
>>>> echo 20 > /sys/module/dmatest/parameters/iterations
>>>> echo 20 > /sys/module/dmatest/parameters/max_channels
>>>> echo "" > /sys/module/dmatest/parameters/channel << allocates 20 channels
>>>> echo 1 > /sys/module/dmatest/parameters/run
>>>
>>> Sure, but if I test something on a specific channels I need to reboot.
>>> Or if I want to change parameters for a next run...
>>>
>>>>
>>>>>> +    % echo 1 > /sys/module/dmatest/parameters/run
>>>>>>  
>>>>>> +Note: the channel parameter should always be the last parameter set prior to
>>>>>> +running the test (setting run=1), this is because upon setting the channel
>>>>>> +parameter, that specific channel is requested using the dmaengine and a thread
>>>>>> +is created with the existing parameters. This thread is set as pending
>>>>>> +and will be executed once run is set to 1. Any parameters set after the thread
>>>>>> +is created are not applied.
>>>>>>  .. hint::
>>>>>>    available channel list could be extracted by running the following command::
>>>>>>  
>>>>>>      % ls -1 /sys/class/dma/
>>>>>>  
>>>>>> -Once started a message like "dmatest: Started 1 threads using dma0chan0" is
>>>>>> -emitted. After that only test failure messages are reported until the test
>>>>>> -stops.
>>>>>> +Once started a message like " dmatest: Added 1 threads using dma0chan0" is
>>>>>> +emitted. A thread for that specific channel is created and is now pending, the
>>>>>> +pending thread is started once run is to 1.
>>>>>>  
>>>>>>  Note that running a new test will not stop any in progress test.
>>>>>>  
>>>>>>
>>>>>
>>>>> - Péter
>>>>>
>>>>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>>>>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>>>>
>>>>
>>>> - Seraj
>>>>
>>>
>>> - Péter
>>>
>>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>>
> 
> - Péter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

- Seraj
Peter Ujfalusi Sept. 4, 2018, 7:15 p.m. UTC | #11
Hi,

On 09/03/2018 05:49 PM, Seraj Mohammed wrote:
> Hi,
> 
> On 03/09/18 09:19, Peter Ujfalusi wrote:
>> Hi,
>>
>> On 2018-08-31 18:01, Seraj Mohammed wrote:
>>>> However, if I got it right I need to reboot the machine if I want to
>>>> change any of the parameters for a re-run.
>>>> Let's say I want to run tests on 6 channel with 50K buffers, 100K 1M, 10M.
>>>> I can not do this without rebooting, right?
>>>
>>> You only need to reboot the machine if you want to change paameters after
>>> allocating the channels.
>>
>> Instead of reboot running the test is fine to clear things up.
>>
>>> Example:
>>>
>>> echo 4096 > /sys/module/dmatest/parameters/test_buf_size
>>> echo 1 > /sys/module/dmatest/parameters/iterations
>>> echo 6 > /sys/module/dmatest/parameters/alignment
>>> echo 0 > /sys/module/dmatest/parameters/noverify
>>> echo 0 > /sys/module/dmatest/parameters/norandom
>>> echo 1 > /sys/module/dmatest/parameters/threads_per_chan
>>> echo 20000 > /sys/module/dmatest/parameters/timeout
>>>
>>> At the is point, you can still change any of the parameters above without
>>> rebooting
>>
>> But I can not do:
>> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
>> echo 2000 > /sys/module/dmatest/parameters/timeout
>> echo 20 > /sys/module/dmatest/parameters/iterations
>> echo 20 > /sys/module/dmatest/parameters/max_channels
>> echo 1 > /sys/module/dmatest/parameters/run
>>
>> it will _not_ start 20 iteration tests on 20 channels.
> 
> This is correct behavior, because issuing
> echo 1 > /sys/module/dmatest/parameters/run
> will no longer handle channel allocation with this patch, all
> functionality dealing with allocating channels has been stripped off
> from the run callback and put into a new callback that is triggered by
> the channel parameter.
> 
> So under the new change, you can do the same by:
> echo 8000000 > /sys/module/dmatest/parameters/test_buf_size
> echo 2000 > /sys/module/dmatest/parameters/timeout
> echo 20 > /sys/module/dmatest/parameters/iterations
> echo 20 > /sys/module/dmatest/parameters/max_channels
> echo "" > /sys/module/dmatest/parameters/channel << Will trigger call
> back to allocate up to max_channels if invoked with empty string
> echo 1 > /sys/module/dmatest/parameters/run

Yep, I figured that out after trying this and that...

>> I need to:
>> echo dma0chan10 > /sys/module/dmatest/parameters/channel
>> cat /sys/module/dmatest/parameters/channel
>> dma0chan10
>>
>> echo dma0chan11 > /sys/module/dmatest/parameters/channel
>> cat /sys/module/dmatest/parameters/channel
>> dma0chan11
>>
>> ^ it tells me that only dma0chan11 is in channels while in fact I have
>> dma0chan10 and dma0chan11 selected.
> 
> Correct, reading the channel parameter will report back the name of the
> LAST channel that was allocated, not a string containing all channels.

I think this is a bit awkward. What I would expect that it will give me the
list of channels I have already scheduled for the test. They can be in the
allocated state with different parameters, but that is minor thing.

>> then I run the test:
>> echo 1 > /sys/module/dmatest/parameters/run
>> [  514.370959] dmatest: dma0chan10-copy: summary 1 tests, 0 failures
>> 7692 iops 15384 KB/s (0)
>> [  514.371099] dmatest: dma0chan11-copy: summary 1 tests, 0 failures
>> 11111 iops 22222 KB/s (0)
>>
>> After this:
>> cat /sys/module/dmatest/parameters/channel returns nothing, which I
>> believe is correct. So I could be able to run the 20 iteration on 20
>> channels, but I can not:
>> echo 20 > /sys/module/dmatest/parameters/iterations
>> echo 20 > /sys/module/dmatest/parameters/max_channels
>> echo 1 > /sys/module/dmatest/parameters/run
>>
>> The patch effectively breaks the batch mode via max_channels.
> 
> It doesn't matter if the channel string is empty, you need to invoke the
> channel parameter to allocate channels prior to running the test.
> 
> This should work
> 
> echo 20 > /sys/module/dmatest/parameters/iterations
> echo 20 > /sys/module/dmatest/parameters/max_channels
> echo "" > /sys/module/dmatest/parameters/channel
> echo 1 > /sys/module/dmatest/parameters/run

Yes, this works.

>>> As you can see now channels 0,1, 2 have already been allocated and their
>>> respective threads are pending. At this point if you want to change
>>> any parameters you have to reboot, because the channels have already been
>>> requested with the properties set above.
>>>
>>> echo 1 > /sys/module/dmatest/parameters/run
>>> dmatest: dma0chan0-copy0: summary 1 tests, 0 failures 285.71 iops 571
>>> KB/s (0)
>>> dmatest: dma0chan2-copy0: summary 1 tests, 0 failures 142.85 iops 285
>>> KB/s (0)
>>> dmatest: dma0chan1-copy0: summary 1 tests, 0 failures 142.85 iops 428
>>> KB/s (0)
>>>
>>> At this point the test is finished and you can run a new test with
>>> completely different parameters without having to reboot.
>>
>> That's fine.
>>
>> If I want to just repeat the same test then I would put the same
>> channels back in a loop and run it again to run them overnight for example.
>>
>> But it is still unclear how the channels will be released..
>> cat /sys/class/dma/dma0chan10/in_use
>> 0
>> echo dma0chan10 > /sys/module/dmatest/parameters/channel
>> cat /sys/class/dma/dma0chan10/in_use
>> 1
>> echo 1 > /sys/module/dmatest/parameters/run
>> [  690.326039] dmatest: dma0chan10-copy: summary 20 tests, 0 failures 71
>> iops 290511 KB/s (0)
>> cat /sys/class/dma/dma0chan10/in_use
>> 1
>> echo 1 > /sys/module/dmatest/parameters/run
>> # will not run any tests
>> cat /sys/class/dma/dma0chan10/in_use
>> 1
>>
>> echo dma0chan12 > /sys/module/dmatest/parameters/channel
>> cat /sys/class/dma/dma0chan10/in_use
>> 0
>> cat /sys/class/dma/dma0chan12/in_use
>> 1
>>
>>
>> So it appears that the channel is going to be released when a new
>> channel is added, right?
> 
> Correct, after completing a test, adding a new channel will clear all
> previously allocated channels to ensure the new test is not polluted
> with residual parameters from prior test runs.
> 
> Another way of clearing channels from previous test run is to query the
> run parameter:
> 
> cat /sys/module/dmatest/parameters/run
> 
> should clear all channels allocated by previous test run.

Since the channels from the previous run will be discarded - even if in the
next run we configure the same channels, wouldn't it be nicer to release
everything when the test finishes to not hog on resources?

>> Which brought up some interesting thing:
>> echo "" > /sys/module/dmatest/parameters/channel
>>
>> Will add the 20 channels to the test :o
>>
>> One thing would be really nice is to print something when we hit run and
>> the dmatest actually going to do something or if the dmatest is not
>> configured properly and will not going to run any test.
> 
> Good idea, adding a message informing user should clear up any confusion.

That would be great. The threads could print that they are starting or the
trigger code tells how many threads are going to be run, or if none is
configured tell that.

But I think the documentation should be updated to avoid a mail thread this
long to figure out what to expect and how to use the new dmatest ;)
diff mbox series

Patch

diff --git a/Documentation/driver-api/dmaengine/dmatest.rst b/Documentation/driver-api/dmaengine/dmatest.rst
index 7ce5e71..0a7e4c3 100644
--- a/Documentation/driver-api/dmaengine/dmatest.rst
+++ b/Documentation/driver-api/dmaengine/dmatest.rst
@@ -26,28 +26,43 @@  Part 2 - When dmatest is built as a module
 
 Example of usage::
 
-    % modprobe dmatest channel=dma0chan0 timeout=2000 iterations=1 run=1
+    % modprobe dmatest timeout=2000 iterations=1 channel=dma0chan0 run=1
 
 ...or::
 
     % modprobe dmatest
-    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
     % echo 2000 > /sys/module/dmatest/parameters/timeout
     % echo 1 > /sys/module/dmatest/parameters/iterations
+    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
     % echo 1 > /sys/module/dmatest/parameters/run
 
 ...or on the kernel command line::
 
-    dmatest.channel=dma0chan0 dmatest.timeout=2000 dmatest.iterations=1 dmatest.run=1
+    dmatest.timeout=2000 dmatest.iterations=1 dmatest.channel=dma0chan0 dmatest.run=1
+
+Example of multi-channel test usage:
+    % modprobe dmatest
+    % echo 2000 > /sys/module/dmatest/parameters/timeout
+    % echo 1 > /sys/module/dmatest/parameters/iterations
+    % echo dma0chan0 > /sys/module/dmatest/parameters/channel
+    % echo dma0chan1 > /sys/module/dmatest/parameters/channel
+    % echo dma0chan2 > /sys/module/dmatest/parameters/channel
+    % echo 1 > /sys/module/dmatest/parameters/run
 
+Note: the channel parameter should always be the last parameter set prior to
+running the test (setting run=1), this is because upon setting the channel
+parameter, that specific channel is requested using the dmaengine and a thread
+is created with the existing parameters. This thread is set as pending
+and will be executed once run is set to 1. Any parameters set after the thread
+is created are not applied.
 .. hint::
   available channel list could be extracted by running the following command::
 
     % ls -1 /sys/class/dma/
 
-Once started a message like "dmatest: Started 1 threads using dma0chan0" is
-emitted. After that only test failure messages are reported until the test
-stops.
+Once started a message like " dmatest: Added 1 threads using dma0chan0" is
+emitted. A thread for that specific channel is created and is now pending, the
+pending thread is started once run is to 1.
 
 Note that running a new test will not stop any in progress test.