Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp596027pxj; Fri, 14 May 2021 10:43:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM/yz8+zp2hw1dWXPO4KfToLy4xng1232Et44ikPdEoBxMedEjXrklbZsHgNtmQKcRSCj0 X-Received: by 2002:a17:907:f81:: with SMTP id kb1mr50726670ejc.476.1621014225659; Fri, 14 May 2021 10:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621014225; cv=none; d=google.com; s=arc-20160816; b=P7CYBG7vJgvWPCHnOaX7YnMIzKDo10KxJvwrNi5g3/8yFZ38jizmCQ/DDfrcy+fu/6 hESgituXxtSgW3ectkMlYAUE5w3LfBYCAz9dOTAirowsTEd+QOJUjJ2wKX/yUPijCOhq k6fec1hF48VcAp+Wh9/wXrCG9y4VcCRrpGq7UWqqJFsFEFnRyVTwbHaWt2EZdszRuRUt l91jxjpS5E2Pnu0zpjGUmFC8LRTTGZOpFLCB9IJBpVFPNM5rbmDRjOhTMvn4cA7v8jG6 lM6HGkYH8n4Xw46qT0hcTksChDqaLfjiZZGEbSmXBZ8YngmjbkCSu9b1Vh2+bEvm6914 19pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PMuhz7QmjDyUOOcCUlm1J8zGgwrLL0mcmdhwYH7Afe4=; b=Cqu9r2l37xIccE1emqXEMywkkIDdP2a8vqSnPOSfrpgvwbOHB+GuPATFrrIQYf0ET+ pcQKqd9PVa2ic5UbLbZU6mdWmgAMX9f39sqMmLWcqAjomVntCina9Zr8JCkKfqajyrA6 BAwpIRqoD+Jk+OoWQFeSYK2dXV3Hm0UI8eCXx6QtXPaIU6d5sHn8MmUe7xWIHn2A3DT9 iifvAdNADkF06/2909kNdO3BkDz1/baElejajHdda4Eygf6A3s/j2Fz1il38O0p8R5V5 1XlGah93CRUw+bWmEV2ZJEKpDxmOmiXYnVSXWqT9jULoogv7srp+Aiicl7YDyWd6NUlg F5JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QvCrTZ5Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si6601129edx.365.2021.05.14.10.43.21; Fri, 14 May 2021 10:43:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QvCrTZ5Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232412AbhENLtQ (ORCPT + 99 others); Fri, 14 May 2021 07:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbhENLtP (ORCPT ); Fri, 14 May 2021 07:49:15 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E31B6C061574; Fri, 14 May 2021 04:48:03 -0700 (PDT) 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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