[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 6 Jul 2011 18:53:57 -0700
From: Yong Wang <yongwang@...are.com>
To: Dmitry Torokhov <dtor@...are.com>,
"pv-drivers@...are.com" <pv-drivers@...are.com>
CC: Shreyas Bhatewara <sbhatewara@...are.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [Pv-drivers] [PATCH] vmxnet3: round down # of queues to power
of two
I just want to point out that rounddown_pow_of_two() returns 0 when (1) the input is 1; and (2) the __buildin_constant_p(n) path is taken. In the vmxnet3 case, even if num_rx_queues is 1, we are safe as its value is not known to be constant at compile time and 1 will be returned by taking the other path (1UL << (fls_long(n) - 1)). The original check of power_of_two is there just to be on the safe side.
Related to this, I wonder if we should always return 1 when the input is 1 (1 is also a power of two as 2^0). I don't have the history of this API though and curious if there are any users of this API that depend on this behavior?
Thanks,
Yong
> -----Original Message-----
> From: Dmitry Torokhov [mailto:dtor@...are.com]
> Sent: Wednesday, July 06, 2011 6:09 PM
> To: pv-drivers@...are.com
> Cc: Shreyas Bhatewara; netdev@...r.kernel.org; Yong Wang
> Subject: Re: [Pv-drivers] [PATCH] vmxnet3: round down # of queues to power of
> two
>
> On Wednesday, July 06, 2011 05:58:51 PM Shreyas Bhatewara wrote:
>
> >
> > + if (!is_power_of_2(num_rx_queues))
> > + num_rx_queues = rounddown_pow_of_two(num_rx_queues);
> > +
>
> No need to do the check, just do:
>
> num_rx_queues = rounddown_pow_of_two(num_rx_queues);
>
> Thanks,
> Dmitry
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists