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 3D8FEC4727E for ; Tue, 29 Sep 2020 03:40:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 124E3207F7 for ; Tue, 29 Sep 2020 03:40:35 +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="gmBHydwM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 124E3207F7 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 23AE16B005C; Mon, 28 Sep 2020 23:40:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C4536B005D; Mon, 28 Sep 2020 23:40:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0657C8E0001; Mon, 28 Sep 2020 23:40:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id E016B6B005C for ; Mon, 28 Sep 2020 23:40:34 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9FDF94DB6 for ; Tue, 29 Sep 2020 03:40:34 +0000 (UTC) X-FDA: 77314696788.12.silk47_1a0d98727187 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 7EB3B180150E1 for ; Tue, 29 Sep 2020 03:40:34 +0000 (UTC) X-HE-Tag: silk47_1a0d98727187 X-Filterd-Recvd-Size: 3048 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 03:40:34 +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=wuFwP1VtH4477YyK4VY8voDgPxxA0zd1F5q5JPQFuM8=; b=gmBHydwMAmNWN1EeYBh4AKHXw/ AvBy+m69Ai3to+r6gqo0bG6rUFr09L48lr7v18UEH7W7fmJl56BXc1BIHPjtjO3P9gPzctJ09seBk k1+nPzTYQJBm2ISavuSSV3a2UoDHWSANYN1OQrq18Oyaao3v+52pMgJEZG8t8xI3gAjUEhsY9fwX8 iv3DoAsAmwCVQ5wh21/SYJLVIVV1qEX3l2t3UilMqdaJ7wlok84ZsSpUhCrLYPe0wnOlMXnRYqPkG 2YOjc9n1r2CH1iKMOxlrbgXwsY4OqNlCD48PFO2YEvlKZvF7u2R/Hq0IT4MH24UcG5dbHbHxMu2fp g/v3As/w==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kN6V8-0002yQ-54; Tue, 29 Sep 2020 03:40:26 +0000 Date: Tue, 29 Sep 2020 04:40:26 +0100 From: Matthew Wilcox To: Andrew Morton Cc: Nick Piggin , Hugh Dickins , Peter Zijlstra , linux-mm@kvack.org, linux-kernel@vger.kernel.org, hch@lst.de, rppt@linux.ibm.com, rdunlap@infradead.org Subject: Re: [PATCH v2] page_alloc: Fix freeing non-compound pages Message-ID: <20200929034026.GA20115@casper.infradead.org> References: <20200926213919.26642-1-willy@infradead.org> <20200928180307.7573f3b6128b5e3007dfc9f0@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200928180307.7573f3b6128b5e3007dfc9f0@linux-foundation.org> 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 Mon, Sep 28, 2020 at 06:03:07PM -0700, Andrew Morton wrote: > Well that's weird and scary looking. `page' has non-zero refcount yet > we go and free random followon pages. Methinks it merits an > explanatory comment? Here's some kernel-doc. Opinions? /** * __free_pages - Free pages allocated with alloc_pages(). * @page: The page pointer returned from alloc_pages(). * @order: The order of the allocation. * * This function differs from put_page() in that it can free multi-page * allocations that were not allocated with %__GFP_COMP. This function * does not check that the @order passed in matches that of the * allocation, so it is possible to leak memory. Freeing more memory than * was allocated will probably be warned about by other debugging checks. * * It is only safe to use the page reference count to determine when * to free an allocation if you use %__GFP_COMP (in which case, you may * as well use put_page() to free the page). Another thread may have a * speculative reference to the first page, but it has no way of knowing * about the rest of the allocation, so we have to free all but the * first page here. * * Context: May be called in interrupt context but not NMI context. */