Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp246193rwb; Tue, 6 Dec 2022 20:30:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5VDWdmnOI92imXzK7i+h42R/p/Nu8/dyHELMeBOyMlDAeTmwYbyUkPVygEGOF8jqEVeS4o X-Received: by 2002:a05:6a00:440b:b0:56b:b53f:e887 with SMTP id br11-20020a056a00440b00b0056bb53fe887mr72716015pfb.3.1670387417080; Tue, 06 Dec 2022 20:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670387417; cv=none; d=google.com; s=arc-20160816; b=aSrCf+tvMl3+YP/d492MT4hVUiXmmQl6VlM44rhsQ1iomoemGCsXx8P5LmrXczwxho F1LYjKW/qnKKh8LnF/y8C7SyJKH6rKxVc5jay0Qy9slK9N+VRHF+/w2Lz5Im0G4fYSwP VysONg1u0B2/o/VNMRpRJnzkou/E9nK+FNIPdlavFgPtfbCk0H9K/uV6qG6/r9XlMQRc SchyeXP4KLLttStJOYX8Gc5WFXEZ38/8bwawQeor4LUvOfdbB8EMWfKoXLHNy0LW6p1U a/imsOccqy5+hjvEUfUeJjrfqh8+IdvXODBq7UPs5lkWvEwsAexMdvwsW+7HcvlznouT yxaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=k4i3NqzvNgLLOzXJhJCK2qX1KHILXyG9rywWTvTCb8A=; b=g9gSraxYOI527VJwUAY9OAA0stg6JV2nIEY6gkv1lKeHzmWI9PgbJxCd8OxHzFVtiX NlwfjGGi6RznEjQt/z/cnPFnYO0T8U/bB7gqH70r7YfgWHGD+cV7VPD1M+6VQyPxiGv9 3v7s3oxIUCnCeiLm6xEMOUXleG551IoIuo1XvWuOv5dX+zFwgvnRphhg7rTV3hmDipFB hycOeDmoNScuPOcyNmLbVWswafteDzyZTm7FZfZLqazsTrwL7qaHgFYyTsml5V1yyEzz RShDp1xGqO+eE/SKLo5KVu7NBBjHo2OmPLJkqeUsIZ4GcPOHnlXjcEYgIgqaBcAYwv2K Yzcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qmC7lv40; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s25-20020a632159000000b004785a1141cbsi19417540pgm.485.2022.12.06.20.30.07; Tue, 06 Dec 2022 20:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qmC7lv40; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbiLGDez (ORCPT + 77 others); Tue, 6 Dec 2022 22:34:55 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 > +} > +