Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1184188pxk; Fri, 4 Sep 2020 02:59:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwV0g0GwSpb013eoMLvi8b1ghpdOazncmrHicB8ODfz/KlsFVPMQZSBv4ULR4/+k1dHxc9 X-Received: by 2002:a50:b946:: with SMTP id m64mr7818171ede.92.1599213580503; Fri, 04 Sep 2020 02:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599213580; cv=none; d=google.com; s=arc-20160816; b=KP2LOycpwY5XIWU16eY+q8tSyCDXJ9sg1gPqjQAcChYHG4gIhflN9Lsbof2dIaZOZF FUKbVXJVEvofkunATCxREtU4cncOp8+jqk7Irb6x1Hba4YBcJiqQbtmwPUdFNBCJDvUy QBkth8otd0KPTQcWEiHh78PY+bMQhL1rrw0oDK3EARtSV5JcOZGv/7n4zIvmktjSikS4 ybOC5bgP8Z1RJjQUMGXkg937gQ52rZIndo8x8v+GOrkSo70yLNRot/YU+cg7d323KBqn rF+pPlTlq/g8h5yS+FwgpxoleWWi//2HlownJFyNp9SPHIfFzEYeVQ358UZJDgEyYI5P AGbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=TkXZqBDDvyoLod+cspGMD51JZ3C06u5FBSZVBVP3KYQ=; b=MQEEx2MUOeqYmWi8kPCkoByYGo9IsvFdOKTjxPkK4W4/H5iMccvDSXUNTPbPrRY56y Gl7GIENuAgxlEk8ugQT2HByt85UxGT18C/3NIHM3TJ2Svj6IWXkynoyEbr8HIA/X2jED XEg+gBvTRb1ZLTKquubeq0KuAnj243LL5a1NaF3yOtKDN5S+20moCshQ1lZNVjQA33Bl j4rUMcbHuVR8mxI6QVp8bcS5F+QM0y/elm+aiGa5vtUH+VEqdj58pmxUA3iS9gyW4jQc nSF8e8ZeAicUMnyqfD0duN0vltfIG9jrMF9vnJGRHAk52/pD/4U137l9pMMbreWPHwcv LouA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si3741835edv.132.2020.09.04.02.59.18; Fri, 04 Sep 2020 02:59:40 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729808AbgIDJ6R (ORCPT + 99 others); Fri, 4 Sep 2020 05:58:17 -0400 Received: from foss.arm.com ([217.140.110.172]:47472 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgIDJ6R (ORCPT ); Fri, 4 Sep 2020 05:58:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9D168101E; Fri, 4 Sep 2020 02:58:16 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AAC993F66F; Fri, 4 Sep 2020 02:58:15 -0700 (PDT) Subject: Re: [PATCH] iommu/iova: Replace cmpxchg with xchg in queue_iova To: Joerg Roedel , Shaokun Zhang Cc: Yuqi Jin , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <1598517834-30275-1-git-send-email-zhangshaokun@hisilicon.com> <20200904093732.GN6714@8bytes.org> From: Robin Murphy Message-ID: <208d2f74-1a04-f01e-b885-c175b0480784@arm.com> Date: Fri, 4 Sep 2020 10:58:14 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200904093732.GN6714@8bytes.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, On 2020-09-04 10:37, Joerg Roedel wrote: > Adding Robin. Did you miss that I've reviewed this already? :) https://lore.kernel.org/linux-iommu/3afcc7b2-0bfb-b79c-513f-1beb66c5f164@arm.com/ 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 > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu >