Commit 5e517ef
throtl: fix the race between submitting IO and setting cgroup.procs
The throttle test cases uses _throtl_issue_io function to submit IO
to the device. This function typically runs in the background process
however before this function starts execution and submit IO, we need
to set the PID of the background process into cgroup.procs. The current
implementation adds sleep 0.1 before _throtl_issue_io and it's assumed
that during this sleep time of 0.1 second, we shall be able to write the
PID of the background process to cgroup.procs. However this may not be
always true as background process might starts running after sleep of 0.1
seconds (and hence start submitting IO) before we could actually write
the PID of background process into cgroup.procs from the parent shell.
This commit helps fix the above race condition by writing pid of the
background/child process using $BASHPID into cgroup.procs. The $BASHPID
returns the pid of the current bash process. So we leverage $BASHPID to
first write the pid of the background/child job/process into cgroup.procs
from within the child sub-shell and then start submitting IO. This way we
eliminate the need of any communication between parent shell and the
background/child shell process and that helps avoid the race.
Signed-off-by: Nilay Shroff <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>1 parent 65ea613 commit 5e517ef
3 files changed
+6
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | 28 | | |
32 | 29 | | |
33 | | - | |
| 30 | + | |
34 | 31 | | |
35 | 32 | | |
36 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 27 | | |
31 | 28 | | |
32 | | - | |
| 29 | + | |
33 | 30 | | |
34 | 31 | | |
35 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
| 106 | + | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
111 | | - | |
112 | | - | |
113 | | - | |
| 110 | + | |
114 | 111 | | |
0 commit comments