netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/11] skb_put_zero() used to optimize code
@ 2017-06-14 14:30 yuan linyu
  2017-06-14 14:42 ` Johannes Berg
  0 siblings, 1 reply; 10+ messages in thread
From: yuan linyu @ 2017-06-14 14:30 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>


yuan linyu (11):
  ipv6: skb_put_zero() used to optimize code
  ipv4: skb_put_zero() used to optimize code
  ncsi: skb_put_zero() used to optimize code
  dsa: skb_put_zero() used to optimize code
  key: skb_put_zero() used to optimize code
  openvswitch: skb_put_zero() used to optimize code
  batman-adv: skb_put_zero() used to optimize code
  bridge: skb_put_zero() used to optimize code
  sctp: skb_put_zero() used to optimize code
  atm: skb_put_zero() used to optimize code
  qrtr: skb_put_zero() used to optimize code

 net/atm/signaling.c                      |  3 +--
 net/batman-adv/bat_v_elp.c               |  3 +--
 net/bridge/netfilter/nft_reject_bridge.c |  6 ++----
 net/dsa/tag_trailer.c                    |  3 +--
 net/ipv4/ipconfig.c                      |  3 +--
 net/ipv4/netfilter/nf_reject_ipv4.c      |  3 +--
 net/ipv6/mcast.c                         |  3 +--
 net/ipv6/ndisc.c                         | 13 ++----------
 net/key/af_key.c                         | 12 ++++-------
 net/ncsi/ncsi-cmd.c                      | 36 +++++++++++---------------------
 net/openvswitch/datapath.c               |  2 +-
 net/qrtr/qrtr.c                          |  9 +++-----
 net/sctp/output.c                        |  2 +-
 13 files changed, 31 insertions(+), 67 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 14:30 [PATCH net-next 00/11] skb_put_zero() used to optimize code yuan linyu
@ 2017-06-14 14:42 ` Johannes Berg
  2017-06-14 15:00   ` yuan linyu
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2017-06-14 14:42 UTC (permalink / raw)
  To: yuan linyu, netdev; +Cc: David S . Miller, yuan linyu

On Wed, 2017-06-14 at 22:30 +0800, yuan linyu wrote:
> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
> 
> 
> yuan linyu (11):
>   ipv6: skb_put_zero() used to optimize code
>   ipv4: skb_put_zero() used to optimize code
>   ncsi: skb_put_zero() used to optimize code
>   dsa: skb_put_zero() used to optimize code
>   key: skb_put_zero() used to optimize code
>   openvswitch: skb_put_zero() used to optimize code
>   batman-adv: skb_put_zero() used to optimize code
>   bridge: skb_put_zero() used to optimize code
>   sctp: skb_put_zero() used to optimize code
>   atm: skb_put_zero() used to optimize code
>   qrtr: skb_put_zero() used to optimize code

Hmm. I guess my spatch missed these because of the casts present in
them.

Surely you didn't do them by hand, so maybe you should provide a single
big patch with the spatch?

johannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 14:42 ` Johannes Berg
@ 2017-06-14 15:00   ` yuan linyu
  2017-06-14 16:29     ` Johannes Berg
  0 siblings, 1 reply; 10+ messages in thread
From: yuan linyu @ 2017-06-14 15:00 UTC (permalink / raw)
  To: Johannes Berg, netdev; +Cc: David S . Miller, yuan linyu

On 三, 2017-06-14 at 16:42 +0200, Johannes Berg wrote:
> On Wed, 2017-06-14 at 22:30 +0800, yuan linyu wrote:
> > 
> > From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
> > 
> > 
> > yuan linyu (11):
> >   ipv6: skb_put_zero() used to optimize code
> >   ipv4: skb_put_zero() used to optimize code
> >   ncsi: skb_put_zero() used to optimize code
> >   dsa: skb_put_zero() used to optimize code
> >   key: skb_put_zero() used to optimize code
> >   openvswitch: skb_put_zero() used to optimize code
> >   batman-adv: skb_put_zero() used to optimize code
> >   bridge: skb_put_zero() used to optimize code
> >   sctp: skb_put_zero() used to optimize code
> >   atm: skb_put_zero() used to optimize code
> >   qrtr: skb_put_zero() used to optimize code
> Hmm. I guess my spatch missed these because of the casts present in
> them.
> 
> Surely you didn't do them by hand, so maybe you should provide a single
> big patch with the spatch?
sorry, I do them by hand. 
last time when i try to change ndisc.c, david adhern suggest to use skb_put_zero().
> 
> johannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 15:00   ` yuan linyu
@ 2017-06-14 16:29     ` Johannes Berg
  2017-06-14 16:31       ` Johannes Berg
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2017-06-14 16:29 UTC (permalink / raw)
  To: cugyly, netdev; +Cc: David S . Miller, yuan linyu

On Wed, 2017-06-14 at 23:00 +0800, yuan linyu wrote:

> sorry, I do them by hand. 

oh, ok.

This seems to work:

@@
identifier p;
expression len;
expression skb;
type t;
@@
-p = (t)skb_put(skb, len);
-memset(p, 0, len);
+p = (t)skb_put_zero(skb, len);

johannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 16:29     ` Johannes Berg
@ 2017-06-14 16:31       ` Johannes Berg
  2017-06-14 19:38         ` David Miller
  2017-06-14 23:45         ` YUAN Linyu
  0 siblings, 2 replies; 10+ messages in thread
From: Johannes Berg @ 2017-06-14 16:31 UTC (permalink / raw)
  To: cugyly, netdev; +Cc: David S . Miller, yuan linyu

On Wed, 2017-06-14 at 18:29 +0200, Johannes Berg wrote:
> On Wed, 2017-06-14 at 23:00 +0800, yuan linyu wrote:
> 
> > sorry, I do them by hand. 
> 
> oh, ok.
> 
> This seems to work:
> 
> @@
> identifier p;
> expression len;
> expression skb;
> type t;
> @@
> -p = (t)skb_put(skb, len);
> -memset(p, 0, len);
> +p = (t)skb_put_zero(skb, len);

Nope, still didn't find everything - not the batman and atm cases for
example. But still a few more, I think that you didn't find, e.g. in
mac80211.

Anyway - I think none of this is really critical.

johannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 16:31       ` Johannes Berg
@ 2017-06-14 19:38         ` David Miller
  2017-06-14 20:11           ` Johannes Berg
  2017-06-14 23:45         ` YUAN Linyu
  1 sibling, 1 reply; 10+ messages in thread
From: David Miller @ 2017-06-14 19:38 UTC (permalink / raw)
  To: johannes; +Cc: cugyly, netdev, Linyu.Yuan

From: Johannes Berg <johannes@sipsolutions.net>
Date: Wed, 14 Jun 2017 18:31:48 +0200

> On Wed, 2017-06-14 at 18:29 +0200, Johannes Berg wrote:
>> On Wed, 2017-06-14 at 23:00 +0800, yuan linyu wrote:
>> 
>> > sorry, I do them by hand. 
>> 
>> oh, ok.
>> 
>> This seems to work:
>> 
>> @@
>> identifier p;
>> expression len;
>> expression skb;
>> type t;
>> @@
>> -p = (t)skb_put(skb, len);
>> -memset(p, 0, len);
>> +p = (t)skb_put_zero(skb, len);
> 
> Nope, still didn't find everything - not the batman and atm cases for
> example. But still a few more, I think that you didn't find, e.g. in
> mac80211.
> 
> Anyway - I think none of this is really critical.

What do you think about Stephen Hemminger's feedback to make skb_put_zero()
return "void *".  It will avoid a lot of casts and make the conversions
look nicer.

I'll also defer on this patch series until we have the spatch thing
which can catch all of them.

Thanks.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 19:38         ` David Miller
@ 2017-06-14 20:11           ` Johannes Berg
  2017-06-14 20:15             ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2017-06-14 20:11 UTC (permalink / raw)
  To: David Miller; +Cc: cugyly, netdev, Linyu.Yuan

On Wed, 2017-06-14 at 15:38 -0400, David Miller wrote:

> What do you think about Stephen Hemminger's feedback to make
> skb_put_zero() return "void *".  It will avoid a lot of casts and
> make the conversions look nicer.

I think it's a good idea. I can send a patch, and remove some casts
where they exist - I guess we could also do it even for skb_put()
eventually.

> I'll also defer on this patch series until we have the spatch thing
> which can catch all of them.

I think I have something that covers most cases, will send out an RFC
in a minute (since I'm not sure I was able to build it all yet).

Note that some of the cases like in ipv6/ndisc.c certainly can't be
done automatically, they look correct but are more complicated because
there's not just a single big memset(), but they're doing it piece by
piece (fill some bytes, clear some others, etc.) Might be worth
checking which aren't covered by the spatch.

johannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 20:11           ` Johannes Berg
@ 2017-06-14 20:15             ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2017-06-14 20:15 UTC (permalink / raw)
  To: johannes; +Cc: cugyly, netdev, Linyu.Yuan

From: Johannes Berg <johannes@sipsolutions.net>
Date: Wed, 14 Jun 2017 22:11:54 +0200

> On Wed, 2017-06-14 at 15:38 -0400, David Miller wrote:
> 
>> What do you think about Stephen Hemminger's feedback to make
>> skb_put_zero() return "void *".  It will avoid a lot of casts and
>> make the conversions look nicer.
> 
> I think it's a good idea. I can send a patch, and remove some casts
> where they exist - I guess we could also do it even for skb_put()
> eventually.
> 
>> I'll also defer on this patch series until we have the spatch thing
>> which can catch all of them.
> 
> I think I have something that covers most cases, will send out an RFC
> in a minute (since I'm not sure I was able to build it all yet).

All sounds great.

> Note that some of the cases like in ipv6/ndisc.c certainly can't be
> done automatically, they look correct but are more complicated because
> there's not just a single big memset(), but they're doing it piece by
> piece (fill some bytes, clear some others, etc.) Might be worth
> checking which aren't covered by the spatch.

Understood.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 16:31       ` Johannes Berg
  2017-06-14 19:38         ` David Miller
@ 2017-06-14 23:45         ` YUAN Linyu
  2017-06-15  6:58           ` Johannes Berg
  1 sibling, 1 reply; 10+ messages in thread
From: YUAN Linyu @ 2017-06-14 23:45 UTC (permalink / raw)
  To: Johannes Berg, cugyly@163.com, netdev@vger.kernel.org; +Cc: David S . Miller



> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> On Behalf Of Johannes Berg
> Sent: Thursday, June 15, 2017 12:32 AM
> To: cugyly@163.com; netdev@vger.kernel.org
> Cc: David S . Miller; YUAN Linyu
> Subject: Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
> 
> On Wed, 2017-06-14 at 18:29 +0200, Johannes Berg wrote:
> > On Wed, 2017-06-14 at 23:00 +0800, yuan linyu wrote:
> >
> > > sorry, I do them by hand.
> >
> > oh, ok.
> >
> > This seems to work:
> >
> > @@
> > identifier p;
> > expression len;
> > expression skb;
> > type t;
> > @@
> > -p = (t)skb_put(skb, len);
> > -memset(p, 0, len);
> > +p = (t)skb_put_zero(skb, len);
> 
> Nope, still didn't find everything - not the batman and atm cases for
> example. But still a few more, I think that you didn't find, e.g. in
> mac80211.
Yes, I thought you already done in mac80211
> 
> Anyway - I think none of this is really critical.
> 
> johannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 00/11] skb_put_zero() used to optimize code
  2017-06-14 23:45         ` YUAN Linyu
@ 2017-06-15  6:58           ` Johannes Berg
  0 siblings, 0 replies; 10+ messages in thread
From: Johannes Berg @ 2017-06-15  6:58 UTC (permalink / raw)
  To: YUAN Linyu, cugyly@163.com, netdev@vger.kernel.org; +Cc: David S . Miller

On Wed, 2017-06-14 at 23:45 +0000, YUAN Linyu wrote:
> > 
> > But still a few more, I think that you didn't find, e.g.
> > in mac80211.
> 
> Yes, I thought you already done in mac80211

So did I, but I also only applied my spatch :)

johannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-06-15  6:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-14 14:30 [PATCH net-next 00/11] skb_put_zero() used to optimize code yuan linyu
2017-06-14 14:42 ` Johannes Berg
2017-06-14 15:00   ` yuan linyu
2017-06-14 16:29     ` Johannes Berg
2017-06-14 16:31       ` Johannes Berg
2017-06-14 19:38         ` David Miller
2017-06-14 20:11           ` Johannes Berg
2017-06-14 20:15             ` David Miller
2017-06-14 23:45         ` YUAN Linyu
2017-06-15  6:58           ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).