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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, 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 69FA6C433E0 for ; Thu, 25 Feb 2021 12:12:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B6FB64F1B for ; Thu, 25 Feb 2021 12:12:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B6FB64F1B 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 C58A78D001B; Thu, 25 Feb 2021 07:12:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE3738D0005; Thu, 25 Feb 2021 07:12:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A83AC8D001B; Thu, 25 Feb 2021 07:12:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0166.hostedemail.com [216.40.44.166]) by kanga.kvack.org (Postfix) with ESMTP id 8FA4B8D0005 for ; Thu, 25 Feb 2021 07:12:51 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 579B510F7D for ; Thu, 25 Feb 2021 12:12:51 +0000 (UTC) X-FDA: 77856678942.26.20F5848 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 5794480192C0 for ; Thu, 25 Feb 2021 12:12:48 +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=l2kQOHAtExAXN9R7ZqFlbGG4l/kVsDVtdNUTjvtMTBM=; b=Mph664UogEaRWHjnRI1mGxwAxQ lb4JaWQZcccyCrNbxNJk4hGSoBNSw3dKNxRCjXEQEWsNTPfckm7141v+vOpDYm0NS2U+5Bg8noZnU hYdZvfIhRLG+OQ5cCNlksriaX7MzKkGNioV5bD8cpqwQoWAIHYyb2d6Vie13PbkH5P1Npr4wMqK02 ct3ZaVvIg3R17CfrwbyFqfiyyw70x2r6K87Iiekg1alEvNU3bfl0/b8tK+2y6HW9e20Vxd5cs1fBZ dy7BasmQWBiwvGrOiadBN4yb6UnuVc834Zu7cZ0u6OIfQZfq22P2aQ2AOo3lLsiBR3I8STxB8iIJU RPags8YA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lFFV1-00Ag7L-LW; Thu, 25 Feb 2021 12:12:10 +0000 Date: Thu, 25 Feb 2021 12:12:07 +0000 From: Matthew Wilcox To: Yu Zhao Cc: Andrew Morton , vbabka@suse.cz, alex.shi@linux.alibaba.com, guro@fb.com, hannes@cmpxchg.org, hughd@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@kernel.org, vdavydov.dev@gmail.com Subject: Re: [PATCH] mm: test page->flags directly in page_lru() Message-ID: <20210225121207.GY2858050@casper.infradead.org> References: <20210122220600.906146-11-yuzhao@google.com> <20210224084807.2179942-1-yuzhao@google.com> <20210224051558.79e31c60eea2c088f4a1b300@linux-foundation.org> <20210224215639.GT2858050@casper.infradead.org> <20210224224846.GU2858050@casper.infradead.org> <20210225035553.GX2858050@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: e8n5p91ouiyja3ds5o1dgdbk5ag4dgku X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 5794480192C0 Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf16; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614255168-709942 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 Wed, Feb 24, 2021 at 10:22:38PM -0700, Yu Zhao wrote: > On Thu, Feb 25, 2021 at 03:55:53AM +0000, Matthew Wilcox wrote: > > On Wed, Feb 24, 2021 at 04:50:39PM -0700, Yu Zhao wrote: > > > Let me work out something *conceptually* smaller first, and if you > > > think folio is absolutely more suitable even for this specific issue, > > > I'll go review and test the four patches you listed. Sounds good? > > > > Umm. It seems to me that no matter what you do, it'll be equivalent to > > this, only without the type-safety? > > I'm thinking about something trivial but still very effective. So far > I've only tested it with PG_{active,unevictable}, and I'm already > seeing a 4KB gain less the 2KB loss from page_lru(). > > I didn't go with this at the beginning because it's also time- > consuming. I need to go over every single use of > PG_{active,unevictable,swapbacked,lru}. Well, yes. If you went with the folio, it'd also be typesafe. What you've done here makes it a runtime error, and it's only detected if you enable CONFIG_DEBUG_VM_PGFLAGS, which people don't do, in general. > +++ b/fs/proc/task_mmu.c > @@ -1712,6 +1712,7 @@ static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty, > unsigned long nr_pages) > { > int count = page_mapcount(page); > + struct page *head = compound_head(page); > > md->pages += nr_pages; > if (pte_dirty || PageDirty(page)) ... if you went full-on folio in this function, you could also make this FolioDirty, saving another call to compound_head. > @@ -1720,7 +1721,7 @@ static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty, > if (PageSwapCache(page)) ... ditto ... > md->swapcache += nr_pages; > > - if (PageActive(page) || PageUnevictable(page)) > + if (PageActive(head) || PageUnevictable(head)) > md->active += nr_pages; > > if (PageWriteback(page)) ... ditto...