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 X-Spam-Level: X-Spam-Status: No, score=-4.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62F6BC4741F for ; Wed, 4 Nov 2020 12:51:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BFEA422243 for ; Wed, 4 Nov 2020 12:51:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tk7tVGSa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFEA422243 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C33806B005D; Wed, 4 Nov 2020 07:51:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE24A6B006C; Wed, 4 Nov 2020 07:51:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAB706B006E; Wed, 4 Nov 2020 07:51:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id 7F0D26B005D for ; Wed, 4 Nov 2020 07:51:34 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1A1C78249980 for ; Wed, 4 Nov 2020 12:51:34 +0000 (UTC) X-FDA: 77446722108.03.sock55_0f05ab3272c1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id EF3FF28A4E9 for ; Wed, 4 Nov 2020 12:51:33 +0000 (UTC) X-HE-Tag: sock55_0f05ab3272c1 X-Filterd-Recvd-Size: 5881 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Nov 2020 12:51:33 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id 33so11120205wrl.7 for ; 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=pJzAz/uxfdVTH9hDa2JCj4+pfMF0RasppafzHOKcmcSradTT7pF7vW1FokpG+Bs++V bPnKL0woacV2/lWepNm1fx2R/HOlh9x+GANqA22yt9HWHyfmHdEYzRxdhOPRY9gMy/Md ZbgY7jgvoKevab4ej5DUvmO9G0jm233DYaZp8pKpKJY9ikOuSRdGzlSPlUy5EU7b6xiA gPuFyMy26wf9QVuj8UVaTX9+gYV0YwFX7MuHzD0yCopznmdttf/1Q/J/ABfDl4DIE5Vj GCYNmY3Ry80r8LNLEVKwZKEfmXIJZBJOc1Ue/7mCZC3K101i+r81CcNuE5pHbWH4/8wG fpIw== X-Gm-Message-State: AOAM532EE82vWYoRxdakEP+0P3SZEKXRAfD5vJp5rljU/ae2V1PlRM/H kvXttkyulmXSSgpn8OmkB7U= X-Google-Smtp-Source: ABdhPJzOQ0NRbvYHtqTnDIRsY8tJqtdseDoZpKi1RFjwxdMac8x7eWhLibNCb4s785rNtv6INKWLCQ== 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: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.=C2=A0 Do you think that dropping (= up to) >>>> 7 packets is acceptable? >>> >>> net.ipv4.tcp_syn_retries =3D 6 >>> >>> tcp clients wouldn't even get that far leading to connect establish i= ssues. >> >> 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 p= acket" >> even if the world is collapsing. >=20 > 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 'problemati= c'page and attempt a new allocation. ( git grep -n page_is_pfmemalloc -- drivers/net/ethernet/ ) >=20 >> 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 a= re speaking >> of thousands of packet drops before the RX-ring can be refilled with n= ormal (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. >=20 > 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". >=20 > 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 !