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 6DC22C00A89 for ; Thu, 5 Nov 2020 12:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BC382151B for ; Thu, 5 Nov 2020 12:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727275AbgKEMJR (ORCPT ); Thu, 5 Nov 2020 07:09:17 -0500 Received: from mx2.suse.de ([195.135.220.15]:34550 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726777AbgKEMJR (ORCPT ); Thu, 5 Nov 2020 07:09:17 -0500 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 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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; > >