[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <759948ce-08a8-88bb-c57d-faee2f5bf414@cogentembedded.com>
Date: Fri, 1 Jun 2018 11:58:25 +0300
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: Tonghao Zhang <xiangxia.m.yue@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH] net: core: improve the tx_hash calculating
Hello!
On 5/31/2018 1:14 PM, Tonghao Zhang wrote:
> Use the % instead of while, and it may simple code and improve
> the calculating. The real_num_tx_queues has been checked when
> allocating and setting it.
>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@...il.com>
> ---
> net/core/dev.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 1844d9b..edc5b75 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -2617,15 +2617,13 @@ void netif_device_attach(struct net_device *dev)
> */
> static u16 skb_tx_hash(const struct net_device *dev, struct sk_buff *skb)
> {
> - u32 hash;
> u16 qoffset = 0;
> u16 qcount = dev->real_num_tx_queues;
>
> if (skb_rx_queue_recorded(skb)) {
> - hash = skb_get_rx_queue(skb);
> - while (unlikely(hash >= qcount))
> - hash -= qcount;
> - return hash;
> + /* When setting the real_num_tx_queues, we make sure
> + * real_num_tx_queues != 0. */
In the networking code, multiline comments should look like:
/* bla
* bla
*/
> + return skb_get_rx_queue(skb) % qcount;
> }
>
> if (dev->num_tc) {
MBR, Sergei
Powered by blists - more mailing lists