linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <shy828301@gmail.com>
To: Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Alex Shi <alex.shi@linux.alibaba.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@suse.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Shakeel Butt <shakeelb@google.com>,
	Matthew Wilcox <willy@infradead.org>, Qian Cai <cai@lca.pw>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	Kuo-Hsin Yang <vovoy@chromium.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH 3/5] shmem: shmem_writepage() split unlikely i915 THP
Date: Tue, 1 Sep 2020 08:39:00 -0700	[thread overview]
Message-ID: <CAHbLzko5xAyzJ7s31B55uXJPXT+2dzun+XcGPJngTwJ6mE=ETg@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.2.11.2008301401390.5954@eggly.anvils>

On Sun, Aug 30, 2020 at 2:04 PM Hugh Dickins <hughd@google.com> wrote:
>
> drivers/gpu/drm/i915/gem/i915_gem_shmem.c contains a shmem_writeback()
> which calls shmem_writepage() from a shrinker: that usually works well
> enough; but if /sys/kernel/mm/transparent_hugepage/shmem_enabled has
> been set to "force" (documented as "Force the huge option on for all -
> very useful for testing"), shmem_writepage() is surprised to be called
> with a huge page, and crashes on the VM_BUG_ON_PAGE(PageCompound) (I
> did not find out where the crash happens when CONFIG_DEBUG_VM is off).
>
> 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().
>
> Fixes: 2d6692e642e7 ("drm/i915: Start writeback from the shrinker")
> Signed-off-by: Hugh Dickins <hughd@google.com>
> Cc: stable@vger.kernel.org # v5.3+
> ---
> I've marked this for stable just for the info, but the number of users
> affected is very probably 1, so please feel free to delete that marking.
>
>  mm/shmem.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
>
> --- 5.9-rc2/mm/shmem.c  2020-08-16 17:32:50.693507198 -0700
> +++ linux/mm/shmem.c    2020-08-28 17:35:08.326024349 -0700
> @@ -1362,7 +1362,15 @@ static int shmem_writepage(struct page *
>         swp_entry_t swap;
>         pgoff_t index;
>
> -       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;

The change looks good to me. Acked-by: Yang Shi <shy828301@gmail.com>

Just a nit: it may be better to move the spilte after the !PageLocked
assertion? Split needs page locked too.

> +
>         BUG_ON(!PageLocked(page));
>         mapping = page->mapping;
>         index = page->index;
>

  parent reply	other threads:[~2020-09-01 16:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-30 21:04 [PATCH 3/5] shmem: shmem_writepage() split unlikely i915 THP Hugh Dickins
2020-08-31 14:41 ` Shakeel Butt
2020-09-01 15:39 ` Yang Shi [this message]
2020-09-01 17:39   ` Hugh Dickins
2020-09-01 18:50     ` Yang Shi

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='CAHbLzko5xAyzJ7s31B55uXJPXT+2dzun+XcGPJngTwJ6mE=ETg@mail.gmail.com' \
    --to=shy828301@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.shi@linux.alibaba.com \
    --cc=cai@lca.pw \
    --cc=chris@chris-wilson.co.uk \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=shakeelb@google.com \
    --cc=vovoy@chromium.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;
as well as URLs for NNTP newsgroup(s).