Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965222AbbLOLV5 (ORCPT ); Tue, 15 Dec 2015 06:21:57 -0500 Received: from mail-qg0-f43.google.com ([209.85.192.43]:35762 "EHLO mail-qg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964921AbbLOLVy (ORCPT ); Tue, 15 Dec 2015 06:21:54 -0500 From: Ming Lei To: linux-kernel@vger.kernel.org, Alexei Starovoitov Cc: "David S. Miller" , netdev@vger.kernel.org, Ming Lei Subject: [PATCH 6/6] bpf: hash: reorganize 'struct htab_elem' Date: Tue, 15 Dec 2015 19:21:04 +0800 Message-Id: <1450178464-27721-7-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450178464-27721-1-git-send-email-tom.leiming@gmail.com> References: <1450178464-27721-1-git-send-email-tom.leiming@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1311 Lines: 52 Lifetime for hash fields and liftime for kfree_rcu fields can't be overlapped, so re-organizing them for better readabilty. Also one sizeof(void *) should be saved with this change, and cache footprint can got improved too. Signed-off-by: Ming Lei --- kernel/bpf/hashtab.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index c1600c3..5476545 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -17,15 +17,20 @@ /* each htab element is struct htab_elem + key + value */ struct htab_elem { + u32 tag; union { - struct hlist_node hash_node; - - /* used after deleted from hash */ - struct bpf_htab *htab; + /* won't be used after being removed from hash */ + struct { + u32 hash; + struct hlist_node hash_node; + }; + + /* set after being deleted from hash */ + struct { + struct bpf_htab *htab; + struct rcu_head rcu; + }; }; - struct rcu_head rcu; - u32 hash; - u32 tag; char key[0] __aligned(8); }; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/