Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3491492pxk; Mon, 28 Sep 2020 20:43:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhj50/uhDCl4vkuXcv0FWIhfGxmkPzQqgXq0iFxcZT0YK+v1+RRiOqAB3EIEEvmf6Fw7Rn X-Received: by 2002:aa7:c387:: with SMTP id k7mr1098761edq.242.1601351006218; Mon, 28 Sep 2020 20:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601351006; cv=none; d=google.com; s=arc-20160816; b=BPO7VB2UMyJfExA4TVQBPSNGIEYu4woFTQBdWhvVEAy8m3ebAoXHx1ylrYrgFtS5g1 q8nKfKu7cDIfvACSskyO5rUa+NlAAbVy+hZ6GEEd2QLvmInPM8AAjk1sQU1VmSr+rgRV r4/iCmtBgPZiM3YjNouG7UaU87UvHYv6NJDrOijNwIhQYiC3QcwCAKgwhNXHXi93qx6d Ej6kdUxeDXNUz7NYCx1YOYIKiF14vXrxRUhBPjukC5oo5SFAQF/klZK04eB+N+/zbwiI JNAOPfVtYCti/eB/DDPuiQCBziArJ2Ztzgl1FgSOCa8PqTLzkU2pdWvc9corL9sksvof hf3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wuFwP1VtH4477YyK4VY8voDgPxxA0zd1F5q5JPQFuM8=; b=KWyJdl8JAb2E6A1M0Ed1uXlPCJ/4c8ySDm/QH57A39UDCuZu1p1sujdjMirYEvP6f8 5mxOAnLaK4rTQHUNMi0DWWkfKYUdpi6r4kNKoJVzdtFW9BBrw2HF4tkm9wQFwtkL137F AJocfJOuQJhLyb8+Hv8dudbQECHVEZeyYdnGXfMEN9rSO1LkotrcEWIg7aX2hb1SiZpy 2NbilCtnlaXu4qyYR9WYVO2NbygEk25dvfutnNI9NND7SE2I3m+L+3aCDYI3WMbM/eIs 0cRHvXDmQNCWM9VU0qVZhHJJ1hZU1cffMQZQ3jmNEbH4DCwtJQ4cE7U/1C1gASARCABK HV6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gmBHydwM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si2079748edy.251.2020.09.28.20.42.51; Mon, 28 Sep 2020 20:43:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gmBHydwM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727331AbgI2Dkc (ORCPT + 99 others); Mon, 28 Sep 2020 23:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbgI2Dkc (ORCPT ); Mon, 28 Sep 2020 23:40:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FD36C061755 for ; Mon, 28 Sep 2020 20:40:32 -0700 (PDT) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. */