Bug 2050244

Summary: cyclictest: Ignore inherited affinity when applying new affinity
Product: Red Hat Enterprise Linux 9 Reporter: John Kacur <jkacur>
Component: realtime-testsAssignee: John Kacur <jkacur>
Status: CLOSED ERRATA QA Contact: Mike Stowell <mstowell>
Severity: unspecified Docs Contact:
Priority: high    
Version: 9.0CC: bhu, mstowell
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: realtime-tests-2.3-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 13:22:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1983783    
Deadline: 2022-02-14   

Description John Kacur 2022-02-03 14:24:55 UTC
This bug was initially created as a copy of Bug #2050242

Description of problem:

If a new affinity is requested we currently calculate a cpumask that is the intersection of the set of the newly requested affinity and the runtime or inherited cpumask.

While this makes sense in some circumstances, such as if the requester wants to add '+' or take away '!' from the current set.

This doesn't make sense if a new affinity is requested and is too restrictive. It can result in no cpus being available for example when isolcpus has been applied.

Comment 2 John Kacur 2022-02-03 15:28:51 UTC
How to Test:

You can use taskset to set the runtime environment that cyclictest will inherit, and then use the -a flag to alter it in cyclictest.
For example
Before this change
taskset --cpu-list 0-4,8 ./cyclictest -t -a 0,3-6
# /dev/cpu_dma_latency set to 0us
policy: other/other: loadavg: 2.26 2.23 2.52 4/2349 16998           

T: 0 (16262) P: 0 I:1000 C: 550911 Min:      3 Act:   52 Avg:   61 Max:   26423
T: 1 (16263) P: 0 I:1500 C: 362514 Min:      3 Act:   52 Avg:   83 Max:   27363
T: 2 (16264) P: 0 I:2000 C: 273451 Min:      3 Act:   52 Avg:   82 Max:   28608

The runtime environment consists of cpus 0,1,2,3,4,8
the requested affinity includes cpus 0,3,4,5,6
The Intersection of those cpus is 0,3,4 - so therefore we get just 3 threads as you can see above.
You can also use taskset -p pid, to examine the cpumasks but this is a bit complicated for the purpose here and not necessary.

After the change we get
taskset --cpu-list 0-4,8 ./cyclictest -t -a 0,3-6
# /dev/cpu_dma_latency set to 0us
policy: other/other: loadavg: 2.48 2.30 2.54 1/2351 17291           

T: 0 (17286) P: 0 I:1000 C:   3985 Min:      4 Act:   52 Avg:   58 Max:    1818
T: 1 (17287) P: 0 I:1500 C:   2643 Min:      5 Act:   52 Avg:   68 Max:   13469
T: 2 (17288) P: 0 I:2000 C:   1991 Min:      6 Act:   53 Avg:   59 Max:    3206
T: 3 (17289) P: 0 I:2500 C:   1592 Min:      7 Act:   53 Avg:   56 Max:    2521
T: 4 (17290) P: 0 I:3000 C:   1329 Min:      6 Act:   53 Avg:   69 Max:    2766

So the requested affinity includes cpus 0,3,4,5,6 or 5 threads which is what we see above.

Comment 9 errata-xmlrpc 2022-05-17 13:22:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: realtime-tests), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2498