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=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 37BA0C4742C for ; Thu, 5 Nov 2020 11:56:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7BE6C206F4 for ; Thu, 5 Nov 2020 11:56:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BE6C206F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A11476B00F3; Thu, 5 Nov 2020 06:56:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 99BA56B00F4; Thu, 5 Nov 2020 06:56:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 863526B00F5; Thu, 5 Nov 2020 06:56:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 592716B00F3 for ; Thu, 5 Nov 2020 06:56:46 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 011B1181AC9CB for ; Thu, 5 Nov 2020 11:56:46 +0000 (UTC) X-FDA: 77450212812.20.train99_4a0381f272c9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id D01B1180C07AF for ; Thu, 5 Nov 2020 11:56:45 +0000 (UTC) X-HE-Tag: train99_4a0381f272c9 X-Filterd-Recvd-Size: 3515 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 11:56:45 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D880EAF26; Thu, 5 Nov 2020 11:56:43 +0000 (UTC) To: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, netdev@vger.kernel.org, Dongli Zhang Cc: Aruna Ramakrishna , Bert Barbe , Rama Nichanamatlu , Venkat Venkatsubra , Manjunath Patil , Joe Jin , SRINIVAS , stable@vger.kernel.org, Jann Horn References: <20201105042140.5253-1-willy@infradead.org> From: Vlastimil Babka Subject: Re: [PATCH] page_frag: Recover from memory pressure Message-ID: <83d68f28-cae7-012d-0f4b-82960b248bd8@suse.cz> Date: Thu, 5 Nov 2020 12:56:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201105042140.5253-1-willy@infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed 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/5/20 5:21 AM, Matthew Wilcox (Oracle) wrote: > When the machine is under extreme memory pressure, the page_frag alloca= tor > signals this to the networking stack by marking allocations with the > 'pfmemalloc' flag, which causes non-essential packets to be dropped. > Unfortunately, even after the machine recovers from the low memory > condition, the page continues to be used by the page_frag allocator, > so all allocations from this page will continue to be dropped. > > Fix this by freeing and re-allocating the page instead of recycling i= t. >=20 > Reported-by: Dongli Zhang > Cc: Aruna Ramakrishna > Cc: Bert Barbe > Cc: Rama Nichanamatlu > Cc: Venkat Venkatsubra > Cc: Manjunath Patil > Cc: Joe Jin > Cc: SRINIVAS > Cc: stable@vger.kernel.org > Fixes: 79930f5892e ("net: do not deplete pfmemalloc reserve") > Signed-off-by: Matthew Wilcox (Oracle) > --- > mm/page_alloc.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 778e815130a6..631546ae1c53 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -5139,6 +5139,10 @@ void *page_frag_alloc(struct page_frag_cache *nc= , > =20 > if (!page_ref_sub_and_test(page, nc->pagecnt_bias)) > goto refill; > + if (nc->pfmemalloc) { > + free_the_page(page, compound_order(page)); > + goto refill; Theoretically the refill can fail and we return NULL while leaving nc->va= =20 pointing to a freed page, so I think you should set nc->va to NULL. Geez, can't the same thing already happen after we sub the nc->pagecnt_bi= as from=20 page ref, and last users of the page fragments then return them and dec t= he ref=20 to zero and the page gets freed? > + } > =20 > #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE) > /* if size can vary use size else just use PAGE_SIZE */ >=20