Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1825815imm; Sat, 30 Jun 2018 05:11:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIdceoIiwbxvrtrUjZ5gEKsr/MIgtqWi6LgMr7MXYC25l4oblEFL/UrhaEjE7LfeVR0tDjL X-Received: by 2002:a17:902:b590:: with SMTP id a16-v6mr19107819pls.225.1530360718736; Sat, 30 Jun 2018 05:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530360718; cv=none; d=google.com; s=arc-20160816; b=fOi9k5ksiEaXK0WEv7lmlsC+q3lONuMM9Bb8kqp+I/rOGog1h1ioLG2TR9AoR0T/TF O/Cl35YSi5Xi90MnRh3Ca076h1HGzdSKnTJBfk+lm1TljNyuVUxq0DlViIZingYu9QVt +26gLBxCp0EYEL+iKJRR2RS6YNTn1qMkvYbPisJPSfuGWrrT7R4XOYNWGaESHYIYZCQC B1Ah6AevbTTZ4oY/orjYN9irsE/wqqAUBrdGsazZzUp4S9oU0u6cMf3SRlO29zG3+X+i KpX9JFjGOGd6BtXzFp6uw3guwNwSXCvSv4otvQfRlH88h6rBJ9HQAiNUJp998E+zAGgS ETZQ== 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:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date :arc-authentication-results; bh=FVcVZyl8cRE3VfokQzKstZxwIZ0e6TMnK9aqWGx2Qrc=; b=0QVqMucLEdoVVxDDs7tkHmf2JR0oFWMP66rrIzkmnzUDFQ1/VoLyirlbdOm44ouH4Y Flg9gZGOj0mQyegPVdH8AiiT5u1jn5zOGEf/xslQg3KRqR7QCo7nGzxU1XvulrFlIcp9 GvxbTjQ6axiAwNZi3TvBR7R40+Avl6aMrnhEqfejLDp9o9pas1cR0Vi0UkQP6gzrWTaE VZFf8JWbVrTfOEYSy/cmqH1g4maRaOZE8TGyhZ/FIdZFW5phsv88J5AcESWnjziXk8dr C5WzQHekpc6plkrSBCDRvWZGZ398mJWuELw+Y58WRJLeCkI1spOE/74r8WzHTogYhob9 eNgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si7549675pli.358.2018.06.30.05.11.44; Sat, 30 Jun 2018 05:11:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936937AbeF3MDr (ORCPT + 99 others); Sat, 30 Jun 2018 08:03:47 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:37980 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936201AbeF3MDq (ORCPT ); Sat, 30 Jun 2018 08:03:46 -0400 Received: from localhost (unknown [183.108.164.149]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 945A0144C612D; Sat, 30 Jun 2018 05:03:44 -0700 (PDT) Date: Sat, 30 Jun 2018 21:03:42 +0900 (KST) Message-Id: <20180630.210342.804224843120744818.davem@davemloft.net> To: lipeng321@huawei.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, yisen.zhuang@huawei.com, salil.mehta@huawei.com Subject: Re: [PATCH net-next 05/10] net: hns3: using modulo for cyclic counters in hclge_cmd_send From: David Miller In-Reply-To: <1530271385-49668-6-git-send-email-lipeng321@huawei.com> References: <1530271385-49668-1-git-send-email-lipeng321@huawei.com> <1530271385-49668-6-git-send-email-lipeng321@huawei.com> X-Mailer: Mew version 6.7 on Emacs 26 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sat, 30 Jun 2018 05:03:46 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Li Date: Fri, 29 Jun 2018 19:23:00 +0800 > @@ -228,8 +228,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) > desc_to_use = &hw->cmq.csq.desc[hw->cmq.csq.next_to_use]; > *desc_to_use = desc[handle]; > (hw->cmq.csq.next_to_use)++; > - if (hw->cmq.csq.next_to_use == hw->cmq.csq.desc_num) > - hw->cmq.csq.next_to_use = 0; > + hw->cmq.csq.next_to_use %= hw->cmq.csq.desc_num; > handle++; I would advise against this. The "%" modulus operation takes many cpu cycles, and the current code is thus much faster.