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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 85F3DC5DF9D for ; Thu, 5 Nov 2020 12:06:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6504422243 for ; Thu, 5 Nov 2020 12:06:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="veqZpURn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6504422243 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 807576B00F5; Thu, 5 Nov 2020 07:06:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B8816B00F6; Thu, 5 Nov 2020 07:06:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F4AD6B00F7; Thu, 5 Nov 2020 07:06:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2AFF86B00F5 for ; Thu, 5 Nov 2020 07:06:03 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C46E5181AC9CC for ; Thu, 5 Nov 2020 12:06:02 +0000 (UTC) X-FDA: 77450236164.14.view45_5e1404e272c9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 9C1AF18229818 for ; Thu, 5 Nov 2020 12:06:02 +0000 (UTC) X-HE-Tag: view45_5e1404e272c9 X-Filterd-Recvd-Size: 2925 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 12:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CRdjjbC6ta204KKisbGTc+8ducfw9SLJz/rtqPEhUcI=; b=veqZpURnKhUSYBpP+xOVgM5T3J vOS0stJpgC2YBhA9WijRTyRhuokLcI75f1HnvFuNPh3wJpi6xFrHB3F33HpMCWnvQLuWIDuOhKBhN qTFw2C4AxmgoGeIId5WzyjI1hU/YetnT7aGSHs2cnXysLxb257QuIzlxOdREE4PlUV0wccy5vYFTr HBXPNh44vq3O8GKQAdbTGk/s2uooNaOYssIu3ioV4iu7DeC7y/FgNCdddTZWodJJ6JIXm3PqTGQJU iYTNTlxW7PsnJY3IGDAwDotKhtqZY+pkuB84vr4KCxdLzk0/h0gE/Y8EE5+YVbT6jZUjz+EReVx21 eRZl8S8A==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kae1a-0004aX-Qo; Thu, 05 Nov 2020 12:05:55 +0000 Date: Thu, 5 Nov 2020 12:05:54 +0000 From: Matthew Wilcox To: Vlastimil Babka 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 Subject: Re: [PATCH] page_frag: Recover from memory pressure Message-ID: <20201105120554.GJ17076@casper.infradead.org> References: <20201105042140.5253-1-willy@infradead.org> <83d68f28-cae7-012d-0f4b-82960b248bd8@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83d68f28-cae7-012d-0f4b-82960b248bd8@suse.cz> X-Bogosity: Ham, tests=bogofilter, spamicity=0.001661, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 ... if (unlikely(!page)) page = alloc_pages_node(NUMA_NO_NODE, gfp, 0); nc->va = page ? page_address(page) : NULL;