Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1847446pxk; Tue, 1 Sep 2020 09:09:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMvxCKAXL0LEfV9iowZkPlkIjVmVcQ4APnBc0SGY83qSMt+M+2OIf6vhf/9toTFJc6gjl3 X-Received: by 2002:a05:6402:1548:: with SMTP id p8mr2456937edx.65.1598976571293; Tue, 01 Sep 2020 09:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598976571; cv=none; d=google.com; s=arc-20160816; b=EtfbjFk7o6Fancs2wUnQS0mfBvF8RxReH4lASWdgFDP4JfYXUYR8Uh59MIUujG7U13 u1c277Fd9iSruscFbpa0bYX03AwROPlDr2op/DG5J7hcr3W8kHYJkIExfUzwLCboBBhp wfN9mIgfrlxTgx1D4Qr2qR7Jp3pUou36T2OCTWiFe5wY99dT0yktg3AY5XKJctbKeBHa MHwtMtzcjGs+SUgQjOPa5q74e2MrX+YDkEEQAx6vMaCEvqMpVwdNLdE0C2FUwH6TlJJ9 T6WXMxu2h2/NT+tTIeKAANOg4dxQM4BBjLE5R/FxvvwGHa0i+nCG2cdzs+ZNbfOuWIW0 5dhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6PG5SiNwVZVH2pkgJv+IFK7tt0WCjvP76ZbFGjJc07s=; b=akafz1GTD4X0D+DZ2RE9pJ8B6KPxtj8iM+OpysOJ15LtY9Wg7MwimuV7zrq7MPNTf5 BG82Ynkl11C7sx/H2e6NPTDZfQ2WOLaj22H+2A5ZSI4Q3YHKaX3wAC6jKocdjF6n3Pcs cxiRsEsZfue9nLVZLfLSgdMdeSYI8hKVJTt/V2VXQCz1V5VJDdO3qn2dSEUPtCRav/l0 VI8NZgZEDiMYXnzj/R4wNrEECzwV83NFuRVXSfrh3atbP5DSU9eZ3564CQ0kp+WfS92+ Y2ZbVjF+kDaM5XjHZBDMd5KLYADeZNF2+hApcdTKfL3fjiMo8h+hm+9qOsjnwmIH5S4Z oRPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="i/8U9ZP+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e19si923966eje.233.2020.09.01.09.09.07; Tue, 01 Sep 2020 09:09:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="i/8U9ZP+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731772AbgIAQIa (ORCPT + 99 others); Tue, 1 Sep 2020 12:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731455AbgIAPjP (ORCPT ); Tue, 1 Sep 2020 11:39:15 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34409C061244 for ; Tue, 1 Sep 2020 08:39:14 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id i26so2274664ejb.12 for ; Tue, 01 Sep 2020 08:39:14 -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=6PG5SiNwVZVH2pkgJv+IFK7tt0WCjvP76ZbFGjJc07s=; b=i/8U9ZP+xxv0b1D3KLACprbO6f9XSdui6Bpc8qWHCAGjJKdf6SV/BwLJGyCkNI3w8z utwAKrw3BY6mIzso/yYfFuWfGTECQ7+S2GJJglSWnuRG1i7Bp7IEakBk2lI8ydIqqedT v9oYslNVOGXacY4YbhO1cqsCwlEYrOZUV0biEgmGK1TKRp95SDA12NtKfAwlcUMe93ud dHZS9fZM0xCRZnZQ5JOyObYV58dweBq4qelLd7pQ0t8xe9+RE9neWOy4ZWoYf9TCf50V L8Wrp+SBtYeR3Pq0uEVbTaRF4pyNXDottPB0Ao1kbMW2rgURZ9yPc+nvFWeuJ8jxGVRD S2zw== 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=6PG5SiNwVZVH2pkgJv+IFK7tt0WCjvP76ZbFGjJc07s=; b=L3xEM7UVTl3ywXWdfMWQXmZerWoVFfy5pJl25Q7r1lv9Agzoh3GuA/iLeuHZHL0b+p Yuk8tnWTEI9TfTd+PWemnU5WYTiqw4ZgP1fmL/1gp1rcGnELIjpBPv7b3c75FQc1sgpq mc0dQqO3+q2buCJRQBfnjTpscXdry0Ebb/7fVIB1tYo743hoVZBwZIw/Iqo1eJCrxMPa cqVE4YDA15MDZ7hCImE8qFDFOS7J1Zz2fOzZnsKWFqb8W4izB0XwGzuKOZ7MBy2HOZ0h ZObKjhYZMig58khOBOXgm4ATiIjCiUpMWUf+x96T6Eqi7JzbyJwJBoJTI6H0fmTucczB fKAQ== X-Gm-Message-State: AOAM532IaKLCVUCE3thEZIxpZJ2o2jIFA5FVNlrfmh04anegjEvw1e18 TZhm4AT8tqdVCV4hG0np6tarsnaqHyykEDkwq37EzcdG6bs= X-Received: by 2002:a17:907:2173:: with SMTP id rl19mr1935562ejb.514.1598974752908; Tue, 01 Sep 2020 08:39:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yang Shi Date: Tue, 1 Sep 2020 08:39:00 -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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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; >