From patchwork Fri Oct 2 21:49:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 289058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0352BC46466 for ; Fri, 2 Oct 2020 21:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93CC321789 for ; Fri, 2 Oct 2020 21:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601675404; bh=RqGwQgMBRsPPfyV9SqR82PwvvtXcQaIrWjN40eVEUFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DLLNyCl9tf3DG5S6tGaDkg9rMNq99DupfXUc+/t3deetdG62nClLm3U1bbwMKE4d8 CvheH7IWjOr16s48ka04N/irf0K9T6VhWS599V3Jts24l1ywX6jBgoyu9RahffNW2e X4gqolWuGPmUoLaa9ollApt2i5IRlvmQoNcMJfGI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725767AbgJBVuD (ORCPT ); Fri, 2 Oct 2020 17:50:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:54706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbgJBVuD (ORCPT ); Fri, 2 Oct 2020 17:50:03 -0400 Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 32D2D20754; Fri, 2 Oct 2020 21:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601675402; bh=RqGwQgMBRsPPfyV9SqR82PwvvtXcQaIrWjN40eVEUFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FsOPrnrG4DEkJ+w2h27UsD5FPAe4tWs0XS36v7Uo1Eyp1Yz95KkDk4KhsEbbwYQpW GD2LfKlFMuOyiLMSYz2mH0IFWEn4kfVFR9wvNMPZLAgizIrrWAk3o7csAJJyv+YCYo JRbruYw8A7HIOXCZ+rcwOvReqyHpsvF6rjAZbjpo= From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, andrew@lunn.ch, johannes@sipsolutions.net, jiri@resnulli.us, mkubecek@suse.cz, dsahern@kernel.org, pablo@netfilter.org, Jakub Kicinski Subject: [PATCH net-next v3 1/9] genetlink: reorg struct genl_family Date: Fri, 2 Oct 2020 14:49:52 -0700 Message-Id: <20201002215000.1526096-2-kuba@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002215000.1526096-1-kuba@kernel.org> References: <20201002215000.1526096-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There are holes and oversized members in struct genl_family. Before: /* size: 104, cachelines: 2, members: 16 */ After: /* size: 88, cachelines: 2, members: 16 */ The command field in struct genlmsghdr is a u8, so no point in the operation count being 32 bit. Also operation 0 is usually undefined, so we only need 255 entries. netnsok and parallel_ops are only ever initialized to true. We can grow the fields as needed, compiler should warn us if someone tries to assign larger constants. Signed-off-by: Jakub Kicinski Reviewed-by: Johannes Berg --- include/net/genetlink.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/genetlink.h b/include/net/genetlink.h index b9eb92f3fe86..5cd9ab0c6bd9 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h @@ -48,8 +48,11 @@ struct genl_family { char name[GENL_NAMSIZ]; unsigned int version; unsigned int maxattr; - bool netnsok; - bool parallel_ops; + unsigned int mcgrp_offset; /* private */ + u8 netnsok:1; + u8 parallel_ops:1; + u8 n_ops; + u8 n_mcgrps; const struct nla_policy *policy; int (*pre_doit)(const struct genl_ops *ops, struct sk_buff *skb, @@ -59,9 +62,6 @@ struct genl_family { struct genl_info *info); const struct genl_ops * ops; const struct genl_multicast_group *mcgrps; - unsigned int n_ops; - unsigned int n_mcgrps; - unsigned int mcgrp_offset; /* private */ struct module *module; };