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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 25CC8C388F7 for ; Thu, 5 Nov 2020 12:09:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9EB412151B for ; Thu, 5 Nov 2020 12:09:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EB412151B 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 173126B00FB; Thu, 5 Nov 2020 07:09:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 124106B00FC; Thu, 5 Nov 2020 07:09:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 012A36B00FD; Thu, 5 Nov 2020 07:09:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id CA0C56B00FB for ; Thu, 5 Nov 2020 07:09:17 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 65CB1362A for ; Thu, 5 Nov 2020 12:09:17 +0000 (UTC) X-FDA: 77450244354.19.bike57_5508975272c9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 46F5E1AD1B4 for ; Thu, 5 Nov 2020 12:09:17 +0000 (UTC) X-HE-Tag: bike57_5508975272c9 X-Filterd-Recvd-Size: 2686 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 12:09:16 +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 B0829AB95; Thu, 5 Nov 2020 12:09:15 +0000 (UTC) Subject: Re: [PATCH] page_frag: Recover from memory pressure To: Matthew Wilcox Cc: linux-mm@kvack.org, netdev@vger.kernel.org, Dongli Zhang , 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> <83d68f28-cae7-012d-0f4b-82960b248bd8@suse.cz> <20201105120554.GJ17076@casper.infradead.org> From: Vlastimil Babka Message-ID: Date: Thu, 5 Nov 2020 13:09:15 +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: <20201105120554.GJ17076@casper.infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 1:05 PM, Matthew Wilcox wrote: > On Thu, Nov 05, 2020 at 12:56:43PM +0100, Vlastimil Babka wrote: >> > +++ b/mm/page_alloc.c >> > @@ -5139,6 +5139,10 @@ void *page_frag_alloc(struct page_frag_cache *nc, >> > 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 >> 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_bias >> from page ref, and last users of the page fragments then return them and dec >> the ref to zero and the page gets freed? > > I don't think you read __page_frag_cache_refill() closely enough ... Or rather not at all, sorry :) somehow I just saw "ah here we call the page allocator". Acked-by: Vlastimil Babka > > if (unlikely(!page)) > page = alloc_pages_node(NUMA_NO_NODE, gfp, 0); > > nc->va = page ? page_address(page) : NULL; > >