lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190830104925.GI17192@suse.de>
Date:   Fri, 30 Aug 2019 12:49:25 +0200
From:   Joerg Roedel <jroedel@...e.de>
To:     Eric Dumazet <edumazet@...gle.com>,
        Robin Murphy <robin.murphy@....com>
Cc:     linux-kernel <linux-kernel@...r.kernel.org>,
        iommu@...ts.linux-foundation.org,
        Eric Dumazet <eric.dumazet@...il.com>,
        Jinyu Qi <jinyuqi@...wei.com>
Subject: Re: [PATCH] iommu/iova: avoid false sharing on fq_timer_on

Looks good to me, but adding Robin for his opinion.

On Wed, Aug 28, 2019 at 06:13:38AM -0700, Eric Dumazet wrote:
> In commit 14bd9a607f90 ("iommu/iova: Separate atomic variables
> to improve performance") Jinyu Qi identified that the atomic_cmpxchg()
> in queue_iova() was causing a performance loss and moved critical fields
> so that the false sharing would not impact them.
> 
> However, avoiding the false sharing in the first place seems easy.
> We should attempt the atomic_cmpxchg() no more than 100 times
> per second. Adding an atomic_read() will keep the cache
> line mostly shared.
> 
> This false sharing came with commit 9a005a800ae8
> ("iommu/iova: Add flush timer").
> 
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Cc: Jinyu Qi <jinyuqi@...wei.com>
> Cc: Joerg Roedel <jroedel@...e.de>
> ---
>  drivers/iommu/iova.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> index 3e1a8a6755723a927a7942a7429ab7e6c19a0027..41c605b0058f9615c2dbdd83f1de2404a9b1d255 100644
> --- a/drivers/iommu/iova.c
> +++ b/drivers/iommu/iova.c
> @@ -577,7 +577,9 @@ void queue_iova(struct iova_domain *iovad,
>  
>  	spin_unlock_irqrestore(&fq->lock, flags);
>  
> -	if (atomic_cmpxchg(&iovad->fq_timer_on, 0, 1) == 0)
> +	/* Avoid false sharing as much as possible. */
> +	if (!atomic_read(&iovad->fq_timer_on) &&
> +	    !atomic_cmpxchg(&iovad->fq_timer_on, 0, 1))
>  		mod_timer(&iovad->fq_timer,
>  			  jiffies + msecs_to_jiffies(IOVA_FQ_TIMEOUT));
>  }
> -- 
> 2.23.0.187.g17f5b7556c-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ