From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: [PATCH v4 net-next 15/19] rhashtable: reorganize struct rhashtable layout Date: Sat, 31 Mar 2018 12:58:56 -0700 Message-ID: <20180331195900.183604-16-edumazet@google.com> References: <20180331195900.183604-1-edumazet@google.com> Cc: netdev , Florian Westphal , Herbert Xu , Thomas Graf , Jesper Dangaard Brouer , Alexander Aring , Stefan Schmidt , Kirill Tkhai , Eric Dumazet , Eric Dumazet To: "David S . Miller" Return-path: Received: from mail-pg0-f68.google.com ([74.125.83.68]:45415 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752986AbeCaT7u (ORCPT ); Sat, 31 Mar 2018 15:59:50 -0400 Received: by mail-pg0-f68.google.com with SMTP id y63so6996323pgy.12 for ; Sat, 31 Mar 2018 12:59:50 -0700 (PDT) In-Reply-To: <20180331195900.183604-1-edumazet@google.com> Sender: netdev-owner@vger.kernel.org List-ID: While under frags DDOS I noticed unfortunate false sharing between @nelems and @params.automatic_shrinking Move @nelems at the end of struct rhashtable so that first cache line is shared between all cpus, because almost never dirtied. Signed-off-by: Eric Dumazet --- include/linux/rhashtable.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index 668a21f04b09665018ffaf91989f32995fbbdfc4..1f8ad121eb4346ed06195661dc2327d17be4de49 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h @@ -152,25 +152,25 @@ struct rhashtable_params { /** * struct rhashtable - Hash table handle * @tbl: Bucket table - * @nelems: Number of elements in table * @key_len: Key length for hashfn - * @p: Configuration parameters * @max_elems: Maximum number of elements in table + * @p: Configuration parameters * @rhlist: True if this is an rhltable * @run_work: Deferred worker to expand/shrink asynchronously * @mutex: Mutex to protect current/future table swapping * @lock: Spin lock to protect walker list + * @nelems: Number of elements in table */ struct rhashtable { struct bucket_table __rcu *tbl; - atomic_t nelems; unsigned int key_len; - struct rhashtable_params p; unsigned int max_elems; + struct rhashtable_params p; bool rhlist; struct work_struct run_work; struct mutex mutex; spinlock_t lock; + atomic_t nelems; }; /** -- 2.17.0.rc1.321.gba9d0f2565-goog