From: Hugh Dickins <hughd@google.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
alex.shi@linux.alibaba.com, cai@lca.pw, hannes@cmpxchg.org,
hughd@google.com, linux-mm@kvack.org, mhocko@suse.com,
mike.kravetz@oracle.com, mm-commits@vger.kernel.org,
shakeelb@google.com, shy828301@gmail.com,
stable@vger.kernel.org, torvalds@linux-foundation.org
Subject: Re: [patch 04/15] shmem: shmem_writepage() split unlikely i915 THP
Date: Fri, 18 Sep 2020 22:44:32 -0700 (PDT) [thread overview]
Message-ID: <alpine.LSU.2.11.2009182208210.13525@eggly.anvils> (raw)
In-Reply-To: <20200919044408.GL32101@casper.infradead.org>
On Sat, 19 Sep 2020, Matthew Wilcox wrote:
> On Fri, Sep 18, 2020 at 09:20:09PM -0700, Andrew Morton wrote:
> > LRU page reclaim always splits the shmem huge page first: I'd prefer not
> > to demand that of i915, so check and split compound in shmem_writepage().
>
> Sorry for not checking this earlier, but I don't think this is right.
>
> for (i = 0; i < obj->base.size >> PAGE_SHIFT; i++) {
> ...
> if (!page_mapped(page) && clear_page_dirty_for_io(page)) {
> ...
> ret = mapping->a_ops->writepage(page, &wbc);
>
> so we cleared the dirty bit on the entire hugepage, but then split
> it after clearing the dirty bit, so the subpages are now not dirty.
> I think we'll lose writes as a result? At least we won't swap pages
> out that deserve to be paged out.
Very good observation, thank you.
It behaves a lot better with this patch in than without it; but you're
right, only the head will get written to swap, and the tails left in
memory; with dirty cleared, so they may be left indefinitely (I've
not yet looked to see when if ever PageDirty might get set later).
Hmm. It may just be a matter of restyling the i915 code with
if (!page_mapped(page)) {
clear_page_dirty_for_io(page);
but I don't want to rush to that conclusion - there might turn
out to be a good way of doing it at the shmem_writepage() end, but
probably only hacks available. I'll mull it over: it deserves some
thought about what would suit, if a THP arrived here some other way.
We did have some i915 guys Cc'ed on the original posting, but no
need to Cc them again until I'm closer to deciding what's right.
Linus, Andrew, probably best to drop this patch for now, since
no-one else has reported the problem here than me, testing with
/sys/kernel/mm/transparent_hugepage/shmem_enabled set to "force";
and what it fixes is not a new regression in 5.9.
Though no harm done if the patch goes in: it is an improvement,
but seriously incomplete, as Matthew has observed.
Hugh
>
> >
> > - VM_BUG_ON_PAGE(PageCompound(page), page);
> > + /*
> > + * If /sys/kernel/mm/transparent_hugepage/shmem_enabled is "force",
> > + * then drivers/gpu/drm/i915/gem/i915_gem_shmem.c gets huge pages,
> > + * and its shmem_writeback() needs them to be split when swapping.
> > + */
> > + if (PageTransCompound(page))
> > + if (split_huge_page(page) < 0)
> > + goto redirty;
> > +
> > BUG_ON(!PageLocked(page));
> > mapping = page->mapping;
> > index = page->index;
> > _
> >
next prev parent reply other threads:[~2020-09-19 5:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-19 4:19 incoming Andrew Morton
2020-09-19 4:20 ` [patch 01/15] mailmap: add older email addresses for Kees Cook Andrew Morton
2020-09-19 4:20 ` [patch 02/15] ksm: reinstate memcg charge on copied pages Andrew Morton
2020-09-19 4:20 ` [patch 03/15] mm: migration of hugetlbfs page skip memcg Andrew Morton
2020-09-19 4:20 ` [patch 04/15] shmem: shmem_writepage() split unlikely i915 THP Andrew Morton
2020-09-19 4:44 ` Matthew Wilcox
2020-09-19 5:44 ` Hugh Dickins [this message]
2020-09-19 16:18 ` Matthew Wilcox
2020-09-20 0:16 ` Hugh Dickins
2020-09-20 3:32 ` Matthew Wilcox
2020-10-02 18:37 ` Matthew Wilcox
2020-10-09 8:14 ` Huang, Ying
2020-10-10 15:32 ` Matthew Wilcox
2020-10-12 2:01 ` Huang, Ying
2020-09-19 4:20 ` [patch 05/15] mm: fix check_move_unevictable_pages() on THP Andrew Morton
2020-09-19 4:20 ` [patch 06/15] mlock: fix unevictable_pgs event counts " Andrew Morton
2020-09-19 4:20 ` [patch 07/15] tmpfs: restore functionality of nr_inodes=0 Andrew Morton
2020-09-19 4:20 ` [patch 08/15] kprobes: fix kill kprobe which has been marked as gone Andrew Morton
2020-09-19 4:20 ` [patch 09/15] mm/thp: fix __split_huge_pmd_locked() for migration PMD Andrew Morton
2020-09-19 4:20 ` [patch 10/15] selftests/vm: fix display of page size in map_hugetlb Andrew Morton
2020-09-19 4:20 ` [patch 11/15] mm/memory_hotplug: drain per-cpu pages again during memory offline Andrew Morton
2020-09-19 4:20 ` [patch 12/15] ftrace: let ftrace_enable_sysctl take a kernel pointer buffer Andrew Morton
2020-09-19 4:20 ` [patch 13/15] stackleak: let stack_erasing_sysctl " Andrew Morton
2020-09-19 4:20 ` [patch 14/15] fs/fs-writeback.c: adjust dirtytime_interval_handler definition to match prototype Andrew Morton
2020-09-19 4:20 ` [patch 15/15] kcsan: kconfig: move to menu 'Generic Kernel Debugging Instruments' Andrew Morton
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=alpine.LSU.2.11.2009182208210.13525@eggly.anvils \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=alex.shi@linux.alibaba.com \
--cc=cai@lca.pw \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mike.kravetz@oracle.com \
--cc=mm-commits@vger.kernel.org \
--cc=shakeelb@google.com \
--cc=shy828301@gmail.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=willy@infradead.org \
/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