Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp275066pxa; Thu, 27 Aug 2020 01:47:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwghKfL3RVJbtUWj8iOH/WlloDu10seXgOXkUE46EkURER0id0q63zQPtb34hUDfuh8Bd1W X-Received: by 2002:a17:906:4ac6:: with SMTP id u6mr16016508ejt.539.1598518040828; Thu, 27 Aug 2020 01:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598518040; cv=none; d=google.com; s=arc-20160816; b=Q1uUZoFWnCiFBuv2w6RuHJWhK3UEsG3BbUnM/SyL4Fm4xueM71ByZ6xq08LY2NvO+E zZFeaEcPoGJeAQ8sAzNubh3oS98cTas5iIic5qK/7Xjo5k6kvBMcWpCDfE4hwAwAvRa/ 8OVRrwf58rZdCHUgsHw8bvydeZyr2JBXwaExe87HfVu2sX0smBtDGR6fXD5cssm8XXCO uA7M6qKpGmjhe8tH+DQHLIYeDXvZc/4w7hSO1uWovXi+PU49pUjbrCZo0b2S6sXbh8Vo MOQvWWez81kQ9r6Z0avdTzNjT3WTlVrOW9RLeTkZ2JnSCx9VXuknFBw7jJVx3G7tRp2l 0IhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=82uz5NdUcrGXlWoU3PK8VSO4lrrSWKRlGH34K8downU=; b=JnC0YASiLDjDZ6wfV8D7upxbUDU7TwZhG/btqv6fzbB4patR1QKp7QpiKpurlbkjOZ DDIaItKlL7zvZ7w4ZBa35918WmTOjgz1k/2ebGUVeQ0NM1KXwxXYb6jb5/mEErAtKKSU nX2bBdKrEmy9hRbaZrT/VrSqlhe034fpOQv0s26pPX/7P1tU/gKVgtu6VkwjDfhvi2Lj 9SmqVA1jVkIOYHajSzMgsyDzYCPAWfwu9sCj0FfNYM/khbx+jQnVPoppF30ydggsT3E5 fpJbj0+2Js1wIs3j3wfcw/d5Uc23bvAhzp9v/OfQouP3o5+bws91EGhqVAHhmGL+K/HH hanQ== 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 bq25si910389ejb.730.2020.08.27.01.46.56; Thu, 27 Aug 2020 01:47:20 -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 S1727786AbgH0IqU (ORCPT + 99 others); Thu, 27 Aug 2020 04:46:20 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10270 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726988AbgH0IqU (ORCPT ); Thu, 27 Aug 2020 04:46:20 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 28EC4C060D18D32208B2; Thu, 27 Aug 2020 16:46:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Thu, 27 Aug 2020 16:46:12 +0800 From: Shaokun Zhang To: , CC: Yuqi Jin , Joerg Roedel , "Shaokun Zhang" Subject: [PATCH] iommu/iova: Replace cmpxchg with xchg in queue_iova Date: Thu, 27 Aug 2020 16:43:54 +0800 Message-ID: <1598517834-30275-1-git-send-email-zhangshaokun@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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