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.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 D5692C10DCE for ; Tue, 10 Mar 2020 20:37:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 73D8321655 for ; Tue, 10 Mar 2020 20:37:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="T7YBm3Pe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73D8321655 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 1F15F6B0003; Tue, 10 Mar 2020 16:37:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A0D66B0006; Tue, 10 Mar 2020 16:37:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DE586B0007; Tue, 10 Mar 2020 16:37:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id EAD226B0003 for ; Tue, 10 Mar 2020 16:37:34 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B43A4181AEF0B for ; Tue, 10 Mar 2020 20:37:34 +0000 (UTC) X-FDA: 76580613228.04.army80_5f3cd71f80215 X-HE-Tag: army80_5f3cd71f80215 X-Filterd-Recvd-Size: 3919 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Mar 2020 20:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=WtnqD/MdLqvKTGd7HoHVF88anJD9iQ2zXhTNYjrz3MI=; b=T7YBm3PetJvch5wm3xYvLImAuE D2j8CsBp+wEepXFoiyu5rPOgHslfOJimMuhdjnainumufRaqh1q7kTEvVqZEgkENAHiOQBwHvCAGt Wy8gkdpVEG4xos2UBWe9voOnuXW2QBgjl5d6NWzRB04b9hPFqh9SuGZFjvjunavHpGt1OAjivF1XQ kFw/9a4VeSGO67+eZVHhPnkiugTaEPGwlqX0V9Nz4zDZP+zchHlPw4b8FUJQ55AGGoCh18hajAHeT CwSIDntB0yuYOGKj9i0lM/+R3YFtYGKYh5h3j1CeDdzaSZnkINCoToeRIXbt27ye5/nxc85qP9azH PdE8d70A==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jBld6-0003RA-Kl; Tue, 10 Mar 2020 20:37:32 +0000 Date: Tue, 10 Mar 2020 13:37:32 -0700 From: Matthew Wilcox To: Alexander Duyck Cc: Andrew Morton , Vlastimil Babka , linux-mm Subject: Re: [PATCH] mm: Make PageType more efficient Message-ID: <20200310203732.GC22433@bombadil.infradead.org> References: <20200310185609.5401-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, Mar 10, 2020 at 01:17:17PM -0700, Alexander Duyck wrote: > On Tue, Mar 10, 2020 at 11:56 AM Matthew Wilcox wrote: > > PageType is a little hard for GCC to reason about, By checking > > ((~A) & flag) instead of (flag & (A | MASK) == MASK), GCC can do > > better optimisations, saving 652 bytes in page_alloc.o (which is > > a heavy user of PageBuddy). > > > > Signed-off-by: Matthew Wilcox (Oracle) > > --- > > include/linux/page-flags.h | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > > index 1bf83c8fcaa7..8fc0876e2794 100644 > > --- a/include/linux/page-flags.h > > +++ b/include/linux/page-flags.h > > @@ -725,14 +725,14 @@ PAGEFLAG_FALSE(DoubleMap) > > #define PG_table 0x00000400 > > #define PG_guard 0x00000800 > > > > -#define PageType(page, flag) \ > > - ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) > > - > > static inline int page_has_type(struct page *page) > > { > > return (int)page->page_type < PAGE_MAPCOUNT_RESERVE; > > } > > > > +#define PageType(page, flag) \ > > + (page_has_type(page) && (~page->page_type & flag)) > > + > > #define PAGE_TYPE_OPS(uname, lname) \ > > static __always_inline int Page##uname(struct page *page) \ > > { \ > > If I recall all the page type is doing is clearing a single bit to > indicate the page type, and only one page type is supposed to be set > at a time correct? > > Is there any reason why we couldn't just do an addition and test? > Basically just add the flag + 1 and see if the value rolls over to 0. > I would think that would reduce to an even simpler setup since that > would be an addition with a test for carry flag or zero. I think we already allow for both PageKmemcg and PageTable to be set on the same page. I don't want to stop people from being able to do combinations like that in the future.