Thread (13 messages) flat view 13 messages, 2 authors, 2018-07-02

Re: [PATCH net-next 05/10] net: hns3: using modulo for cyclic counters in hclge_cmd_send

From: lipeng (Y) <hidden>
Date: 2018-07-02 07:07:05
Also in: lkml


On 2018/6/30 20:03, David Miller wrote:
From: Peng Li <redacted>
Date: Fri, 29 Jun 2018 19:23:00 +0800
quoted
@@ -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.

.
Agree with you.

Thanks for your review, we  concentrate on  the code style and ignore the
performance in this patch, It is not good.

I will remove this patch from the patchset.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help