Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1275326pxb; Wed, 4 Nov 2020 04:53:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIcuQrj55Xj225j7QubTz3vUeascW+78Dj+41VQXvztDCda+amYP381j3BT3uKIDCwZulv X-Received: by 2002:a17:906:68d8:: with SMTP id y24mr24920950ejr.438.1604494414595; Wed, 04 Nov 2020 04:53:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604494414; cv=none; d=google.com; s=arc-20160816; b=ub3wY8y9K/r79UgvasP9eET9MWRh0GN8RmZSLNuwn6jCN+Cr/YHcG8hNhWyb0EtrvX PwP08VChpsT/YyMZ5QMOhKnBAyeQJJ/w7QYcLvwPaHe2O2am3nF6fM8GXOFQoNzOILMw yALbFqnBEiRqpZ9G9g4W9VAnEUVfOoJD06wb4k+ue9qU4RkpxLVLhcYbxf8VOmnFc95K jToyt0nPvh2lnMUxmPAdOXbAo36/uUMLBGI3EEZNQZ5biqptEeTq2jnp99ElYl2s9Bdv LW8Q5NQzYXHsrFZlWiW9IZw96N+H11w3O3XIKzJkQ36QYdc3KKLrnwSJL7yhYAFlqlu+ KrCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=pLlGk+cZ5H+bPN4ICXizwdh/rPzTm72DYXYeQwOXCr0=; b=ytPh3/veOdMVmG9774fITzk3qBAUUpyNy8GDNjQMuSRZGqiGKujhXv1l0nmPv0BOXI cY51v3ygjW4jVVLEgoIzmwYRzb58tocptLF9g3f5u/NzUnohCV0m19IRf/XltPNCM/GP zJmfIfX0A/Oc0FG5UzEF3j46+7/Um/IwXe2Px6g+mgrLbOk3y+eIxjnmeaceF6rHjFyg LOhVeR27IjpJwm9LiIDjVyNs2num/2cDPwTPgb5GLONtyVmJW6zOraf/fnDX/n525bMC S1+OPrsXM8I8p8mZWiOGjJkt1usFcpA584CK6jm5znWBlZ+s690C6ye5JlwLCv5yjYxz 5BjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tk7tVGSa; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n7si1291877ejr.387.2020.11.04.04.53.10; Wed, 04 Nov 2020 04:53:34 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=Tk7tVGSa; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729591AbgKDMve (ORCPT + 99 others); Wed, 4 Nov 2020 07:51:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728922AbgKDMve (ORCPT ); Wed, 4 Nov 2020 07:51:34 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9108BC0613D3; Wed, 4 Nov 2020 04:51:33 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id k10so20595877wrw.13; Wed, 04 Nov 2020 04:51:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pLlGk+cZ5H+bPN4ICXizwdh/rPzTm72DYXYeQwOXCr0=; b=Tk7tVGSahYOHlMXSNvEBkehn7INsUSuXVmTxbRu96ErkVy5nIkklFOpdHV8jo1+tXS kDb8fdQqrhfXeXPgkSbBiHSAJrMMd6cdjk4kBzXWg361UcfiTMW0KHUWAzsjK3kcSc2P jqOhsSbafcy5rZ4v5FJOQs6/F/k4guUtiBWbQWrehexn8pBd4lcidjOKbVRi2cd/SuTQ fNyO+8TkixUa/czAyI4GikrMfOpN8JuAH9Au+ys8w2HZQSW3uypjPxzQ0VyQuielg6VX alg+kydyXHFYrMpma1rsmkP/TAoCcugwydAOCEElr7mjDy49c5gzu8Xu2iUVtbnBYhL1 t+xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pLlGk+cZ5H+bPN4ICXizwdh/rPzTm72DYXYeQwOXCr0=; b=LFZyy0gbD51ccp0bBo/dIUk9yhzgswpiEwcBGie2uwtOlJy6A1wswE2zeX8SesXVl4 n79o4gOwAr0HgwjNGr9RZcytSWloKkRcum1jGP9dtLB4aav3I6Q+bXo44naSJ4zoy8ZW wLVeQIyd4A76rTKQPOIO8EpY/WqggLBe+nEJsTtNp6NHwuCyHjayl/ZoDRUB3fKblv6A 7TrT45iCYtz1/4h78UNNuutog89MiTgBkGlTbL65GVnJrCtzmM8s9tq7XNquuPyKfb3/ ZI5DB9GqJ/B57JuXd7rWV3PO1ip11515gzPnG9KFgSGEpiqsHrt0HQ9xPA7WaqJP+JmO cI6g== X-Gm-Message-State: AOAM53219GnNLvThBc3cSd374Xh4ILW0kobXSlwQA0ttPX31ElzUIn1l d/EqQFYYl6DA5tfgfyf2VBU= X-Received: by 2002:a5d:5083:: with SMTP id a3mr31111254wrt.93.1604494292254; Wed, 04 Nov 2020 04:51:32 -0800 (PST) Received: from [192.168.8.114] ([37.172.5.208]) by smtp.gmail.com with ESMTPSA id c18sm2330160wrt.10.2020.11.04.04.51.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 04:51:31 -0800 (PST) Subject: Re: [PATCH 1/1] mm: avoid re-using pfmemalloc page in page_frag_alloc() To: Matthew Wilcox , Eric Dumazet Cc: Rama Nichanamatlu , Dongli Zhang , linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, davem@davemloft.net, kuba@kernel.org, aruna.ramakrishna@oracle.com, bert.barbe@oracle.com, venkat.x.venkatsubra@oracle.com, manjunath.b.patil@oracle.com, joe.jin@oracle.com, srinivas.eeda@oracle.com References: <20201103193239.1807-1-dongli.zhang@oracle.com> <20201103203500.GG27442@casper.infradead.org> <7141038d-af06-70b2-9f50-bf9fdf252e22@oracle.com> <20201103211541.GH27442@casper.infradead.org> <20201104011640.GE2445@rnichana-ThinkPad-T480> <2bce996a-0a62-9d14-4310-a4c5cb1ddeae@gmail.com> <20201104123659.GA17076@casper.infradead.org> From: Eric Dumazet Message-ID: <053d1d51-430a-2fa9-fb72-fee5d2f9785c@gmail.com> Date: Wed, 4 Nov 2020 13:51:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20201104123659.GA17076@casper.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/4/20 1:36 PM, Matthew Wilcox wrote: > On Wed, Nov 04, 2020 at 09:50:30AM +0100, Eric Dumazet wrote: >> On 11/4/20 2:16 AM, Rama Nichanamatlu wrote: >>>> Thanks for providing the numbers.  Do you think that dropping (up to) >>>> 7 packets is acceptable? >>> >>> net.ipv4.tcp_syn_retries = 6 >>> >>> tcp clients wouldn't even get that far leading to connect establish issues. >> >> This does not really matter. If host was under memory pressure, >> dropping a few packets is really not an issue. >> >> Please do not add expensive checks in fast path, just to "not drop a packet" >> even if the world is collapsing. > > Right, that was my first patch -- to only recheck if we're about to > reuse the page. Do you think that's acceptable, or is that still too > close to the fast path? I think it is totally acceptable. The same strategy is used in NIC drivers, before recycling a page. If page_is_pfmemalloc() returns true, they simply release the 'problematic'page and attempt a new allocation. ( git grep -n page_is_pfmemalloc -- drivers/net/ethernet/ ) > >> Also consider that NIC typically have thousands of pre-allocated page/frags >> for their RX ring buffers, they might all have pfmemalloc set, so we are speaking >> of thousands of packet drops before the RX-ring can be refilled with normal (non pfmemalloc) page/frags. >> >> If we want to solve this issue more generically, we would have to try >> to copy data into a non pfmemalloc frag instead of dropping skb that >> had frags allocated minutes ago under memory pressure. > > I don't think we need to copy anything. We need to figure out if the > system is still under memory pressure, and if not, we can clear the > pfmemalloc bit on the frag, as in my second patch. The 'least change' > way of doing that is to try to allocate a page, but the VM could export > a symbol that says "we're not under memory pressure any more". > > Did you want to move checking that into the networking layer, or do you > want to keep it in the pagefrag allocator? I think your proposal is fine, thanks !