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=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 EF0C1C4363A for ; Wed, 28 Oct 2020 08:35:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 69E5F2464E for ; Wed, 28 Oct 2020 08:35:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="uDtpJ/JV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69E5F2464E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A23CB6B0068; Wed, 28 Oct 2020 04:35:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF286B006C; Wed, 28 Oct 2020 04:35:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D8F16B006E; Wed, 28 Oct 2020 04:35:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 439536B0068 for ; Wed, 28 Oct 2020 04:35:30 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D7C5B180AD807 for ; Wed, 28 Oct 2020 08:35:29 +0000 (UTC) X-FDA: 77420675178.24.soup73_5e0886327283 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id BF8441A4A0 for ; Wed, 28 Oct 2020 08:35:29 +0000 (UTC) X-HE-Tag: soup73_5e0886327283 X-Filterd-Recvd-Size: 3220 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Wed, 28 Oct 2020 08:35:29 +0000 (UTC) Received: from kernel.org (unknown [87.70.96.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 41A472463F; Wed, 28 Oct 2020 08:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603874128; bh=VdZ6RPspIwE2RdZPZCBBhwxtZPXnUkV8kkwMzmNK/YE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uDtpJ/JVvEHDI1KE80RM1DwlwPFRaOaZ+AzaUPh+us5vL3qrwKnRty5yfNBgtt9xF rAFgI+8sDx+5QfU+a6fq0zenG8KuMsL926ro2kY5xgcWeb8RQgkKOTxi9mslRioPji FmfOBnGsf7pmV2EB8ej+OGqrmRRmmFy28WWdxxKI= Date: Wed, 28 Oct 2020 10:35:22 +0200 From: Mike Rapoport To: "Matthew Wilcox (Oracle)" Cc: linux-mm@kvack.org Subject: Re: [PATCH] mm/page_alloc: Add __free_pages documentation Message-ID: <20201028083522.GB1428094@kernel.org> References: <20201027025523.3235-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027025523.3235-1-willy@infradead.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 Tue, Oct 27, 2020 at 02:55:23AM +0000, Matthew Wilcox (Oracle) wrote: > Provide some guidance towards when this might not be the right interface > to use. > > Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Mike Rapoport > --- > mm/page_alloc.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 23f5066bd4a5..e613177b8041 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -5007,6 +5007,26 @@ static inline void free_the_page(struct page *page, unsigned int order) > __free_pages_ok(page, order, FPI_NONE); > } > > +/** > + * __free_pages - Free pages allocated with alloc_pages(). > + * @page: The page pointer returned from alloc_pages(). > + * @order: The order of the allocation. > + * > + * This function can free multi-page allocations that are not compound > + * pages. It does not check that the @order passed in matches that of > + * the allocation, so it is easy to leak memory. Freeing more memory > + * than was allocated will probably emit a warning. > + * > + * If the last reference to this page is speculative, it will be released > + * by put_page() which only frees the first page of a non-compound > + * allocation. To prevent the remaining pages from being leaked, we free > + * the subsequent pages here. If you want to use the page's reference > + * count to decide when to free the allocation, you should allocate a > + * compound page, and use put_page() instead of __free_pages(). > + * > + * Context: May be called in interrupt context or while holding a normal > + * spinlock, but not in NMI context or while holding a raw spinlock. > + */ > void __free_pages(struct page *page, unsigned int order) > { > if (put_page_testzero(page)) > -- > 2.28.0 > > -- Sincerely yours, Mike.