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=unavailable 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 9B1AAC4338F for ; Sat, 14 Aug 2021 04:29:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3E1E560E96 for ; Sat, 14 Aug 2021 04:29:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3E1E560E96 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id AA5188D0001; Sat, 14 Aug 2021 00:29:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A55FC6B0072; Sat, 14 Aug 2021 00:29:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 974966B006C; Sat, 14 Aug 2021 00:29:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 7C1806B006C for ; Sat, 14 Aug 2021 00:29:48 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 049FA18ED0 for ; Sat, 14 Aug 2021 04:29:48 +0000 (UTC) X-FDA: 78472408056.11.59E4D64 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 75C233001856 for ; Sat, 14 Aug 2021 04:29:47 +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=lwU/IB+Nm5xyRqkYrurF6eOIosLOeIB9lERbwxGE+Dg=; b=mEigd+RjClZCSGpcrcOTkqnqZC nehtbqTGvEHUl1RMBpynmAyfNh6+qTtT/xN1hvdmx006BQ5OIlAMvytLJxpnJjfoIRv8AHK0yDO4C Yf8wPQ+/B2EvniCanoYo44kn17z/G2Zyya6TWHI35HGTEnjMNw1EX6xNFvBb4Do2ewQrtjR6mbgCg Zx3V9cjoeuLI+o121oULU00ybt3BWHeE6ndrlLnL2vzx/f0jFkbLLX4H80xJBc/NnIfwXksjydpua ZRMJ7fT17o2Q9cv07DaLzCStkjt9evQpLrSko4LRKP4wf164VVRb3SlUDrvpbjHa/vt8ElsRXiopS oIyVRHaA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mElHU-00GNYa-Oq; Sat, 14 Aug 2021 04:28:44 +0000 Date: Sat, 14 Aug 2021 05:28:24 +0100 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Johannes Weiner , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH v14 080/138] mm/workingset: Convert workingset_refault() to take a folio Message-ID: References: <20210715033704.692967-1-willy@infradead.org> <20210715033704.692967-81-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210715033704.692967-81-willy@infradead.org> X-Rspamd-Queue-Id: 75C233001856 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mEigd+Rj; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam01 X-Stat-Signature: r3r7kgf7ehn31gk3ecu3cghhux777j19 X-HE-Tag: 1628915387-255471 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 Thu, Jul 15, 2021 at 04:36:06AM +0100, Matthew Wilcox (Oracle) wrote: > /** > - * workingset_refault - evaluate the refault of a previously evicted page > - * @page: the freshly allocated replacement page > - * @shadow: shadow entry of the evicted page > + * workingset_refault - evaluate the refault of a previously evicted folio > + * @page: the freshly allocated replacement folio Randy pointed out this doc mistake. Which got me looking at this whole patch again, and I noticed that we're counting an entire folio as a single page. So I'm going to apply this patch on top of the below patch. diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 241bd0f53fb9..bfe38869498d 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -597,12 +597,6 @@ static inline void mod_lruvec_page_state(struct page *page, #endif /* CONFIG_MEMCG */ -static inline void inc_lruvec_state(struct lruvec *lruvec, - enum node_stat_item idx) -{ - mod_lruvec_state(lruvec, idx, 1); -} - static inline void __inc_lruvec_page_state(struct page *page, enum node_stat_item idx) { diff --git a/mm/workingset.c b/mm/workingset.c index 10830211a187..9f91c28cc0ce 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -273,9 +273,9 @@ void *workingset_eviction(struct page *page, struct mem_cgroup *target_memcg) } /** - * workingset_refault - evaluate the refault of a previously evicted folio - * @page: the freshly allocated replacement folio - * @shadow: shadow entry of the evicted folio + * workingset_refault - Evaluate the refault of a previously evicted folio. + * @folio: The freshly allocated replacement folio. + * @shadow: Shadow entry of the evicted folio. * * Calculates and evaluates the refault distance of the previously * evicted folio in the context of the node and the memcg whose memory @@ -295,6 +295,7 @@ void workingset_refault(struct folio *folio, void *shadow) unsigned long refault; bool workingset; int memcgid; + long nr; unpack_shadow(shadow, &memcgid, &pgdat, &eviction, &workingset); @@ -347,10 +348,11 @@ void workingset_refault(struct folio *folio, void *shadow) * However, the cgroup that will own the folio is the one that * is actually experiencing the refault event. */ + nr = folio_nr_pages(folio); memcg = folio_memcg(folio); lruvec = mem_cgroup_lruvec(memcg, pgdat); - inc_lruvec_state(lruvec, WORKINGSET_REFAULT_BASE + file); + mod_lruvec_state(lruvec, WORKINGSET_REFAULT_BASE + file, nr); /* * Compare the distance to the existing workingset size. We @@ -376,15 +378,15 @@ void workingset_refault(struct folio *folio, void *shadow) goto out; folio_set_active(folio); - workingset_age_nonresident(lruvec, folio_nr_pages(folio)); - inc_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + file); + workingset_age_nonresident(lruvec, nr); + mod_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + file, nr); /* Folio was active prior to eviction */ if (workingset) { folio_set_workingset(folio); /* XXX: Move to lru_cache_add() when it supports new vs putback */ lru_note_cost_folio(folio); - inc_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + file); + mod_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + file, nr); } out: rcu_read_unlock(); > + * @shadow: shadow entry of the evicted folio > * > * Calculates and evaluates the refault distance of the previously > - * evicted page in the context of the node and the memcg whose memory > + * evicted folio in the context of the node and the memcg whose memory > * pressure caused the eviction. > */ > -void workingset_refault(struct page *page, void *shadow) > +void workingset_refault(struct folio *folio, void *shadow) > { > - bool file = page_is_file_lru(page); > + bool file = folio_is_file_lru(folio); > struct mem_cgroup *eviction_memcg; > struct lruvec *eviction_lruvec; > unsigned long refault_distance; > @@ -301,10 +301,10 @@ void workingset_refault(struct page *page, void *shadow) > rcu_read_lock(); > /* > * Look up the memcg associated with the stored ID. It might > - * have been deleted since the page's eviction. > + * have been deleted since the folio's eviction. > * > * Note that in rare events the ID could have been recycled > - * for a new cgroup that refaults a shared page. This is > + * for a new cgroup that refaults a shared folio. This is > * impossible to tell from the available data. However, this > * should be a rare and limited disturbance, and activations > * are always speculative anyway. Ultimately, it's the aging > @@ -340,14 +340,14 @@ void workingset_refault(struct page *page, void *shadow) > refault_distance = (refault - eviction) & EVICTION_MASK; > > /* > - * The activation decision for this page is made at the level > + * The activation decision for this folio is made at the level > * where the eviction occurred, as that is where the LRU order > - * during page reclaim is being determined. > + * during folio reclaim is being determined. > * > - * However, the cgroup that will own the page is the one that > + * However, the cgroup that will own the folio is the one that > * is actually experiencing the refault event. > */ > - memcg = page_memcg(page); > + memcg = folio_memcg(folio); > lruvec = mem_cgroup_lruvec(memcg, pgdat); > > inc_lruvec_state(lruvec, WORKINGSET_REFAULT_BASE + file); > @@ -375,15 +375,15 @@ void workingset_refault(struct page *page, void *shadow) > if (refault_distance > workingset_size) > goto out; > > - SetPageActive(page); > - workingset_age_nonresident(lruvec, thp_nr_pages(page)); > + folio_set_active(folio); > + workingset_age_nonresident(lruvec, folio_nr_pages(folio)); > inc_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + file); > > - /* Page was active prior to eviction */ > + /* Folio was active prior to eviction */ > if (workingset) { > - SetPageWorkingset(page); > + folio_set_workingset(folio); > /* XXX: Move to lru_cache_add() when it supports new vs putback */ > - lru_note_cost_page(page); > + lru_note_cost_folio(folio); > inc_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + file); > } > out: > -- > 2.30.2 >