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=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no 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 BCA72C433E6 for ; Tue, 1 Sep 2020 18:50:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A97120767 for ; Tue, 1 Sep 2020 18:50:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rKOVQTut" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A97120767 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C0F3890001E; Tue, 1 Sep 2020 14:50:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9798900015; Tue, 1 Sep 2020 14:50:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5F5D90001E; Tue, 1 Sep 2020 14:50:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id 886E3900015 for ; Tue, 1 Sep 2020 14:50:20 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3E975181AC553 for ; Tue, 1 Sep 2020 18:50:20 +0000 (UTC) X-FDA: 77215383000.15.pot59_2417c652709a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 0DD891814B0C1 for ; Tue, 1 Sep 2020 18:50:20 +0000 (UTC) X-HE-Tag: pot59_2417c652709a X-Filterd-Recvd-Size: 5987 Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 18:50:19 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id c10so2471152edk.6 for ; Tue, 01 Sep 2020 11:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nz5CAELUBJduEX0zdbamYoeJmzl2NIbIAQHq+WzwOh0=; b=rKOVQTutXkylaslkF5EDj29k89NmOAbhs93DZDL6uM787tawoR9KRjvoY1P1phgl47 /iXaVl/WWAtZEnga5dVEl3qYsnN4HKQByetHkE2hq+vkGCEhKz0bgYSyLxe96N+bmOG5 +qKCPh3eXILlp6hukLZjvOjC0JXDx5qhSNdq+vkjAZSMuDxNDcu1P8sFzGJ50udgvJTc 3lXXoVf6YzyD4Aa34GRVbzXNzQUeJoB7SnhYrtQ9G4fp7e+bp/O41YeOe6JztGugJp5O 1d7ilF6gLoYfQzyRA/Qr98vhKk466paXJJPK/CGM2xqJtcy/KRJ6QcLThPAII0aPg1Lm Dv2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nz5CAELUBJduEX0zdbamYoeJmzl2NIbIAQHq+WzwOh0=; b=TOEN4uqL/xH6AUDXInGP+bPWQfqT9wtEtCAZ6BKwql+3CqB0o9hgbonb1E4CsvE7PY 8alxApWaWbXkuBl0NSX0xa+H9g8eCDsQrYtCfGKOOPHKJkX11aYHxbEjDiD6LlHXfSOo mvyCe/xmIm1WFxkmlC75ih7hzd5lUGBuNlb54J32t+yWKUVO2En+G7lHFZ8liOtsFUzq auvNJQcKTxmFHsObdKqI9gWhWY0eu2pgNgGRHHbqMZ2LXQSABP/WJIOqIjIqHtkZgxEE qlSiZw5qdaxXp0q1oB7kUVwDc7dedoLwISsT1O9R9LgIHgdB0kNsVuW8LfZ9Kytiuydv XTpw== X-Gm-Message-State: AOAM530uq3uSYA0d19wHxY8ie802b2feMZ9W6IfDN5AZezgdoe3AT2ib 7NCHTHCBn9DJuMgAefWCFE35TPN13m/s/oN/1AI= X-Google-Smtp-Source: ABdhPJzKB2AJV1YlTZ9j7FbpsWqZoNwEZezU1pGjMvLS0fs16gttFi4NcRRnfyxvnn8Pu/t45tEpbFmoqcUcY8uxKjQ= X-Received: by 2002:aa7:dc05:: with SMTP id b5mr3178718edu.137.1598986218310; Tue, 01 Sep 2020 11:50:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yang Shi Date: Tue, 1 Sep 2020 11:50:06 -0700 Message-ID: Subject: Re: [PATCH 3/5] shmem: shmem_writepage() split unlikely i915 THP To: Hugh Dickins Cc: Andrew Morton , Alex Shi , Johannes Weiner , Michal Hocko , Mike Kravetz , Shakeel Butt , Matthew Wilcox , Qian Cai , Chris Wilson , Kuo-Hsin Yang , Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 0DD891814B0C1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Tue, Sep 1, 2020 at 10:39 AM Hugh Dickins wrote: > > On Tue, 1 Sep 2020, Yang Shi wrote: > > On Sun, Aug 30, 2020 at 2:04 PM Hugh Dickins 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 > > > 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 > > Thanks. > > > > > Just a nit: it may be better to move the spilte after the !PageLocked > > assertion? Split needs page locked too. > > I hadn't considered that, but I think it's best left as is: > split_huge_page_to_list() has its own > VM_BUG_ON_PAGE(!PageLocked(head), head); > to enforce its needs: think of the old BUG_ON(!PageLocked(page)) > below as enforcing shmem's needs, checking that split_huge_page() > did not unlock it :) Yes, it is definitely fine to keep it as is. I just thought we could bailout earlier if the page is not locked. > > > > > > + > > > BUG_ON(!PageLocked(page)); > > > mapping = page->mapping; > > > index = page->index; > > >