From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
To: Yu Zhao <yuzhao@google.com>
Cc: Matthew Wilcox <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Jens Axboe <axboe@kernel.dk>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Andi Shyti <andi.shyti@linux.intel.com>,
Chengming Zhou <chengming.zhou@linux.dev>,
Christian Brauner <brauner@kernel.org>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Dan Carpenter <dan.carpenter@linaro.org>,
David Airlie <airlied@gmail.com>,
David Hildenbrand <david@redhat.com>, Hao Ge <gehao@kylinos.cn>,
Jani Nikula <jani.nikula@linux.intel.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Josef Bacik <josef@toxicpanda.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Miklos Szeredi <miklos@szeredi.hu>,
Nhat Pham <nphamcs@gmail.com>,
Oscar Salvador <osalvador@suse.de>,
Ran Xiaokai <ran.xiaokai@zte.com.cn>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Simona Vetter <simona@ffwll.ch>,
Steven Rostedt <rostedt@goodmis.org>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Vlastimil Babka <vbabka@suse.cz>,
Yosry Ahmed <yosryahmed@google.com>,
intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCHv2 05/11] mm/truncate: Use folio_set_dropbehind() instead of deactivate_file_folio()k
Date: Fri, 17 Jan 2025 10:38:53 +0200 [thread overview]
Message-ID: <yy55r5zwiwjgad52hgqclhg76p36jrnine37uffudmdmauxx5l@7jztoqpzscoj> (raw)
In-Reply-To: <CAOUHufZ42ZV1SU+rGLM-2j2Hp43Q9eLY_yFYg8jsifOfcPHUgQ@mail.gmail.com>
On Wed, Jan 15, 2025 at 02:46:44PM -0700, Yu Zhao wrote:
> On Wed, Jan 15, 2025 at 2:35 PM Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Wed, Jan 15, 2025 at 11:31:29AM +0200, Kirill A. Shutemov wrote:
> > > -static void lru_deactivate_file(struct lruvec *lruvec, struct folio *folio)
> > > -{
> > > - bool active = folio_test_active(folio) || lru_gen_enabled();
> > > - long nr_pages = folio_nr_pages(folio);
> > > -
> > > - if (folio_test_unevictable(folio))
> > > - return;
> > > -
> > > - /* Some processes are using the folio */
> > > - if (folio_mapped(folio))
> > > - return;
> > > -
> > > - lruvec_del_folio(lruvec, folio);
> > > - folio_clear_active(folio);
> > > - folio_clear_referenced(folio);
> > > -
> > > - if (folio_test_writeback(folio) || folio_test_dirty(folio)) {
> > > - /*
> > > - * Setting the reclaim flag could race with
> > > - * folio_end_writeback() and confuse readahead. But the
> > > - * race window is _really_ small and it's not a critical
> > > - * problem.
> > > - */
> > > - lruvec_add_folio(lruvec, folio);
> > > - folio_set_reclaim(folio);
> > > - } else {
> > > - /*
> > > - * The folio's writeback ended while it was in the batch.
> > > - * We move that folio to the tail of the inactive list.
> > > - */
> > > - lruvec_add_folio_tail(lruvec, folio);
> > > - __count_vm_events(PGROTATED, nr_pages);
> > > - }
> > > -
> > > - if (active) {
> > > - __count_vm_events(PGDEACTIVATE, nr_pages);
> > > - __count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE,
> > > - nr_pages);
> > > - }
> > > -}
> >
> > > +++ b/mm/truncate.c
> > > @@ -486,7 +486,7 @@ unsigned long mapping_try_invalidate(struct address_space *mapping,
> > > * of interest and try to speed up its reclaim.
> > > */
> > > if (!ret) {
> > > - deactivate_file_folio(folio);
> > > + folio_set_dropbehind(folio);
> >
> > brr.
> >
> > This is a fairly substantial change in semantics, and maybe it's fine.
> >
> > At a high level, we're trying to remove pages from an inode that aren't
> > in use. But we might find that some of them are in use (eg they're
> > mapped or under writeback). If they are mapped, we don't currently
> > try to accelerate their reclaim, but now we're going to mark them
> > as dropbehind. I think that's wrong.
> >
> > If they're dirty or under writeback, then yes, mark them as dropbehind, but
> > I think we need to be a little more surgical here. Maybe preserve the
> > unevictable check too.
>
> Right -- deactivate_file_folio() does make sure the folio is not
> unevictable or mapped. So probably something like below would the
> change in semantics be close enough?
>
> if (!folio_test_unevictable(folio) && !folio_mapped(folio))
> folio_set_dropbehind(folio);
Okay, makes sense to me.
--
Kiryl Shutsemau / Kirill A. Shutemov
next prev parent reply other threads:[~2025-01-17 8:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250115093135.3288234-1-kirill.shutemov@linux.intel.com>
[not found] ` <20250115093135.3288234-6-kirill.shutemov@linux.intel.com>
2025-01-15 20:43 ` [PATCHv2 05/11] mm/truncate: Use folio_set_dropbehind() instead of deactivate_file_folio() Yu Zhao
2025-01-15 21:35 ` Matthew Wilcox
2025-01-15 21:46 ` Yu Zhao
2025-01-17 8:38 ` Kirill A. Shutemov [this message]
[not found] ` <20250115093135.3288234-10-kirill.shutemov@linux.intel.com>
2025-01-15 20:51 ` [PATCHv2 09/11] mm: Remove PG_reclaim Yu Zhao
[not found] ` <20250115093135.3288234-12-kirill.shutemov@linux.intel.com>
2025-01-15 20:52 ` [PATCHv2 11/11] mm: Rename PG_dropbehind to PG_reclaim Yu Zhao
2025-01-16 6:18 ` Christoph Hellwig
2025-01-17 8:42 ` Kirill A. Shutemov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yy55r5zwiwjgad52hgqclhg76p36jrnine37uffudmdmauxx5l@7jztoqpzscoj \
--to=kirill.shutemov@linux.intel.com \
--cc=Jason@zx2c4.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andi.shyti@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=chengming.zhou@linux.dev \
--cc=christophe.leroy@csgroup.eu \
--cc=dan.carpenter@linaro.org \
--cc=david@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gehao@kylinos.cn \
--cc=hannes@cmpxchg.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=miklos@szeredi.hu \
--cc=nphamcs@gmail.com \
--cc=osalvador@suse.de \
--cc=ran.xiaokai@zte.com.cn \
--cc=rodrigo.vivi@intel.com \
--cc=rostedt@goodmis.org \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--cc=yosryahmed@google.com \
--cc=yuzhao@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox