From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B361C2BD09 for ; Tue, 9 Jul 2024 13:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TbYmgVACDAtRDSTL3B4NejRqBxXknmHxVQadZf89uHw=; b=p3A/FdhFr9mRkIlgAi0OHb01XS JzrdDKb9yOSX957LUwbMaQfRzCnQOd2NSlT5ak43tfBYiV/iP/gkSPbsuKtrafN90Ht+IibIRHf3t gGSDdENehzlxpGzXG3210H+GFmD5Hk5JiCgEreFq3zKKP6vkkvRcJpsUxr8V+l2DrIs7D1GHQ8G3d 004VEoOjuF0+0ZoYmcOjNDv08X7d7C3W42x30KAGyHudp4Zzhp5UDLNRZfn63U0OdSsFYxJvFCAtL EJIg3SyB09vExc5gyjNk7GnB8Zcxiof+abl9IJzbD2i/5mQd2Awg9H8EolH1ZrKltg8v5NsAcsVVJ 6o9skobw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRBMZ-00000007TVi-0NFu; Tue, 09 Jul 2024 13:58:35 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRBMH-00000007TSJ-3Jm5 for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2024 13:58:19 +0000 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-356c4e926a3so3365770f8f.1 for ; Tue, 09 Jul 2024 06:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720533495; x=1721138295; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TbYmgVACDAtRDSTL3B4NejRqBxXknmHxVQadZf89uHw=; b=Mv+9CvmDUioLkCCc9mTwcEzw8JZhwesy/fc9y1rZzG++8t/cc8TwTMddqa6T3QKmO+ rFWpwQMmzC4La+zSdjSTkBmFoUBAIAdEzWw1K3yUsHlL4gErqjK9k+eZiWSQlphmnP8C NBWbs9tSTWyRME7/swcK+rHJL0RbhOUFtqByB7UUoV4gN4Y6PQUqT+3LnJohKuuFJkKQ WBgHKpGxtsn/avswMf0gbe5BueUEPsu9yYKfjjN0QVxLCjh7iCrjMOZXOFQI0eQc10pr xybUB7xX7+tDQUAK/Kv5XJkhZsx4ta2jzaQh4FfcPo6bwAPS5MhqSL2VG5m71PPEbmqL HvFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720533495; x=1721138295; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TbYmgVACDAtRDSTL3B4NejRqBxXknmHxVQadZf89uHw=; b=wMcKDYLa9v/Yfubo4tTJVnrmLDeiEJEojpBzfp/iKtUj7xfEkmlQ+AaJc1y6UYI7ls 0qjbjbPsG/AQ8PollNWTQiESFRzS0T2h36gVknUfCMtBGRbiPVFQtiYktwVTJK2Jowgy jSMdZNkXPJkNO/NB2OliMAhbzUojFBMa7ZZCkA0XKjLNWoW4EPRpMVWVacDEAYlvIvGz tRUFfQN+dO8dAfrdGOJaxkyky+2RXpYl3V+UbytYwrQphO7UXGz9pKKW+iixOePp/JnI wgs3PmZm9eqz4H/H61WqnJZeemnFKrvIEaCmp5rZo/h/TVfsrN+L9pRFYs6svJiCl5FG 4xEQ== X-Forwarded-Encrypted: i=1; AJvYcCXColzrKZmgpiQl3HiJnnUz2nTZ01TCgD4RivpqCNexM5pHCz8dsMaYW2XbUO6bcFOJvf3jvihTaXnP0RIbcRAwOk2P8ZEOB18DLBVi73xA+H/YgVc= X-Gm-Message-State: AOJu0YwL3mgzz460ehiP9OhMZKludBYw8vdtPFXah7Yv/0M/dRRNIqMt vLFlGQU6Mh6ORJ6oAnsRX3wa195MolsdqeWrbacX33IlWcgqtN4W X-Google-Smtp-Source: AGHT+IFhR6wXKYVJPy9dz+zWqOXpE2lauzhnAJp1D41g6UvLG42BZPLhgq5ODjo9utaXK51miT15Dw== X-Received: by 2002:adf:ffcd:0:b0:367:9791:2939 with SMTP id ffacd0b85a97d-367cea6b804mr1603691f8f.21.1720533494785; Tue, 09 Jul 2024 06:58:14 -0700 (PDT) Received: from skbuf ([188.25.110.57]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d16b0sm206311405e9.7.2024.07.09.06.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 06:58:14 -0700 (PDT) Date: Tue, 9 Jul 2024 16:58:11 +0300 From: Vladimir Oltean To: Breno Leitao Cc: kernel test robot , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, kuba@kernel.org, horms@kernel.org, Roy.Pledge@nxp.com, open list Subject: Re: [PATCH 1/4] soc: fsl: qbman: FSL_DPAA depends on COMPILE_TEST Message-ID: <20240709135811.c7tqh3ocfumg6ctt@skbuf> References: <20240624162128.1665620-1-leitao@debian.org> <202406261920.l5pzM1rj-lkp@intel.com> <20240626140623.7ebsspddqwc24ne4@skbuf> <20240708133746.ea62kkeq2inzcos5@skbuf> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="hpogfizkbgtmf2d4" Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_065817_870854_9D156900 X-CRM114-Status: GOOD ( 29.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --hpogfizkbgtmf2d4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Breno, On Mon, Jul 08, 2024 at 12:08:05PM -0700, Breno Leitao wrote: > I thought about a patch like the following (compile tested only). What > do you think? To be honest, there are several things I don't really like about this patch. - I really struggled with applying it in the current format. Could you please post the output of git format-patch in the future? - You addressed dpaa_set_coalesce() but not also dpaa_fq_setup() - You misrepresented the patch content by saying you only allocate size for online CPUs in the commit message. But you allocate for all possible CPUs. - You only kfree(needs_revert) in the error (revert_values) case, but not in the normal (return 0) case. - The netdev coding style is to sort the lines with variable declarations in reverse order of line length (they call this "reverse Christmas tree"). Your patch broke that order. - You should use kcalloc() instead of kmalloc_array() + memset() I have prepared and tested the attached alternative patch on a board and I am preparing to submit it myself, if you don't have any objection. Thanks, Vladimir --hpogfizkbgtmf2d4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-net-dpaa-avoid-on-stack-arrays-of-NR_CPUS-elements.patch" >From 00b942829ee283baa602011a05b02d18c6988171 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Mon, 8 Jul 2024 11:57:33 -0700 Subject: [PATCH] net: dpaa: avoid on-stack arrays of NR_CPUS elements The dpaa-eth driver is written for PowerPC and Arm SoCs which have 1-24 CPUs. It depends on CONFIG_NR_CPUS having a reasonably small value in Kconfig. Otherwise, there are 2 functions which allocate on-stack arrays of NR_CPUS elements, and these can quickly explode in size, leading to warnings such as: drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:3280:12: warning: stack frame size (16664) exceeds limit (2048) in 'dpaa_eth_probe' [-Wframe-larger-than] The problem is twofold: - Reducing the array size to the boot-time num_possible_cpus() (rather than the compile-time NR_CPUS) creates a variable-length array, avoidable in the Linux kernel. - Using NR_CPUS as an array size makes the driver blow up in stack consumption with generic, as opposed to hand-crafted, .config files. A simple solution is to use dynamic allocation for num_possible_cpus() elements (aka a small number determined at runtime). Link: https://lore.kernel.org/all/202406261920.l5pzM1rj-lkp@intel.com/ Signed-off-by: Vladimir Oltean --- .../net/ethernet/freescale/dpaa/dpaa_eth.c | 20 ++++++++++++++----- .../ethernet/freescale/dpaa/dpaa_ethtool.c | 10 +++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index ddeb0a5f2317..c856b556929d 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -931,14 +931,18 @@ static inline void dpaa_setup_egress(const struct dpaa_priv *priv, } } -static void dpaa_fq_setup(struct dpaa_priv *priv, - const struct dpaa_fq_cbs *fq_cbs, - struct fman_port *tx_port) +static int dpaa_fq_setup(struct dpaa_priv *priv, + const struct dpaa_fq_cbs *fq_cbs, + struct fman_port *tx_port) { int egress_cnt = 0, conf_cnt = 0, num_portals = 0, portal_cnt = 0, cpu; const cpumask_t *affine_cpus = qman_affine_cpus(); - u16 channels[NR_CPUS]; struct dpaa_fq *fq; + u16 *channels; + + channels = kcalloc(num_possible_cpus(), sizeof(u16), GFP_KERNEL); + if (!channels) + return -ENOMEM; for_each_cpu_and(cpu, affine_cpus, cpu_online_mask) channels[num_portals++] = qman_affine_channel(cpu); @@ -997,6 +1001,10 @@ static void dpaa_fq_setup(struct dpaa_priv *priv, break; } } + + kfree(channels); + + return 0; } static inline int dpaa_tx_fq_to_id(const struct dpaa_priv *priv, @@ -3416,7 +3424,9 @@ static int dpaa_eth_probe(struct platform_device *pdev) */ dpaa_eth_add_channel(priv->channel, &pdev->dev); - dpaa_fq_setup(priv, &dpaa_fq_cbs, priv->mac_dev->port[TX]); + err = dpaa_fq_setup(priv, &dpaa_fq_cbs, priv->mac_dev->port[TX]); + if (err) + goto free_dpaa_bps; /* Create a congestion group for this netdev, with * dynamically-allocated CGR ID. diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c index 5bd0b36d1feb..3f8cd4a7d845 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c @@ -457,12 +457,16 @@ static int dpaa_set_coalesce(struct net_device *dev, struct netlink_ext_ack *extack) { const cpumask_t *cpus = qman_affine_cpus(); - bool needs_revert[NR_CPUS] = {false}; struct qman_portal *portal; u32 period, prev_period; u8 thresh, prev_thresh; + bool *needs_revert; int cpu, res; + needs_revert = kcalloc(num_possible_cpus(), sizeof(bool), GFP_KERNEL); + if (!needs_revert) + return -ENOMEM; + period = c->rx_coalesce_usecs; thresh = c->rx_max_coalesced_frames; @@ -485,6 +489,8 @@ static int dpaa_set_coalesce(struct net_device *dev, needs_revert[cpu] = true; } + kfree(needs_revert); + return 0; revert_values: @@ -498,6 +504,8 @@ static int dpaa_set_coalesce(struct net_device *dev, qman_dqrr_set_ithresh(portal, prev_thresh); } + kfree(needs_revert); + return res; } -- 2.34.1 --hpogfizkbgtmf2d4--