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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 59B9FC433ED for ; Fri, 14 May 2021 11:48:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D4AE061458 for ; Fri, 14 May 2021 11:48:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4AE061458 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3C5486B0036; Fri, 14 May 2021 07:48:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 375806B006E; Fri, 14 May 2021 07:48:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 216A86B0070; Fri, 14 May 2021 07:48:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id E44956B0036 for ; Fri, 14 May 2021 07:48:04 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7E7F08249980 for ; Fri, 14 May 2021 11:48:04 +0000 (UTC) X-FDA: 78139662888.34.817B14B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id EFF8240002CE for ; Fri, 14 May 2021 11:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PMuhz7QmjDyUOOcCUlm1J8zGgwrLL0mcmdhwYH7Afe4=; b=QvCrTZ5Ysk4eK80ekakeQIJB79 t30kKv+swkuk0a/ARhDHBg0cHciJXU5odZ7+irtsvrNLcSbXxJ2HpM5PzJPkRMChDEBrp0hsc6g/+ N55Blbv9fdSv6W3TUgZtV0xFVqq2dGIAPt27vKf4Nm7C+hJpQw/PajoVUV3ANcadqDEKclSp7PiLg ZRX8vLW97ctsKogImgPm1mlpOgjFQ+3h0YrkabYCArd310ucDrDTdR09UUn++gwG91ms0moHDDAlX rfXMPqh5JhyW92MYGKy9hlmPvkLDYWIkgg4gyBNpHYvQn6xj4qB4rSNl24JcnX1rNp/n1Lue316hx Fydl24rg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lhWHV-00AKdf-Fe; Fri, 14 May 2021 11:47:18 +0000 Date: Fri, 14 May 2021 12:47:01 +0100 From: Matthew Wilcox To: Vlastimil Babka Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jeff Layton Subject: Re: [PATCH v10 01/33] mm: Introduce struct folio Message-ID: References: <20210511214735.1836149-1-willy@infradead.org> <20210511214735.1836149-2-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: EFF8240002CE Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QvCrTZ5Y; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam04 X-Stat-Signature: dewmca7ek6f6rmorzni4h41wd7oo7wby X-HE-Tag: 1620992883-715742 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 Fri, May 14, 2021 at 12:40:05PM +0200, Vlastimil Babka wrote: > On 5/11/21 11:47 PM, Matthew Wilcox (Oracle) wrote: > > +/** > > + * folio_page - Return a page from a folio. > > + * @folio: The folio. > > + * @n: The page number to return. > > + * > > + * @n is relative to the start of the folio. It should be between > > + * 0 and folio_nr_pages(@folio) - 1, but this is not checked for. > > + */ > > +#define folio_page(folio, n) nth_page(&(folio)->page, n) > > BTW, would it make sense to have also a folio_page(folio) wrapper? Or is > "&folio->page" used in later patches sufficiently elegant and stable enough for > the future? Ah! If you see &folio->page in a patch, it's "a bad smell" [1]. At this stage, it probably indicates "This other thing I need isn't converted entirely to folios yet". I consider it fine in implementations of utility functions like this: +static inline unsigned int folio_order(struct folio *folio) +{ + return compound_order(&folio->page); +} but when we see it here: +void folio_unlock(struct folio *folio) { BUILD_BUG_ON(PG_waiters != 7); - page = compound_head(page); - VM_BUG_ON_PAGE(!PageLocked(page), page); - if (clear_bit_unlock_is_negative_byte(PG_locked, &page->flags)) - wake_up_page_bit(page, PG_locked); + VM_BUG_ON_FOLIO(!folio_locked(folio), folio); + if (clear_bit_unlock_is_negative_byte(PG_locked, folio_flags(folio, 0))) + wake_up_page_bit(&folio->page, PG_locked); } that's an indication that wake_up_page_bit() needs to be converted to folio_wake_bit(), which happens in a later patch. I could probably avoid this temporary problem with a different ordering of the patches, but it's not clear to me that's a good use of my time. The existing folio_page() is a way of distinguishing between "this function i need to call doesn't have a folio equivalent yet" and "this function i need to call needs to deal specifically with one page in this folio". For the former, use &folio->page; for the latter, use folio_page() or folio_file_page(). [1] https://en.wikipedia.org/wiki/Code_smell