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.6 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 03FB0C4346E for ; Tue, 22 Sep 2020 03:12:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F3C8F23A32 for ; Tue, 22 Sep 2020 03:12:20 +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="d34MmqRK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3C8F23A32 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 C8ABA90001C; Mon, 21 Sep 2020 23:12:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C3C29900012; Mon, 21 Sep 2020 23:12:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B51E890001C; Mon, 21 Sep 2020 23:12:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 9C3D6900012 for ; Mon, 21 Sep 2020 23:12:19 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 59056180AD802 for ; Tue, 22 Sep 2020 03:12:19 +0000 (UTC) X-FDA: 77289223998.12.bikes58_0711e842714a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 339A018010DA0 for ; Tue, 22 Sep 2020 03:12:19 +0000 (UTC) X-HE-Tag: bikes58_0711e842714a X-Filterd-Recvd-Size: 2201 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 03:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=h0Wt1nZ5tXLUvhFoOuxEASr/8rsQ9oAWPb9vAv0G31M=; b=d34MmqRKwkWKmc/GD5DLdgwPi+ UOatbrDDhwaWPntS5E5vChS5j7vs0Fhk6TVGRJS6e+sVmhPc96EYW/wignyY9aO9f8a2XNq2Ke0YO A1qqv7vtnEJDynK1eBhPcPcBUx8svvsmiGuxT6y/uVAwFORnolgjd6WEWcfp4Qj77usTiL6sVioIr m3COQb/kcNBmlsUuoMqOSN9FPO5zM6iDfxFaAnsdswth0+cls6K9rbWM8NklvPuSjBxpso9kYHRx3 1992ccAxD5JZYBQgSGPFbAVFpA1y9lx23pUTCSTwhbgzWbXF7+p5Y2veOEsdkbIkvEdb3H+SixPNc q87AB7Bw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKYj1-0001w1-CK for linux-mm@kvack.org; Tue, 22 Sep 2020 03:12:15 +0000 Date: Tue, 22 Sep 2020 04:12:15 +0100 From: Matthew Wilcox To: linux-mm@kvack.org Subject: Rare memory leakage Message-ID: <20200922031215.GZ32101@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Bogosity: Ham, tests=bogofilter, spamicity=0.000377, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This is a fun little race. Dramatis personae: Pages P0, P1 are consecutive and aligned. Threads A, B, C. Page P0 is allocated to the page cache. Page P1 is free. Thread A calls find_get_entry() P0 is returned from xas_load() Thread B removes the page from the page cache (eg truncate, invalidatepage). P0 is buddy-merged with P1. Thread C calls alloc_pages, order 1, does not specify GFP_COMP. P0 now has refcount 1. Thread A calls page_cache_get_speculative(). P0 has refcount 2. Thread C calls __free_page(P0, 1) put_page_testzero is _false_. Do not call free_the_page(). Thread A calls put_page(P0) We free P0 and nobody knows to free P1. Weird solution: In __free_page(), if put_page_testzero() fails and page is not PageHead, convert it to a compound page. Then the put_page() by Thread A will free P1. Better ideas?