From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78178C43461 for ; Fri, 4 Sep 2020 09:37:38 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43DBC205CB for ; Fri, 4 Sep 2020 09:37:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43DBC205CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 2B12686A51; Fri, 4 Sep 2020 09:37:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vUozl-wB2BM2; Fri, 4 Sep 2020 09:37:37 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7D73686A14; Fri, 4 Sep 2020 09:37:37 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6F997C0052; Fri, 4 Sep 2020 09:37:37 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 265A0C0051 for ; Fri, 4 Sep 2020 09:37:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 099BA86D99 for ; Fri, 4 Sep 2020 09:37:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J-h408M7CVgK for ; Fri, 4 Sep 2020 09:37:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by whitealder.osuosl.org (Postfix) with ESMTPS id 59A2186D70 for ; Fri, 4 Sep 2020 09:37:35 +0000 (UTC) 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 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-Disposition: inline In-Reply-To: <1598517834-30275-1-git-send-email-zhangshaokun@hisilicon.com> User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Yuqi Jin , iommu@lists.linux-foundation.org, Robin Murphy , linux-kernel@vger.kernel.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56314C433E2 for ; Fri, 4 Sep 2020 09:37:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28D2F20791 for ; Fri, 4 Sep 2020 09:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729871AbgIDJhk (ORCPT ); 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