Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp102753iof; Sun, 5 Jun 2022 22:27:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtXb284FQ5FsXAQ3TiVPDn56nOBmz08sbCmYWMGrSel3dqQx+0bU18biQVZJ652by+0GGR X-Received: by 2002:a63:81c6:0:b0:3fc:8ba2:9f9a with SMTP id t189-20020a6381c6000000b003fc8ba29f9amr20185465pgd.432.1654493249042; Sun, 05 Jun 2022 22:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654493249; cv=none; d=google.com; s=arc-20160816; b=IuLyGSoC3cB5nK68G9Bbg6mcJRD1wHLEEPOqiIr1YzmMtUk1reyWb4Hp/V5NOFpfp4 88BTZSC1/1L2HDUFlermOaMkfHeLtelcbmEPrndU1HhklB/Pq53DIpbJ7kiyjXPaAxgs hKGDva+3IswpWA+Fw5zf9IwvWDxF9796Zr4Gtlovb3n1iVmbiuQVLWgEFlVMLdLK/5YK unMdFt2d6XCFvQiYKx/eg96RrWlGdRTkAB66kIzZbF+coOva0mYdhXmQmozKBhA95Gdp 2+rZHYlUzoJ0npU5k8YAHSFcKM4fqWa3uVH45xKGvUqiVs8qb9yiV97mkwgjKD7O0FiS XHTQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=was8tcKpwkWpR9DxpcI7t1pBAFz2ts3UO52spVyMh7w=; b=OP9A7TgkoxpqrPMR7I5oMJSTPDhCWXvY0vpCAkpF3y3bmj6OEFo7uppzUsSvdbMCOx 0gyi5kpA9ifywKO3MFKVt6FuAET3CSJFScQGm6RdJtXoqewMBR9WOQJbJQtU+1JBqpgj xfSLcAOwYX4+Et3huYiZFJZYfFQZSEGRPJvMeJoNTMZZOnKxXzQGe2hPb+fUacLZtqu/ RRZ2vksPrhwMt+irBIK5J/JRt1G4wwuVN18cRG+2GewP0T4F41LbNsRGD81glU0qeEpF oLZhVrKdzGjBrvtcewGSY/h/SoGFr4ktY8Xy7h3+rpGu/AEPdiXfzSMk/IYDV/pcAGHV e9Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SoILe+FI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w191-20020a6382c8000000b003fcb87a92a1si16631368pgd.305.2022.06.05.22.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:27:29 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SoILe+FI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 38A641E7363; Sun, 5 Jun 2022 21:28:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239228AbiFCTCD (ORCPT + 99 others); Fri, 3 Jun 2022 15:02:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348708AbiFCTAB (ORCPT ); Fri, 3 Jun 2022 15:00:01 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13E2329833; Fri, 3 Jun 2022 12:00:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 6C987CE24B8; Fri, 3 Jun 2022 18:59:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E77CCC385B8; Fri, 3 Jun 2022 18:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654282797; bh=wNoOUeH436EM5Q4+ipBC6tMdcUFPQYmnJuswlasQq7s=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SoILe+FIL2S6KalxEeHmls5fUj88pDOTWr2GlXkpmPjl5+15cM4zJMc0RwCu3qH/3 QQIsotDeOWea8wAWWgNZGA2Vzz1rv8wKxyj8Bdude0azly82ePzu51lJpXZ85CTweI 5elR6Htm+9ahYC0czwCImx/nIgkILwiaxVRL1ZsjkUpbVFCexeLFzuZh0MQspNLkZU lZqEetTJ1+ZuY7yIHo9e6rIAXwzXdJ9Fpo38wEB64ZorajI8T/uAg3brpJGvrtmK1S 9+R5sPRSMtfyS0q7/Bd4Qu8OuFPKFEVvuoLnNskg6SQZH0Mhg8PZhX9aGOINHxAEoV iKbEjktYZcC/g== Date: Fri, 3 Jun 2022 11:59:56 -0700 From: Jakub Kicinski To: Eric Dumazet Cc: Chen Lin , Felix Fietkau , john@phrozen.org, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, David Miller , Paolo Abeni , Matthias Brugger , netdev , Linux ARM , linux-mediatek@lists.infradead.org, LKML , Alexander Duyck Subject: Re: [PATCH v2] net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface netdev[napi]_alloc_frag Message-ID: <20220603115956.6ad82a53@kernel.org> In-Reply-To: References: <2997c5b0-3611-5e00-466c-b2966f09f067@nbd.name> <1654245968-8067-1-git-send-email-chen45464546@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 3 Jun 2022 10:25:16 -0700 Eric Dumazet wrote: > > goto release_desc; > > @@ -1914,7 +1923,16 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag) > > return -ENOMEM; > > > > for (i = 0; i < rx_dma_size; i++) { > > - ring->data[i] = netdev_alloc_frag(ring->frag_size); > > Note aside, calling netdev_alloc_frag() in a loop like that is adding > GFP_ATOMIC pressure. > > mtk_rx_alloc() being in process context, using GFP_KERNEL allocations > would be less aggressive and > have more chances to succeed. > > We probably should offer a generic helper. This could be used from > driver/net/tun.c and others. Do cases where netdev_alloc_frag() is not run from a process context from to your mind? My feeling is that the prevailing pattern is what this driver does, which is netdev_alloc_frag() at startup / open and napi_alloc_frag() from the datapath. So maybe we can even spare the detail in the API and have napi_alloc_frag() assume GFP_KERNEL by default?