Re: [PATCH rdma-next 4/4] IB/mlx5: Test and increment 'dying' atomically

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

 



On Thu, Jan 24, 2019 at 03:07:12PM +0200, Moni Shoua wrote:
> The purpose in this fix was to prevent a specific bad from happening:
> num_leaf_free from being incremented too many times and causing the
> flow to wait forever in
> 
>         wait_event(imr->q_leaf_free, !atomic_read(&imr->num_leaf_free));
> 
> This could happen because there were 2 flows that looked like
> 
>         if (umem_odp->dying)
>                 return 0;
>                                                    <<< dying could
> change from 0 to 1 here
>         WRITE_ONCE(umem_odp->dying, 1);
>         atomic_inc(&imr->num_leaf_free);
> 
> Replacing the critical section with atomic_add_unless() solves the problem IMO

As I said, this coding pattern should be done with test_and_set not
with atomics. test_and_set are atomic and include the required
barriers to make this work right.

Jason




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux