From patchwork Wed Aug 16 14:06:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemek Kitszel X-Patchwork-Id: 13355224 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69C5CFC01 for ; Wed, 16 Aug 2023 14:09:26 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200032706; Wed, 16 Aug 2023 07:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692194965; x=1723730965; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uIKtvDbe+7VbgaZgQmtc0Up6bjzaTD/DQNKknP+rGoE=; b=YDdZFUZwqKJk3m4YVZYownJoHuPGMiTUjwCONCkQ78m755Z7MINuSLaw QJuHM2xMnVbq4eolZn5OwRDgc13Ec9QDueHtmnAKy/4ThvMv3q+jyTmEO oHrqH35LwIXhgN/EniiM48a1qUn1vra/zHXzQV55nGAcELZ5PPHC2Tmc1 +HzvqdxWXZ0SDnfE1rK8Fj284y53zV+VwTFX6RUoP4wzR/ELe4cEPVVoC zcyYMzdmt3ajeYi9l2Lq9ovAGKeRQUbirj3EPC2ddwrK2B9Phm3tq96BD zDJ5msmrbdKtsOz2beYmZVQMc/WOW78f/A14i2q6uwAfufcIrX54unbfV g==; X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="375312756" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="375312756" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2023 07:09:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="980753045" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="980753045" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga006.fm.intel.com with ESMTP; 16 Aug 2023 07:09:21 -0700 Received: from pelor.igk.intel.com (pelor.igk.intel.com [10.123.220.13]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 65ABF3497F; Wed, 16 Aug 2023 15:09:20 +0100 (IST) From: Przemek Kitszel To: Kees Cook , netdev@vger.kernel.org Cc: Jacob Keller , intel-wired-lan@lists.osuosl.org, Alexander Lobakin , linux-hardening@vger.kernel.org, Steven Zou , Przemek Kitszel Subject: [PATCH net-next v3 0/7] introduce DEFINE_FLEX() macro Date: Wed, 16 Aug 2023 10:06:16 -0400 Message-Id: <20230816140623.452869-1-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add DEFINE_FLEX() macro, that helps on-stack allocation of structures with trailing flex array member. Expose __struct_size() macro which reads size of data allocated by DEFINE_FLEX(). Accompany new macros introduction with actual usage, in the ice driver (hence targeting for netdev tree). Obvious benefits include simpler resulting code, less heap usage, less error checking. Less obvious is the fact that compiler has more room to optimize, and as a whole, even with more stuff on the stack, we end up with overall better (smaller) report from bloat-o-meter: add/remove: 8/6 grow/shrink: 7/18 up/down: 2211/-2270 (-59) (individual results in each patch). v3: tidy up 1st patch v2: Kees: reusing __struct_size() instead of doubling it as a new macro Przemek Kitszel (7): overflow: add DEFINE_FLEX() for on-stack allocs ice: ice_sched_remove_elems: replace 1 elem array param by u32 ice: drop two params of ice_aq_move_sched_elems() ice: make use of DEFINE_FLEX() in ice_ddp.c ice: make use of DEFINE_FLEX() for struct ice_aqc_add_tx_qgrp ice: make use of DEFINE_FLEX() for struct ice_aqc_dis_txq_item ice: make use of DEFINE_FLEX() in ice_switch.c drivers/net/ethernet/intel/ice/ice_common.c | 20 ++----- drivers/net/ethernet/intel/ice/ice_ddp.c | 39 ++++--------- drivers/net/ethernet/intel/ice/ice_lag.c | 48 ++++------------ drivers/net/ethernet/intel/ice/ice_lib.c | 23 ++------ drivers/net/ethernet/intel/ice/ice_sched.c | 56 ++++++------------ drivers/net/ethernet/intel/ice/ice_sched.h | 6 +- drivers/net/ethernet/intel/ice/ice_switch.c | 63 +++++---------------- drivers/net/ethernet/intel/ice/ice_xsk.c | 22 +++---- include/linux/compiler_types.h | 32 +++++++---- include/linux/fortify-string.h | 4 -- include/linux/overflow.h | 20 +++++++ 11 files changed, 115 insertions(+), 218 deletions(-) base-commit: 479b322ee6feaff612285a0e7f22c022e8cd84eb