Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp23380pxv; Tue, 29 Jun 2021 22:18:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFF75KO9PUeovaJZGEnZKqM0KlKG2UztpJHg0vB2aZvmppckAKNmuzGAbJR7BZun7pSxhs X-Received: by 2002:aa7:c70d:: with SMTP id i13mr44625143edq.249.1625030290760; Tue, 29 Jun 2021 22:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625030290; cv=none; d=google.com; s=arc-20160816; b=HC2VU63aDP32EaT+i7zfDfvKZOAAWBweKenzASWuCO5b66OuqjZ69iJFT8NZv4kR/1 GLpFrGD1S0Frj51Tp1ZAHz315dWx849pA3RhBE7C2pAkMaV7UJInZ2CJEW/P4668hVIb Qz1zyf3SfP0EnrkyYq9Jvn1SdSnLUpEXWJEeO7RYZ5J09h8bJiFzwnc2DtxjwGuh6HX0 VEZ7S+USyI1saGUztS4bAlIx1yP4N5y3n6wYVZGfeHCK/ljHXcFs88TJ0+Rilns8Gt+H Rf8MI7uJPyRY9kBJ4nLeD8TGTFgijKwQEovxE9hgVS7jBr2UWqctwMiJLeNVjT6MfpYA 2XLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xugq2Itb92GveGC9lFrpW1MMdYEHoWa1T9rN2HNUDKY=; b=frr8xE80Hpi/jrKCjrD4gSjh4mGuv2l/2CmOtAsAa74LScigif43WuvJcSIMlSehgO W35/RxAP807KKrPa7kNW22r2YsEsNPD7dQ6VnJojq5u5ZVe1XTNqm1ilUAMKP376K28D nGtLZJH0FlxGJD8c8gOKEzVJTrih2P7bN2Fhm2F+KSXevmB4O9ozhQb8pYtfGOOKmHqK 6wM6Zs4WgqTbAvobjfCfnEuuP+eMHWpmqAhvNFV4my98TKBRXLNxvsKertFEKIZUs78O fBAPntd1jZ16btplb7r3r/DR00jDgRd2Ytrzck/jR1Af006bELZmFly1DSzXUSZZ7ztX cSmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MHZr4odT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si18733898ejh.141.2021.06.29.22.17.47; Tue, 29 Jun 2021 22:18:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MHZr4odT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233586AbhF3FOH (ORCPT + 99 others); Wed, 30 Jun 2021 01:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233538AbhF3FOG (ORCPT ); Wed, 30 Jun 2021 01:14:06 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7A0BC061766; Tue, 29 Jun 2021 22:11:37 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1625029894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xugq2Itb92GveGC9lFrpW1MMdYEHoWa1T9rN2HNUDKY=; b=MHZr4odTyNS4111aBfmnfJLq5X6M+HczsTMpadbO/67kWKT4gL8lESEOm3RPx2CXT5WPnj hNQXX9plwJtCyFyd4nVqTjlBdjgH6LFVpiJ2+7wMNB+op0w8pbyEIo337SAXw2rLa9GQnc IPO+vgycuNwp73PpNSm0ooZ2oJM3N6w= From: Yajun Deng To: davem@davemloft.net, kuba@kernel.org, andriin@fb.com, atenart@kernel.org, alobakin@pm.me, ast@kernel.org, edumazet@google.com, daniel@iogearbox.net, weiwan@google.com, ap420073@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] net: core: Modify alloc_size in alloc_netdev_mqs() Date: Wed, 30 Jun 2021 13:11:18 +0800 Message-Id: <20210630051118.2212-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: yajun.deng@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use ALIGN for 'struct net_device', and remove the unneeded 'NETDEV_ALIGN - 1'. This can save a few bytes. and modify the pr_err content when txqs < 1. Signed-off-by: Yajun Deng --- net/core/dev.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index c253c2aafe97..c42a682a624d 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10789,7 +10789,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, BUG_ON(strlen(name) >= sizeof(dev->name)); if (txqs < 1) { - pr_err("alloc_netdev: Unable to allocate device with zero queues\n"); + pr_err("alloc_netdev: Unable to allocate device with zero TX queues\n"); return NULL; } @@ -10798,14 +10798,12 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, return NULL; } - alloc_size = sizeof(struct net_device); + /* ensure 32-byte alignment of struct net_device*/ + alloc_size = ALIGN(sizeof(struct net_device), NETDEV_ALIGN); if (sizeof_priv) { /* ensure 32-byte alignment of private area */ - alloc_size = ALIGN(alloc_size, NETDEV_ALIGN); - alloc_size += sizeof_priv; + alloc_size += ALIGN(sizeof_priv, NETDEV_ALIGN); } - /* ensure 32-byte alignment of whole construct */ - alloc_size += NETDEV_ALIGN - 1; p = kvzalloc(alloc_size, GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!p) -- 2.32.0