netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: sched: shrink struct Qdisc
@ 2018-05-25 14:28 Paolo Abeni
  2018-05-25 14:41 ` Jiri Pirko
  2018-05-29  3:13 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2018-05-25 14:28 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Jamal Hadi Salim, Cong Wang, Jiri Pirko

The struct Qdisc has a lot of holes, especially after commit
a53851e2c321 ("net: sched: explicit locking in gso_cpu fallback"),
which as a side effect, moved the fields just after 'busylock'
on a new cacheline.

Since both 'padded' and 'refcnt' are not updated frequently, and
there is a hole before 'gso_skb', we can move such fields there,
saving a cacheline without any performance side effect.

Before this commit:

pahole -C Qdisc net/sche/sch_generic.o
	# ...
        /* size: 384, cachelines: 6, members: 25 */
        /* sum members: 236, holes: 3, sum holes: 92 */
        /* padding: 56 */

After this commit:
pahole -C Qdisc net/sche/sch_generic.o
	# ...
	/* size: 320, cachelines: 5, members: 25 */
	/* sum members: 236, holes: 2, sum holes: 28 */
	/* padding: 56 */

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 include/net/sch_generic.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 98c10a28cd01..827a3711dc68 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -85,6 +85,8 @@ struct Qdisc {
 	struct net_rate_estimator __rcu *rate_est;
 	struct gnet_stats_basic_cpu __percpu *cpu_bstats;
 	struct gnet_stats_queue	__percpu *cpu_qstats;
+	int			padded;
+	refcount_t		refcnt;
 
 	/*
 	 * For performance sake on SMP, we put highly modified fields at the end
@@ -97,8 +99,6 @@ struct Qdisc {
 	unsigned long		state;
 	struct Qdisc            *next_sched;
 	struct sk_buff_head	skb_bad_txq;
-	int			padded;
-	refcount_t		refcnt;
 
 	spinlock_t		busylock ____cacheline_aligned_in_smp;
 	spinlock_t		seqlock;
-- 
2.17.0

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

* Re: [PATCH net-next] net: sched: shrink struct Qdisc
  2018-05-25 14:28 [PATCH net-next] net: sched: shrink struct Qdisc Paolo Abeni
@ 2018-05-25 14:41 ` Jiri Pirko
  2018-05-29  3:13 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2018-05-25 14:41 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: netdev, David S. Miller, Jamal Hadi Salim, Cong Wang

Fri, May 25, 2018 at 04:28:44PM CEST, pabeni@redhat.com wrote:
>The struct Qdisc has a lot of holes, especially after commit
>a53851e2c321 ("net: sched: explicit locking in gso_cpu fallback"),
>which as a side effect, moved the fields just after 'busylock'
>on a new cacheline.
>
>Since both 'padded' and 'refcnt' are not updated frequently, and
>there is a hole before 'gso_skb', we can move such fields there,
>saving a cacheline without any performance side effect.
>
>Before this commit:
>
>pahole -C Qdisc net/sche/sch_generic.o
>	# ...
>        /* size: 384, cachelines: 6, members: 25 */
>        /* sum members: 236, holes: 3, sum holes: 92 */
>        /* padding: 56 */
>
>After this commit:
>pahole -C Qdisc net/sche/sch_generic.o
>	# ...
>	/* size: 320, cachelines: 5, members: 25 */
>	/* sum members: 236, holes: 2, sum holes: 28 */
>	/* padding: 56 */
>
>Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Acked-by: Jiri Pirko <jiri@mellanox.com>

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

* Re: [PATCH net-next] net: sched: shrink struct Qdisc
  2018-05-25 14:28 [PATCH net-next] net: sched: shrink struct Qdisc Paolo Abeni
  2018-05-25 14:41 ` Jiri Pirko
@ 2018-05-29  3:13 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-05-29  3:13 UTC (permalink / raw)
  To: pabeni; +Cc: netdev, jhs, xiyou.wangcong, jiri

From: Paolo Abeni <pabeni@redhat.com>
Date: Fri, 25 May 2018 16:28:44 +0200

> The struct Qdisc has a lot of holes, especially after commit
> a53851e2c321 ("net: sched: explicit locking in gso_cpu fallback"),
> which as a side effect, moved the fields just after 'busylock'
> on a new cacheline.
> 
> Since both 'padded' and 'refcnt' are not updated frequently, and
> there is a hole before 'gso_skb', we can move such fields there,
> saving a cacheline without any performance side effect.
> 
> Before this commit:
> 
> pahole -C Qdisc net/sche/sch_generic.o
> 	# ...
>         /* size: 384, cachelines: 6, members: 25 */
>         /* sum members: 236, holes: 3, sum holes: 92 */
>         /* padding: 56 */
> 
> After this commit:
> pahole -C Qdisc net/sche/sch_generic.o
> 	# ...
> 	/* size: 320, cachelines: 5, members: 25 */
> 	/* sum members: 236, holes: 2, sum holes: 28 */
> 	/* padding: 56 */
> 
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Applied.

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

end of thread, other threads:[~2018-05-29  3:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-25 14:28 [PATCH net-next] net: sched: shrink struct Qdisc Paolo Abeni
2018-05-25 14:41 ` Jiri Pirko
2018-05-29  3:13 ` David Miller

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).