From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH net-next 1/2] net: tap: replay while() loop with % operator in tap_get_queue() Date: Mon, 11 Dec 2017 08:58:11 -0800 Message-ID: <20171211085811.00c3cbaf@xeon-e3> References: <1512998801-17852-1-git-send-email-cugyly@163.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, "David S . Miller" , yuan linyu To: yuan linyu Return-path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:45843 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752041AbdLKQ6P (ORCPT ); Mon, 11 Dec 2017 11:58:15 -0500 Received: by mail-pf0-f196.google.com with SMTP id u19so11964115pfa.12 for ; Mon, 11 Dec 2017 08:58:15 -0800 (PST) In-Reply-To: <1512998801-17852-1-git-send-email-cugyly@163.com> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 11 Dec 2017 21:26:41 +0800 yuan linyu wrote: > From: yuan linyu > > Signed-off-by: yuan linyu > --- > drivers/net/tap.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/drivers/net/tap.c b/drivers/net/tap.c > index 0a886fda..78900a0 100644 > --- a/drivers/net/tap.c > +++ b/drivers/net/tap.c > @@ -275,11 +275,7 @@ static struct tap_queue *tap_get_queue(struct tap_dev *tap, > > if (likely(skb_rx_queue_recorded(skb))) { > rxq = skb_get_rx_queue(skb); > - > - while (unlikely(rxq >= numvtaps)) > - rxq -= numvtaps; > - > - queue = rcu_dereference(tap->taps[rxq]); > + queue = rcu_dereference(tap->taps[rxq % numvtaps]); > goto out; > } > Modulus is slower than the loop.