diff mbox series

[rt-tests,v1,4/6] cyclictest: Mimik --smp behavior with --affinity

Message ID 20201218141935.24151-5-dwagner@suse.de
State Superseded
Headers show
Series libnuma cleanups for cyclictest | expand

Commit Message

Daniel Wagner Dec. 18, 2020, 2:19 p.m. UTC
Let --affinity without an argument behave in the same way as
--smp. Run a thread on each CPU. This makes cyclictest behave as the
rest of the rt-tests when --affinity is used.

Reviewed-by: Daniel Wagner <dwagner@suse.de>
---
 src/cyclictest/cyclictest.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

John Kacur Jan. 26, 2021, 5:55 a.m. UTC | #1
On Fri, 18 Dec 2020, Daniel Wagner wrote:

> Let --affinity without an argument behave in the same way as

> --smp. Run a thread on each CPU. This makes cyclictest behave as the

> rest of the rt-tests when --affinity is used.

> 

> Reviewed-by: Daniel Wagner <dwagner@suse.de>

> ---

>  src/cyclictest/cyclictest.c | 2 ++

>  1 file changed, 2 insertions(+)

> 

> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c

> index 0e6519125c2f..b9b0eb3575e3 100644

> --- a/src/cyclictest/cyclictest.c

> +++ b/src/cyclictest/cyclictest.c

> @@ -1024,6 +1024,8 @@ static void process_options(int argc, char *argv[], int max_cpus)

>  				    argv[optind][0] == '0' ||

>  				    argv[optind][0] == '!')) {

>  				parse_cpumask(argv[optind], max_cpus, &affinity_mask);

> +			} else {

> +				num_threads = -1;

>  			}

>  

>  			if (verbose)

> -- 

> 2.29.2

> 

> 

Well, --smp historically combined -a -t and threads at the same priority
You could argue that it is reasonable for -a to automatically imply -t
but I have had debates with people about this and we settled on -a just 
specifies the affinity, and the default number of threads is one unless
you use -t.

I'm not sure what you mean by this makes cyclictest behave the way the 
rest of rt-tests does, the rest of rt-tests should match what cyclitest 
does. That said, I did some quick runs of signaltest and -a seems broken,
sigh.
Daniel Wagner Jan. 26, 2021, 8:37 a.m. UTC | #2
On Tue, Jan 26, 2021 at 12:55:33AM -0500, John Kacur wrote:
> Well, --smp historically combined -a -t and threads at the same priority

> You could argue that it is reasonable for -a to automatically imply -t

> but I have had debates with people about this and we settled on -a just 

> specifies the affinity, and the default number of threads is one unless

> you use -t.


My thinking is if you set an affinity mask, you want also to assign a
thread to the CPUs. If not what's the point to set an affinity mask
without a thread on it. Though the user is able to overwrite this
by providing the -t options along side the -a option.

> I'm not sure what you mean by this makes cyclictest behave the way the 

> rest of rt-tests does, the rest of rt-tests should match what cyclitest 

> does.


As I wrote, make cyclictest behave the same way as the to other tools
when -a/-t is used.

> That said, I did some quick runs of signaltest and -a seems broken,

> sigh.


Is it broken without my patches or with my patches? What is broken?
John Kacur Jan. 26, 2021, 4:32 p.m. UTC | #3
On Tue, 26 Jan 2021, Daniel Wagner wrote:

> On Tue, Jan 26, 2021 at 12:55:33AM -0500, John Kacur wrote:

> > Well, --smp historically combined -a -t and threads at the same priority

> > You could argue that it is reasonable for -a to automatically imply -t

> > but I have had debates with people about this and we settled on -a just 

> > specifies the affinity, and the default number of threads is one unless

> > you use -t.

> 

> My thinking is if you set an affinity mask, you want also to assign a

> thread to the CPUs. If not what's the point to set an affinity mask

> without a thread on it. Though the user is able to overwrite this

> by providing the -t options along side the -a option.


Not necessarily, but you want to limit where the threads, no matter
how few or how many run. As I said, it's not an unreasonable default,
but it is not the current default of 1 unless you specify -t
I suggest we stick with the current default in this clean-up effort.
We can discuss if there are some better defaults after this effort is 
complete.

> 

> > I'm not sure what you mean by this makes cyclictest behave the way the 

> > rest of rt-tests does, the rest of rt-tests should match what cyclitest 

> > does.

> 

> As I wrote, make cyclictest behave the same way as the to other tools

> when -a/-t is used.

> 

> > That said, I did some quick runs of signaltest and -a seems broken,

> > sigh.

> 

> Is it broken without my patches or with my patches? What is broken?

> 

> 

I haven't done a git bisect or something of that sort to determine if your 
patches broke it, but here's what I see. (running on non-rt laptop now, so 
ignore numbers), but it looks like at least the -t option requiring an 
argument existed before your changes, but your changes to affinity 
probably could use some more testing.

The following is okay

./signaltest  -a1-4
2.00 1.52 1.14 2/1079 6541          

T: 0 ( 6537) P: 0 C:  14896 Min:      3 Act:    4 Avg:   26 Max:     366


The following is broken, the default without an argument should be 2
./signaltest  -t
./signaltest: option requires an argument -- 't'

In the following note that threads other than thread 0 didn't appear
on the screen until after the ctrl-c

./signaltest -t9 -a1-4
1.11 1.14 1.14 2/1075 6864          

T: 0 ( 6856) P: 0 C:   1649 Min:     38 Act:  511 Avg:  457 Max:    4911
^CT: 0 ( 6856) P: 0 C:   1660 Min:     38 Act:  554 Avg:  457 Max:    4911
T: 1 ( 6857) P: 0 C:   1660 Min:     38 Act:  490 Avg: 1090 Max:   15024
T: 2 ( 6858) P: 0 C:   1660 Min:     38 Act:  449 Avg: 1091 Max:   15053
T: 3 ( 6859) P: 0 C:   1660 Min:     38 Act:  412 Avg: 1091 Max:   15075
T: 4 ( 6860) P: 0 C:   1660 Min:     38 Act:  378 Avg: 1090 Max:   15081
T: 5 ( 6861) P: 0 C:   1659 Min:     38 Act:  517 Avg: 1091 Max:   15072
T: 6 ( 6862) P: 0 C:   1659 Min:     38 Act:  485 Avg: 1091 Max:   15067
T: 7 ( 6863) P: 0 C:   1659 Min:     38 Act:  522 Avg: 1091 Max:   12832
T: 8 ( 6864) P: 0 C:   1659 Min:     38 Act:  549 Avg: 1091 Max:   12839


etc, it's broken in many ways.
Daniel Wagner Jan. 26, 2021, 5:13 p.m. UTC | #4
On Tue, Jan 26, 2021 at 11:32:25AM -0500, John Kacur wrote:
> Not necessarily, but you want to limit where the threads, no matter

> how few or how many run. As I said, it's not an unreasonable default,

> but it is not the current default of 1 unless you specify -t

> I suggest we stick with the current default in this clean-up effort.

> We can discuss if there are some better defaults after this effort is

> complete.


Understood. BTW, you can do '-a 1 -t' which will spawn N threads on CPU
1. So it's still possible to get the same setup.

> I haven't done a git bisect or something of that sort to determine if your

> patches broke it, but here's what I see. (running on non-rt laptop now, so

> ignore numbers), but it looks like at least the -t option requiring an

> argument existed before your changes, but your changes to affinity

> probably could use some more testing.

>

> The following is okay

>

> ./signaltest  -a1-4

> 2.00 1.52 1.14 2/1079 6541

>

> T: 0 ( 6537) P: 0 C:  14896 Min:      3 Act:    4 Avg:   26 Max:     366

>

>

> The following is broken, the default without an argument should be 2

> ./signaltest  -t

> ./signaltest: option requires an argument -- 't'


Right, this shouldn't be too hard to fix. I'll send an update.

> In the following note that threads other than thread 0 didn't appear

> on the screen until after the ctrl-c

>

> ./signaltest -t9 -a1-4

> 1.11 1.14 1.14 2/1075 6864

>

> T: 0 ( 6856) P: 0 C:   1649 Min:     38 Act:  511 Avg:  457 Max:    4911

> ^CT: 0 ( 6856) P: 0 C:   1660 Min:     38 Act:  554 Avg:  457 Max:    4911

> T: 1 ( 6857) P: 0 C:   1660 Min:     38 Act:  490 Avg: 1090 Max:   15024

> T: 2 ( 6858) P: 0 C:   1660 Min:     38 Act:  449 Avg: 1091 Max:   15053

> T: 3 ( 6859) P: 0 C:   1660 Min:     38 Act:  412 Avg: 1091 Max:   15075

> T: 4 ( 6860) P: 0 C:   1660 Min:     38 Act:  378 Avg: 1090 Max:   15081

> T: 5 ( 6861) P: 0 C:   1659 Min:     38 Act:  517 Avg: 1091 Max:   15072

> T: 6 ( 6862) P: 0 C:   1659 Min:     38 Act:  485 Avg: 1091 Max:   15067

> T: 7 ( 6863) P: 0 C:   1659 Min:     38 Act:  522 Avg: 1091 Max:   12832

> T: 8 ( 6864) P: 0 C:   1659 Min:     38 Act:  549 Avg: 1091 Max:   12839

>

>

> etc, it's broken in many ways.


I don't think I broke this. This is since I can remember the output
behavior. You only see the live update from T0, never the from the
helper threads.
diff mbox series

Patch

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 0e6519125c2f..b9b0eb3575e3 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1024,6 +1024,8 @@  static void process_options(int argc, char *argv[], int max_cpus)
 				    argv[optind][0] == '0' ||
 				    argv[optind][0] == '!')) {
 				parse_cpumask(argv[optind], max_cpus, &affinity_mask);
+			} else {
+				num_threads = -1;
 			}
 
 			if (verbose)