netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Or Gerlitz <or.gerlitz@gmail.com>,
	Govindarajulu Varadarajan <_govind@gmx.com>,
	Yinghai Lu <yinghai@kernel.org>,
	David Miller <davem@davemloft.net>,
	NetDev <netdev@vger.kernel.org>,
	ssujith@cisco.com, gvaradar@cisco.com,
	"Christian Benvenuti (benve)" <benve@cisco.com>
Subject: Re: [PATCH net] net: sched: shrink struct qdisc_skb_cb to 28 bytes
Date: Thu, 18 Sep 2014 12:31:11 -0700	[thread overview]
Message-ID: <1411068671.4290.24.camel@joe-AO725> (raw)
In-Reply-To: <1411067679.7106.283.camel@edumazet-glaptop2.roam.corp.google.com>

On Thu, 2014-09-18 at 12:14 -0700, Eric Dumazet wrote:
> On Thu, 2014-09-18 at 11:07 -0700, Joe Perches wrote:
> 
> > > +static inline struct ipoib_cb *ipoib_skb_cb(const struct sk_buff *skb)
> > > +{
> > > +	BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct ipoib_cb));
> > > +	return (struct ipoib_cb *)skb->cb;
> > > +}
> > 
> > It seems better not to use const for the struct sk_buff * here.
> > 
> > Neither of the uses take a const struct sk_buff *
> 
> Thats pretty standard, check for other similar constructs like that.
> 
> 
> static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb)
> {
>         return (struct qdisc_skb_cb *)skb->cb;
> }
> 
> This allows uses of the helper when the skb is only read (has the const qual)

I don't mind the const argument, but casting
the return to non-const seems like poor form.

btw: it seems like it's 8:5 non-const to const

$ grep -rP --include=*.[ch] -n "cb\s*\*\s*\w+\s*\(\s*(?:const\s+)?struct\s+sk_buff\s*\*\s*\w+\s*\)" *
drivers/net/ethernet/freescale/gianfar.c:2091:static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
drivers/net/wireless/ath/ath10k/core.h:83:static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
include/net/mrp.h:38:static inline struct mrp_skb_cb *mrp_cb(struct sk_buff *skb)
include/net/ieee802154_netdev.h:235:static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb)
include/net/ieee802154_netdev.h:240:static inline struct ieee802154_mac_cb *mac_cb_init(struct sk_buff *skb)
include/net/sch_generic.h:251:static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb)
include/net/codel.h:95:static struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb)
include/net/garp.h:36:static inline struct garp_skb_cb *garp_cb(struct sk_buff *skb)
net/core/dev.c:2177:static struct dev_kfree_skb_cb *get_kfree_skb_cb(const struct sk_buff *skb)
net/sched/sch_choke.c:142:static inline struct choke_skb_cb *choke_skb_cb(const struct sk_buff *skb)
net/sched/sch_sfb.c:95:static inline struct sfb_skb_cb *sfb_skb_cb(const struct sk_buff *skb)
net/sched/sch_netem.c:171:static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb)
net/sched/sch_sfq.c:167:static inline struct sfq_skb_cb *sfq_skb_cb(const struct sk_buff *skb)

  reply	other threads:[~2014-09-18 19:31 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-09 18:32 [PATCH net-next 0/8] enic updates Govindarajulu Varadarajan
2014-06-09 18:32 ` [PATCH net-next 1/8] flow_keys: Record IP layer protocol in skb_flow_dissect() Govindarajulu Varadarajan
2014-06-10 13:11   ` Daniel Borkmann
2014-06-10 14:08     ` Govindarajulu Varadarajan
2014-06-10 14:26       ` Eric Dumazet
2014-06-11 22:06         ` David Miller
2014-06-11 22:08           ` David Miller
2014-06-12  5:38             ` Govindarajulu Varadarajan
2014-06-19 18:06   ` Chema Gonzalez
2014-06-19 18:52     ` Govindarajulu Varadarajan
2014-06-24  5:29   ` Yinghai Lu
2014-06-26  6:34     ` Govindarajulu Varadarajan
2014-09-18 14:18       ` Or Gerlitz
2014-09-18 14:38         ` Eric Dumazet
2014-09-18 15:02         ` [PATCH net] net: sched: shrink struct qdisc_skb_cb to 28 bytes Eric Dumazet
2014-09-18 16:26           ` Stephen Hemminger
2014-09-18 16:32             ` Eric Dumazet
2014-09-18 18:00               ` Eric Dumazet
2014-09-18 18:07                 ` Joe Perches
2014-09-18 19:14                   ` Eric Dumazet
2014-09-18 19:31                     ` Joe Perches [this message]
2014-09-18 20:31                       ` Eric Dumazet
2014-09-18 21:28               ` Or Gerlitz
2014-09-18 22:29           ` [net] " Doug Ledford
2014-09-19 12:07             ` Or Gerlitz
2014-09-22 18:38             ` David Miller
2014-09-22 18:22           ` [PATCH net] " David Miller
2014-06-09 18:32 ` [PATCH net-next 2/8] enic: fix return value in _vnic_dev_cmd Govindarajulu Varadarajan
2014-06-09 18:32 ` [PATCH net-next 3/8] enic: devcmd for adding IP 5 tuple hardware filters Govindarajulu Varadarajan
2014-06-09 18:32 ` [PATCH net-next 4/8] enic: alloc/free rx_cpu_rmap Govindarajulu Varadarajan
2014-06-09 18:44   ` Sergei Shtylyov
2014-06-10 13:52     ` Govindarajulu Varadarajan
2014-06-10 15:00       ` Sergei Shtylyov
2014-06-09 18:32 ` [PATCH net-next 5/8] enic: Add Accelerated RFS support Govindarajulu Varadarajan
2014-06-09 18:32 ` [PATCH net-next 6/8] enic: fix lockdep around devcmd_lock Govindarajulu Varadarajan
2014-06-09 18:32 ` [PATCH net-next 7/8] enic: add low latency socket busy_poll support Govindarajulu Varadarajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411068671.4290.24.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=_govind@gmx.com \
    --cc=benve@cisco.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=gvaradar@cisco.com \
    --cc=netdev@vger.kernel.org \
    --cc=or.gerlitz@gmail.com \
    --cc=ssujith@cisco.com \
    --cc=stephen@networkplumber.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).