Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1174815pxk; Fri, 4 Sep 2020 02:38:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxX8v4X47wWbYpi0kZXlxGWNd9KkekvETJwlAEN+nRLqHkjC/986xbau1gxYa3LRfkxG1PC X-Received: by 2002:a17:906:d6a:: with SMTP id s10mr1167645ejh.413.1599212333841; Fri, 04 Sep 2020 02:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599212333; cv=none; d=google.com; s=arc-20160816; b=Ne6UN3q2jVJk2SsnpEgbjW5QHbVRdxFNqDL7HSYIOhFoLTJAv1bjFJIx8/SR4NMnsl 2olmL8CrJZJbSMHTExNKmYbltVB+LUgsGmd6iIwiVSOBp2O5dEJURFQh9Fv+GelupySf 3dPnS5fJ4gIlh5luwn0MDVlXrmYai3zo6YhQwhWZhU/+5jVxtpKHKa8Bnra3NEzxBfXQ 7yFki3w233E6MNaxr9aiJ35s8F+MBglehQ3E9WltZmNJfHy5Lh77+Gjl0dHoKsNG1Ly7 I2zOEt454xYG1hdnRA60biY5k8kZB6UT7ZeYKFzgXKyXKZ4wWt+K3IWznfYQ4M4Wy465 CUvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=VZwU+Wgeu3ZhJMiqAOFaPfSJu8T/wsEKOCUvegkG114=; b=VVLqOYWwDcxdrFzGMF2diNZTgxcaeMITh5bdN1MY3agrDeSZjOdqjb5sHZ9GiyicLr V1nTmIdk3igPpsMH/xkxd+9/HF3WaTwkOYSUQ1l1Y8i8XoJ56z8VU1fen2ltUK1ePKcu DUAT80/ZLGgussYytTb7A87n4eGN4JjMiNwPBIh2R46a2K2/7gzuSAj7lq2UMucz7+2u c5MvHHx0QPV8RI67hoZEMHctGmdCA0dXE3YXYGEEePyMqi2g+wv6JhI4cZKb0UUqOPzA eB0gcDNpMXzHfoWxAXQtJHtGEelyiaBWnpf6ZQ6TzrMwDhQNg4ADXNKtzrrd4Kj0lRbX Zqhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si3817650ejn.24.2020.09.04.02.38.30; Fri, 04 Sep 2020 02:38:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729741AbgIDJhk (ORCPT + 99 others); Fri, 4 Sep 2020 05:37:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbgIDJhj (ORCPT ); Fri, 4 Sep 2020 05:37:39 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA4B7C061244 for ; Fri, 4 Sep 2020 02:37:34 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 92BC3A6D; Fri, 4 Sep 2020 11:37:33 +0200 (CEST) Date: Fri, 4 Sep 2020 11:37:32 +0200 From: Joerg Roedel To: Shaokun Zhang Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Yuqi Jin , Robin Murphy Subject: Re: [PATCH] iommu/iova: Replace cmpxchg with xchg in queue_iova Message-ID: <20200904093732.GN6714@8bytes.org> References: <1598517834-30275-1-git-send-email-zhangshaokun@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1598517834-30275-1-git-send-email-zhangshaokun@hisilicon.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding Robin. On Thu, Aug 27, 2020 at 04:43:54PM +0800, Shaokun Zhang wrote: > From: Yuqi Jin > > The performance of the atomic_xchg is better than atomic_cmpxchg because > no comparison is required. While the value of @fq_timer_on can only be 0 > or 1. Let's use atomic_xchg instead of atomic_cmpxchg here because we > only need to check that the value changes from 0 to 1 or from 1 to 1. > > Cc: Joerg Roedel > Signed-off-by: Yuqi Jin > Signed-off-by: Shaokun Zhang > --- > drivers/iommu/iova.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c > index 45a251da5453..30d969a4c5fd 100644 > --- a/drivers/iommu/iova.c > +++ b/drivers/iommu/iova.c > @@ -579,7 +579,7 @@ void queue_iova(struct iova_domain *iovad, > > /* Avoid false sharing as much as possible. */ > if (!atomic_read(&iovad->fq_timer_on) && > - !atomic_cmpxchg(&iovad->fq_timer_on, 0, 1)) > + !atomic_xchg(&iovad->fq_timer_on, 1)) > mod_timer(&iovad->fq_timer, > jiffies + msecs_to_jiffies(IOVA_FQ_TIMEOUT)); > } > -- > 2.7.4