RE: [PATCH net-next] r8152: simply the arguments
From: Hayes Wang > Sent: 17 March 2017 03:00 > To: David Laight; netdev@vger.kernel.org > Cc: nic_swsd; linux-ker...@vger.kernel.org; linux-...@vger.kernel.org > Subject: RE: [PATCH net-next] r8152: simply the arguments > > David Laight [mailto:david.lai...@aculab.com] > > Sent: Thursday, March 16, 2017 10:28 PM > [...] > > If you are really lucky the compiler will optimise it away. > > Otherwise it will generate another local variable and possibly > > a register spill to stack. > > However, I could reduce the time for calculating the address, > because I only calculate it once and save the result to a variable. > Right? address you want is just an offset from another pointer that is commonly used and ought to be assigned to a register variable. The offset can be added by the instruction that puts the value into the register used for the first function argument. So 'saving' it in another variable is extra work. David
RE: [PATCH net-next] r8152: simply the arguments
David Laight [mailto:david.lai...@aculab.com] > Sent: Thursday, March 16, 2017 10:28 PM [...] > If you are really lucky the compiler will optimise it away. > Otherwise it will generate another local variable and possibly > a register spill to stack. However, I could reduce the time for calculating the address, because I only calculate it once and save the result to a variable. Right? Best Regards, Hayes
RE: [PATCH net-next] r8152: simply the arguments
From: Hayes Wang > Sent: 16 March 2017 06:28 > Replace >napi with napi and tp->netdev with netdev. > > Signed-off-by: Hayes Wang> --- > drivers/net/usb/r8152.c | 44 +++- > 1 file changed, 27 insertions(+), 17 deletions(-) > > diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c > index 227e1fd..e480e9f 100644 > --- a/drivers/net/usb/r8152.c > +++ b/drivers/net/usb/r8152.c > @@ -1761,6 +1761,7 @@ static int rx_bottom(struct r8152 *tp, int budget) > unsigned long flags; > struct list_head *cursor, *next, rx_queue; > int ret = 0, work_done = 0; > + struct napi_struct *napi = >napi; > > if (!skb_queue_empty(>rx_queue)) { > while (work_done < budget) { > @@ -1773,7 +1774,7 @@ static int rx_bottom(struct r8152 *tp, int budget) > break; > > pkt_len = skb->len; > - napi_gro_receive(>napi, skb); > + napi_gro_receive(napi, skb); ... I'm not sure this makes the code any more readable. It isn't even needed to shorten any long lines. If you are really lucky the compiler will optimise it away. Otherwise it will generate another local variable and possibly a register spill to stack. David