From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 74EBD192B98; Wed, 10 Jul 2024 13:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720619062; cv=none; b=bGJCJnBELEuKsJPuBeOQKCylMCeQVV7ESfcmM9A7esgFA1za/Qx/EYieYOrMi8EkEJ/eWegXsgkAO27M8niMlKHFQSa78THsm9O5KD5WS9PiWidnkSc8UMwZUfZUt74AboOBWbMPrfr0CYUvIXtJptym9notOqNvtKxcgpIAijg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720619062; c=relaxed/simple; bh=YLWNJAMBEj6wuEjbKu2MzzNMNoT+GkqatSDHG9Byrc4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ir/ATMYLlLFffguBectn9pCsA6RftzIhrf5q0Dmhp5vC/Cf5li/7SX0b8LJZ4zeFt/wRjVupx+HCq1q6gZQ3StYqaDggKdm8r/peNn5WjEroR1xIngoyVy8iBrUV3hsFd5hyxD331cqv+3d2F4zEXQz5cbsNVNn/L8mm2P12KTI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m33srKBc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m33srKBc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1F5BC32781; Wed, 10 Jul 2024 13:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720619062; bh=YLWNJAMBEj6wuEjbKu2MzzNMNoT+GkqatSDHG9Byrc4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m33srKBcRZK1Q5vXVsDRTMGtm+UM9DyOxNZR/f+uMA+1wDcgKxieAiKLB5g8UQvAH 6vUE/q4io+Udiy3avskC6Py3Ypss1vGlzKmqq474M0aGTKYaWz8FV77Y+5A9nPVXKX GSzhGtTneElcSrkAIa2Hpi2P7yjl9WOkqp7Xsh8WtRA73uK62RSJ2fft2vf2qdkspk drvzsrLg/DQWxPI17CIG1urfR347QQCGps7OuZ4lyw0gCmi+8BNCI6KapJiX7fji97 RrBv9QVvtAlF3HyM+QkSUPN0vUBM6R0SccMl63X9J2Ug0RFguHS+H5sRdywfpRvhb5 ASRKe20xOoPlw== Date: Wed, 10 Jul 2024 14:44:16 +0100 From: Simon Horman To: Breno Leitao Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kees Cook , "Gustavo A. R. Silva" , keescook@chromium.org, linux-hardening@vger.kernel.org, Alexander Lobakin , Przemek Kitszel , Jiri Pirko , Sebastian Andrzej Siewior , Daniel Borkmann , Lorenzo Bianconi , Johannes Berg , "open list:NETWORKING [GENERAL]" , open list Subject: Re: [PATCH net-next v3] netdevice: define and allocate &net_device _properly_ Message-ID: <20240710134416.GT346094@kernel.org> References: <20240710113036.2125584-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240710113036.2125584-1-leitao@debian.org> On Wed, Jul 10, 2024 at 04:30:28AM -0700, Breno Leitao wrote: > From: Alexander Lobakin > > In fact, this structure contains a flexible array at the end, but > historically its size, alignment etc., is calculated manually. > There are several instances of the structure embedded into other > structures, but also there's ongoing effort to remove them and we > could in the meantime declare &net_device properly. > Declare the array explicitly, use struct_size() and store the array > size inside the structure, so that __counted_by() can be applied. > Don't use PTR_ALIGN(), as SLUB itself tries its best to ensure the > allocated buffer is aligned to what the user expects. > Also, change its alignment from %NETDEV_ALIGN to the cacheline size > as per several suggestions on the netdev ML. > > bloat-o-meter for vmlinux: > > free_netdev 445 440 -5 > netdev_freemem 24 - -24 > alloc_netdev_mqs 1481 1450 -31 > > On x86_64 with several NICs of different vendors, I was never able to > get a &net_device pointer not aligned to the cacheline size after the > change. > > Signed-off-by: Alexander Lobakin > Signed-off-by: Breno Leitao > Reviewed-by: Przemek Kitszel > Reviewed-by: Eric Dumazet > Reviewed-by: Kees Cook > > --- > Changelog > > v3: > * Fix kernel-doc documentation for the new fields (Simon) Thanks for the update, LGTM.