From patchwork Thu Oct 1 22:59:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 267148 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 5E33CC4727F for ; Thu, 1 Oct 2020 22:59:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C6BA2177B for ; Thu, 1 Oct 2020 22:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601593184; bh=RqGwQgMBRsPPfyV9SqR82PwvvtXcQaIrWjN40eVEUFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GBnjpzkAJsZ1bJye3J6QDIKycDntv4Rk1iAuVR6kIKSibBC0wqRmwoBD7UMmqqx7d Abz71xBkIOOh9p+KPemdZbZ32r2QbXume/dbxbVMD71QDOmipUrtGGLt5VedjVO7Zh x4vCP+Xqj6qUYIpZv9tEtiMK+jJlSCQog3msmoYw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733196AbgJAW7n (ORCPT ); Thu, 1 Oct 2020 18:59:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:40636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733120AbgJAW7n (ORCPT ); Thu, 1 Oct 2020 18:59:43 -0400 Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.6]) (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 22B8720848; Thu, 1 Oct 2020 22:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601593182; bh=RqGwQgMBRsPPfyV9SqR82PwvvtXcQaIrWjN40eVEUFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B9TCmHjiwoEXUmTU9wkn+RFb31LQZSeWUleF8W4l3JMzJNl/ufkqbiWTFFVWeS4rA Xf5FDuR/7Q2jxnraWs5i8KfCUiFCTAeGcv0KuXC6IRsX6Z4WK2m5AElTm0sDxYdCTs DQqeeeZHAzn0zEPvIWbF5GUQK7kra/HypqkE1bPs= 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 v2 01/10] genetlink: reorg struct genl_family Date: Thu, 1 Oct 2020 15:59:24 -0700 Message-Id: <20201001225933.1373426-2-kuba@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001225933.1373426-1-kuba@kernel.org> References: <20201001225933.1373426-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; };