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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 3B0CDC433E0 for ; Wed, 13 Jan 2021 13:54:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 945112339D for ; Wed, 13 Jan 2021 13:54:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 945112339D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D027D8D005A; Wed, 13 Jan 2021 08:54:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CD99F8D0059; Wed, 13 Jan 2021 08:54:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C16708D005A; Wed, 13 Jan 2021 08:54:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id AA1318D0059 for ; Wed, 13 Jan 2021 08:54:48 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 72EC8180AD81F for ; Wed, 13 Jan 2021 13:54:48 +0000 (UTC) X-FDA: 77700897456.18.rod51_2d180ee2751e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 52BFE100ED3DF for ; Wed, 13 Jan 2021 13:54:48 +0000 (UTC) X-HE-Tag: rod51_2d180ee2751e X-Filterd-Recvd-Size: 3842 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 13:54:47 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9664DAC24; Wed, 13 Jan 2021 13:54:46 +0000 (UTC) Date: Wed, 13 Jan 2021 14:54:44 +0100 From: Oscar Salvador To: Mike Kravetz Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Naoya Horiguchi , Muchun Song , David Hildenbrand , Andrew Morton Subject: Re: [RFC PATCH 1/3] hugetlb: use page.private for hugetlb specific page flags Message-ID: <20210113135439.GA29271@linux> References: <20210111210152.118394-1-mike.kravetz@oracle.com> <20210111210152.118394-2-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210111210152.118394-2-mike.kravetz@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Mon, Jan 11, 2021 at 01:01:50PM -0800, Mike Kravetz wrote: > As hugetlbfs evolved, state information about hugetlb pages was added. > One 'convenient' way of doing this was to use available fields in tail > pages. Over time, it has become difficult to know the meaning or contents > of fields simply be looking at a small bit of code. Sometimes, the > naming is just confusing. For example: The PagePrivate flag indicates > a huge page reservation was consumed and needs to be restored if an error > is encountered and the page is freed before it is instantiated. The > page.private field contains the pointer to a subpool if the page is > associated with one. > > In an effort to make the code more readable, use page.private to contain > hugetlb specific flags. These flags will have test, set and clear functions > similar to those used for 'normal' page flags. More importantly, the > flags will have names which actually reflect their purpose. > > In this patch, > - Create infrastructure for huge page flag functions > - Move subpool pointer to page[1].private to make way for flags > Create routines with meaningful names to modify subpool field > - Use new HPageRestoreReserve reserve flag instead of PagePrivate > > Conversion of other state information will happen in subsequent patches. I like this idea, it would make the code much easier to follow, and together with Muchun's gathering indiscrete index hugetlb code will start looking less scarier. I do have a question below: > +enum htlb_page_flags { > + HPAGE_RestoreReserve = 0, > +}; > + > +/* > + * Macros to create function definitions for hpage flags > + */ > +#define TESTHPAGEFLAG(flname) \ > +static inline int HPage##flname(struct page *page) \ > + { return test_bit(HPAGE_##flname, &(page->private)); } > + > +#define SETHPAGEFLAG(flname) \ > +static inline void SetHPage##flname(struct page *page) \ > + { set_bit(HPAGE_##flname, &(page->private)); } > + > +#define CLEARHPAGEFLAG(flname) \ > +static inline void ClearHPage##flname(struct page *page) \ > + { clear_bit(HPAGE_##flname, &(page->private)); } > + > +#define HPAGEFLAG(flname) \ > + TESTHPAGEFLAG(flname) \ > + SETHPAGEFLAG(flname) \ > + CLEARHPAGEFLAG(flname) > + > +HPAGEFLAG(RestoreReserve) I have mixed feelings about this. Could we have a single function that sets/clears the bit/flag? e.g: static inline void hugetlb_set_flag(struct page *p, page_flag) { set_bit(flag, &(page->private)); } etc. It would look less of an overkill? -- Oscar Salvador SUSE L3