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=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 75DC9C55179 for ; Tue, 27 Oct 2020 19:05:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0020521527 for ; Tue, 27 Oct 2020 19:05:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="S7rZgB2r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0020521527 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7C6E06B0074; Tue, 27 Oct 2020 15:05:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 777CA6B0075; Tue, 27 Oct 2020 15:05:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F0236B0078; Tue, 27 Oct 2020 15:05:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id 30F0B6B0074 for ; Tue, 27 Oct 2020 15:05:42 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BEFEB3626 for ; Tue, 27 Oct 2020 19:05:40 +0000 (UTC) X-FDA: 77418634440.09.soda45_560a3952727e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 3F378180AD80F for ; Tue, 27 Oct 2020 19:05:40 +0000 (UTC) X-HE-Tag: soda45_560a3952727e X-Filterd-Recvd-Size: 5345 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 19:05:37 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09RIsWkI111613; Tue, 27 Oct 2020 19:05:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2020-01-29; bh=755FeKlzmrdomlcY8XkliWcjb6gmyG9afG/PXmJwJRM=; b=S7rZgB2rVKOmww7s6AESSDK7GOyGZcnMTf6oRCrOr/Am0bhWNlG4KY6PFjj0Ah/uCpUs rPAnNoCQ0da8KGwrn141cV1Dr+BvBs33QRISpKFk8hYrOAdaaYNZgV2CjngaX29iwIhJ hsft2DRGjDJWKeDEo4+mWi45jJQ6JXESuq+3YQh5EKLIC9hkkuYEi5iMH1UwXJV3jCvr kOrovD+yhPVejFmZb1bdLIQvxx+YYsavQxRcLTdMz3t/5MmBPiCISXRlOzgxtC0cbfXH LIBLEL1xDRbjz34VsqCwKNcNauPu4Lsb67Wvi7JJRvGkbwZx9toeguO5AfvPdQ8ozZTr EA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 34dgm41fft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 27 Oct 2020 19:05:31 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09RItLZm020077; Tue, 27 Oct 2020 19:03:31 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 34cx6wbnfw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2020 19:03:31 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 09RJ3UoM001696; Tue, 27 Oct 2020 19:03:30 GMT Received: from [192.168.0.110] (/73.243.10.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 27 Oct 2020 12:03:29 -0700 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.0.3.2.82\)) Subject: Re: [PATCH] mm/page_alloc: Add __free_pages documentation From: William Kucharski In-Reply-To: <20201027025523.3235-1-willy@infradead.org> Date: Tue, 27 Oct 2020 13:03:28 -0600 Cc: linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Message-Id: <3110137D-97A5-4FC6-B5C3-B6BFD07D069A@oracle.com> References: <20201027025523.3235-1-willy@infradead.org> To: "Matthew Wilcox (Oracle)" X-Mailer: Apple Mail (2.3654.0.3.2.82) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9787 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010270110 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9787 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 impostorscore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=2 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010270110 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: I like the explanation. Reviewed-by: William Kucharski > On Oct 26, 2020, at 8:55 PM, Matthew Wilcox (Oracle) = wrote: >=20 > Provide some guidance towards when this might not be the right = interface > to use. >=20 > Signed-off-by: Matthew Wilcox (Oracle) > --- > mm/page_alloc.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) >=20 > 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); > } >=20 > +/** > + * __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)) > --=20 > 2.28.0 >=20 >=20