Re: [PATCH blktests 2/2] throtl: fix the race between submitting IO and setting cgroup.procs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 12/18/24 07:54, Yu Kuai wrote:
> Hi,
> 
> 在 2024/12/17 21:14, Nilay Shroff 写道:
>> This commit helps fix the above race condition by touching a temp file. The
>> the existence of the temp file is then polled by the background process at
>> regular interval. Until the temp file is created, the background process
>> would not forward progress and starts submitting IO and from the main
>> thread we'd touch temp file only after we write PID of the background
>> process into cgroup.procs.
> 
> It's right sleep 0.1 is not appropriate here, and this can work.
> However, I think reading cgroup.procs directly is better, something
> like following:
> 
>  _throtl_test_io() {
> -       local pid
> +       local pid="none"
> 
>         {
>                 local rw=$1
>                 local bs=$2
>                 local count=$3
> 
> -               sleep 0.1
> +               while ! cat $CGROUP2_DIR/$THROTL_DIR/cgroup.procs | grep $pid; do
> +                       sleep 0.1
>                 _throtl_issue_io "$rw" "$bs" "$count"
>         } &

Thank you for your review and suggestion!

However, IMO this may not work always because the issue here's that the @pid is local 
variable and when the shell starts the background job/process, typically, all local 
variables are copied to the new job. Henceforth, any update made to @pid in the parent 
shell would not be visible to the background job. 
I think, for IPC between parent shell and background job, we may use temp file,
named pipe or signals. As file is the easiest and simplest mechanism, for this 
simple test I preferred using file. 

Thanks,
--Nilay




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux