From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net-next 05/10] net: hns3: using modulo for cyclic counters in hclge_cmd_send Date: Sat, 30 Jun 2018 21:03:42 +0900 (KST) Message-ID: <20180630.210342.804224843120744818.davem@davemloft.net> References: <1530271385-49668-1-git-send-email-lipeng321@huawei.com> <1530271385-49668-6-git-send-email-lipeng321@huawei.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, yisen.zhuang@huawei.com, salil.mehta@huawei.com To: lipeng321@huawei.com Return-path: 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 In-Reply-To: <1530271385-49668-6-git-send-email-lipeng321@huawei.com> Sender: netdev-owner@vger.kernel.org List-ID: 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.