lkml.org 
[lkml]   [2018]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH net-next 05/10] net: hns3: using modulo for cyclic counters in hclge_cmd_send
From
From: Peng Li <lipeng321@huawei.com>
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.

\
 
 \ /
  Last update: 2018-06-30 14:04    [W:0.095 / U:2.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site