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=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 8D484C43462 for ; Mon, 19 Apr 2021 18:24:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69D0B60E0C for ; Mon, 19 Apr 2021 18:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240939AbhDSSZX (ORCPT ); Mon, 19 Apr 2021 14:25:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:48482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233908AbhDSSZU (ORCPT ); Mon, 19 Apr 2021 14:25:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5E6B9611EE; Mon, 19 Apr 2021 18:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618856690; bh=YxOWGUrr9Arsoda9fsVSCB7Wv4rVHn47U+RWA4JnEik=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Eqgm4LWDn1T4KMIdCqYE+gjNg+SANj+00vJAZ20BOHkbCOUFadrvAoCiSfOO0vRry cRCtQoRNQsNXz5MFoOsMVaaP5Gd9/+08n7XDGr80HYzIgK9xevo+a/Sm9FXoJXZjTk HaSQiBdLsidEyOo5u5kxW/yk+MUsmi2kU2J8JYlAQ+COKbIhejTh20dmKGVs5wB+PQ r8kxDIacMWEYzyfTRPMIDb6vu58wBn7mPmvUnoXAazvSjaTq6lhypXTWnItI4BvjoA TnqdMG0PIIF9yA1redNzhKMCU4jKQXwnIlYMZ9uunZfCkBYwZUzqLYKrPmPwfNOjpf 8Nh3U2mR23q7w== Date: Mon, 19 Apr 2021 21:24:30 +0300 From: Mike Rapoport To: Matthew Wilcox Cc: Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , David Hildenbrand , Elena Reshetova , "H. Peter Anvin" , Ingo Molnar , James Bottomley , "Kirill A. Shutemov" , Matthew Garrett , Mark Rutland , Michal Hocko , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , "Rafael J. Wysocki" , Rick Edgecombe , Roman Gushchin , Shakeel Butt , Shuah Khan , Thomas Gleixner , Tycho Andersen , Will Deacon , Yury Norov , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-riscv@lists.infradead.org, x86@kernel.org, kernel test robot Subject: Re: [PATCH] secretmem: optimize page_is_secretmem() Message-ID: References: <20210419084218.7466-1-rppt@kernel.org> <20210419112302.GX2531743@casper.infradead.org> <20210419122156.GZ2531743@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210419122156.GZ2531743@casper.infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Apr 19, 2021 at 01:21:56PM +0100, Matthew Wilcox wrote: > On Mon, Apr 19, 2021 at 02:56:17PM +0300, Mike Rapoport wrote: > > > > With that fixed, you'll have a head page that you can use for testing, > > > which means you don't need to test PageCompound() (because you know the > > > page isn't PageTail), you can just test PageHead(). > > > > I can't say I follow you here. page_is_secretmem() is intended to be a > > generic test, so I don't see how it will get PageHead() if it is called > > from other places. > > static inline bool head_is_secretmem(struct page *head) > { > if (PageHead(head)) > return false; > ... > } > > static inline bool page_is_secretmem(struct page *page) > { > if (PageTail(page)) > return false; > return head_is_secretmem(page); > } > > (yes, calling it head is a misnomer, because it's not necessarily a head, > it might be a base page, but until we have a name for pages which might > be a head page or a base page, it'll have to do ...) To me this looks less clean and readable and in the end we have an extra check for PG_Head if that won't get optimized away. Does not seem to me there would be a measurable difference, but if this is important for future conversion to folio I don't mind using {head,page}_is_secretmem. -- Sincerely yours, Mike.