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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19BA2C352A1 for ; Wed, 7 Dec 2022 03:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbiLGDe4 (ORCPT ); Tue, 6 Dec 2022 22:34:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbiLGDex (ORCPT ); Tue, 6 Dec 2022 22:34:53 -0500 Received: from out-101.mta0.migadu.com (out-101.mta0.migadu.com [91.218.175.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 700F2554F7 for ; Tue, 6 Dec 2022 19:34:52 -0800 (PST) Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1670384088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k4i3NqzvNgLLOzXJhJCK2qX1KHILXyG9rywWTvTCb8A=; b=qmC7lv40Mfq0jF+qtrceU5586th75q2MNlPTDgNdm5fv2HRn2tnhdUydqq8G1i+CeYZi6a la3cDX/xZpfr2/19O7J8R9oeHZaC68qZqbslAs5LMxEKPV4da1hUMdLdApDVrqNDHcQqb1 q8H95CIbNRn7XGWZ30pkXa2JF5ZQbPU= Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.200.110.1.12\)) Subject: Re: [PATCH mm-unstable v5 01/10] mm: add folio dtor and order setter functions X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20221129225039.82257-2-sidhartha.kumar@oracle.com> Date: Wed, 7 Dec 2022 11:34:31 +0800 Cc: linux-kernel@vger.kernel.org, Linux Memory Management List , Andrew Morton , Muchun Song , Mike Kravetz , Matthew Wilcox , Mina Almasry , Miaohe Lin , hughd@google.com, tsahu@linux.ibm.com, jhubbard@nvidia.com, David Hildenbrand Content-Transfer-Encoding: quoted-printable Message-Id: References: <20221129225039.82257-1-sidhartha.kumar@oracle.com> <20221129225039.82257-2-sidhartha.kumar@oracle.com> To: Sidhartha Kumar X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Nov 30, 2022, at 06:50, Sidhartha Kumar = wrote: >=20 > Add folio equivalents for set_compound_order() and = set_compound_page_dtor(). >=20 > Also remove extra new-lines introduced by mm/hugetlb: convert > move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert > hugetlb_cgroup_uncharge_page() to folios. >=20 > Suggested-by: Mike Kravetz > Suggested-by: Muchun Song > Signed-off-by: Sidhartha Kumar > --- > include/linux/mm.h | 16 ++++++++++++++++ > mm/hugetlb.c | 4 +--- > 2 files changed, 17 insertions(+), 3 deletions(-) >=20 > diff --git a/include/linux/mm.h b/include/linux/mm.h > index a48c5ad16a5e..2bdef8a5298a 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct = page *page, > page[1].compound_dtor =3D compound_dtor; > } >=20 > +static inline void folio_set_compound_dtor(struct folio *folio, > + enum compound_dtor_id compound_dtor) > +{ > + VM_BUG_ON_FOLIO(compound_dtor >=3D NR_COMPOUND_DTORS, folio); > + folio->_folio_dtor =3D compound_dtor; > +} > + > void destroy_large_folio(struct folio *folio); >=20 > static inline int head_compound_pincount(struct page *head) > @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page = *page, unsigned int order) > #endif > } >=20 > +static inline void folio_set_compound_order(struct folio *folio, > + unsigned int order) > +{ > + folio->_folio_order =3D order; > +#ifdef CONFIG_64BIT > + folio->_folio_nr_pages =3D order ? 1U << order : 0; It seems that you think the user could pass 0 to order. However, ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 = pages. You should not touch it. So this should be: static inline void folio_set_compound_order(struct folio *folio, unsigned int order) { if (!folio_test_large(folio)) return; folio->_folio_order =3D order; #ifdef CONFIG_64BIT folio->_folio_nr_pages =3D 1U << order; #endif } If we can make sure all the users of folio_set_compound_order() should = pass a non-order-0 page (it is true for now), then I suggest adding a = VM_BUG_ON() here to catch unexpected users. static inline void folio_set_compound_order(struct folio *folio, unsigned int order) { VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); folio->_folio_order =3D order; #ifdef CONFIG_64BIT folio->_folio_nr_pages =3D 1U << order; #endif } Thanks. > +#endif > +} > +