Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp151045rwd; Wed, 14 Jun 2023 13:43:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6KFiyCulGAmdl9yQI0QmBBavLxppfwsLgwLyP/nbo56Bw0+L5yYZQV8+XxaxPDYpTka5Eg X-Received: by 2002:a17:906:974b:b0:966:5035:6973 with SMTP id o11-20020a170906974b00b0096650356973mr22061051ejy.50.1686775391151; Wed, 14 Jun 2023 13:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686775391; cv=none; d=google.com; s=arc-20160816; b=imY2P9TA95kg55t8Pg6qOlLiSNEFQjPuq+Psz0bxjgmxJIXmEfAQmBz0PlPWjFTAwl rjYpx6OGzMYICXpPYgLXEEb6Q0f1zGn13VpMoy4ojWHTXPjhATa5d+OnNamLsPC5J+HE LaA334a9rR+BNKMPC+fUsQc92RzrYxJhQNoU6s8UJLM7eO4mPpaQHsFi0nd7pqTxF5E9 WFwOT5jDx/9kxEGiA6gsJxaPHxgP/thS2av7k6EjtFBJUTnompCmbHeP6VcwNaqfpb+z kK1uQe9evtzQBI3FwZ0PdulZSgEKsOgrHD9ENm67TbJZw72/TjaIbI6d0CInvf+omtnl G91Q== 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=bHxFZhGcHSdLpHTIxszs9CxuBIsMRRxsbZMR2wHn8Tc=; b=Sa2r9qbCdHQ3n/cidNyVcSgonBOEfl5VVgguOgqvKXrZVLp4UJSSNwvG0ZPenLFaRy w6/SfOvaTdHEVL6+hmq762EWCLCI1e9wgOmgXi/VetgoFCByh0qpHeOi2md2oJc5zExp Mj+RgJ63Eo/l99EKOMWXND84mMs01nOMHo6xlcFwwc9mDNSzaNOnWAB0DLuByQxcKP9K CWES7KnvUVbVHHDsZhk0UtB2tJWyQ8OukOQnHpQrUBNNbozDohRSlar48yahHfCTBorO IVX5Jiz5AkqG01Cv/Lmv9pV/eMU7SdJr5drzomwmIzBJUC7XU44qlQVyoEqWIMitIk23 Ws9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=LFdFZsfr; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h24-20020a170906111800b009827cdf1e42si1036338eja.39.2023.06.14.13.42.46; Wed, 14 Jun 2023 13:43:11 -0700 (PDT) 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=@infradead.org header.s=casper.20170209 header.b=LFdFZsfr; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236519AbjFNURl (ORCPT + 99 others); Wed, 14 Jun 2023 16:17:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234755AbjFNURk (ORCPT ); Wed, 14 Jun 2023 16:17:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C3541BCE for ; Wed, 14 Jun 2023 13:17:38 -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=bHxFZhGcHSdLpHTIxszs9CxuBIsMRRxsbZMR2wHn8Tc=; b=LFdFZsfrd0y1NAeGvqWlUvYTJ7 2H2n6r/w+mPa8rLoeP06+zkqtqKzYcl0QKIezAvkFiU8bDe+EYRt7ZYEYH5xoz321r8Lh3QXolqRN b+IqR3JsCwWmU4huN8phDrN62zQWBaGwbK9E7gJadhlLJ/62no4fvoRzT91/n++WH0rTGyaaS+5hA /kHnhEcvYC08g8oDNxa4fKUuDfqgM1XOk4Ohn8swIz2X/dQ+2FlUMm5okIbdHUA1JfDC8kSHa6Dip 3Ya3Rg4PNTm7/nNfuZrDvbXRaymlDvLxoDPkMmbQllAs2tqymDTItxxdvMiHMrCYjAVhPAqwcijzL 5Ilia9bQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1q9Wvu-006kPi-9B; Wed, 14 Jun 2023 20:17:34 +0000 Date: Wed, 14 Jun 2023 21:17:34 +0100 From: Matthew Wilcox To: Andrew Morton Cc: "Vishal Moola (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/5] mmzone: Introduce folio_migratetype() Message-ID: References: <20230614021312.34085-1-vishal.moola@gmail.com> <20230614021312.34085-3-vishal.moola@gmail.com> <20230614131305.2939f29e4372c94a8c6a56a8@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230614131305.2939f29e4372c94a8c6a56a8@linux-foundation.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Wed, Jun 14, 2023 at 01:13:05PM -0700, Andrew Morton wrote: > On Tue, 13 Jun 2023 19:13:09 -0700 "Vishal Moola (Oracle)" wrote: > > > Introduce folio_migratetype() as a folio equivalent for > > get_pageblock_migratetype(). This function intends to return the > > migratetype the folio is located in, hence the name choice. > > > > ... > > > > --- a/include/linux/mmzone.h > > +++ b/include/linux/mmzone.h > > @@ -105,6 +105,9 @@ extern int page_group_by_mobility_disabled; > > #define get_pageblock_migratetype(page) \ > > get_pfnblock_flags_mask(page, page_to_pfn(page), MIGRATETYPE_MASK) > > > > +#define folio_migratetype(folio) \ > > + get_pfnblock_flags_mask(&folio->page, folio_pfn(folio), \ > > + MIGRATETYPE_MASK) > > Theoretically this is risky because it evaluates its argument more than > once. Although folio_migratetype(folio++) seems an unlikely thing to do. folio++ is always an unsafe thing to do. folios are not consecutive in memory (unless we know they're order-0). > An inlined C function is always preferable. My quick attempt at that > reveals that the header files are All Messed Up As Usual. The page-equivalent of this also evaluates its arguments more than once, so it doesn't see too risky for now?