From patchwork Sun Aug 30 21:04:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 11745333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C1CD739 for ; Sun, 30 Aug 2020 21:04:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C2C6F20936 for ; Sun, 30 Aug 2020 21:04:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mLgm8Hki" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2C6F20936 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F0B0A6B0002; Sun, 30 Aug 2020 17:04:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EBB266B0003; Sun, 30 Aug 2020 17:04:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD18B6B0005; Sun, 30 Aug 2020 17:04:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id C91376B0002 for ; Sun, 30 Aug 2020 17:04:57 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 82E82180AD804 for ; Sun, 30 Aug 2020 21:04:57 +0000 (UTC) X-FDA: 77208464634.29.trees47_300eb252708a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 4888D18086CCB for ; Sun, 30 Aug 2020 21:04:57 +0000 (UTC) X-Spam-Summary: 1,0,0,214941bf49635d61,d41d8cd98f00b204,hughd@google.com,,RULES_HIT:41:355:379:800:960:966:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3866:3867:3868:3870:3871:3874:4321:4385:5007:6261:6653:6742:8957:10004:10400:10450:10455:11026:11232:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:12986:13069:13311:13357:13439:14093:14096:14097:14181:14394:14659:14721:19904:19999:21080:21324:21444:21451:21627:21740:30034:30054:30056:30070:30075,0,RBL:209.85.167.195:@google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04ygkyxurb1zjq8dfm6uazcypq693opdn9ftmjunxyjoess3xkd65tgebf5hqnc.ojeb4awrzfjxh3qq437n67irt9wrxezipzaes78jtnds1wsbhi7fq81p74mh4cm.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: trees47_300eb252708a X-Filterd-Recvd-Size: 4824 Received: from mail-oi1-f195.google.com (mail-oi1-f195.google.com [209.85.167.195]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Sun, 30 Aug 2020 21:04:56 +0000 (UTC) Received: by mail-oi1-f195.google.com with SMTP id u24so5487476oic.7 for ; Sun, 30 Aug 2020 14:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=coS1VgOeVvuW3zilDte6RopNvB+JCPXBV06ZRlXDP00=; b=mLgm8HkihKv7FyGuefBErbKi1q1X3jgYF1hFyRbkUtb+OlouRU6smur6+yj1xhcX5o mudVlzmxyk3BIsBQ+jxr0UGffsZM9yHUxOWGMJy6iP4fPeUNHnCpypxiDiDSe26OP8CP WaD1ejKPn5MwG679WL8r5CkBr4ucRNV4Fki7DfaAZdyGCroDviXtVHCUmZWgTa0ggtUP ifGpay17H5XsEl31i4ALDPfoMpW26ISN3x0V7bMmMeOak1enznroTYmgomSaLQ/7zVcH voFY5z0lGiViIVUs/JP2LEhQwAzltEAb9mLieOjaBjUcg+uiL5oPQeDt9Li8eYlhKfYv 2cdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=coS1VgOeVvuW3zilDte6RopNvB+JCPXBV06ZRlXDP00=; b=V38iiPezJobNPdOEHWWSz3EDsOKntnZH8tmD0hd2uK+apmDxYH9tSYWwHkbtzHNnaY a+XFHsgv+6EooBwXq6bLssRD8BKSbOAIkjonKc7x6Dlv0wR07kkfhVSNLuMxPIoxeAgv ittMc+QfLXODw9xo32PP88JLM8+lFF7DCOIwxEEn4DugKOtqMhVp4JiJK4tW5HRcAT5x dUX2V5Cnyd2/WVSCgtSLsQvZDVXFw/cmHt04Es6TsbZAL7X4boGiYMpB55Jfw18nPT+A affVAidGfjnEYoBLFrlENIIY6aKyz2sJoo51bMO9S8U9Nx7QvehtHfD6aHuIS5fPBqwf k8NQ== X-Gm-Message-State: AOAM532NZZG5iWuRvm6NTVjxauUyihZfF3/NjuZBP6+52wIHRC6FounW I10eHCUocMtRcf1hZTvH6DCVVA== X-Google-Smtp-Source: ABdhPJyBDjSpD7vn8efGsx/WG5uLd+GklOI9Mc88ks1Nx40bsNuBq8J3UE90x7tcCu+8R+f7RbVQiQ== X-Received: by 2002:a05:6808:b36:: with SMTP id t22mr1874161oij.159.1598821496074; Sun, 30 Aug 2020 14:04:56 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id z10sm1362907otk.6.2020.08.30.14.04.54 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Sun, 30 Aug 2020 14:04:55 -0700 (PDT) Date: Sun, 30 Aug 2020 14:04:53 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Alex Shi , Johannes Weiner , Michal Hocko , Mike Kravetz , Shakeel Butt , Matthew Wilcox , Qian Cai , Chris Wilson , Kuo-Hsin Yang , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/5] shmem: shmem_writepage() split unlikely i915 THP Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 X-Rspamd-Queue-Id: 4888D18086CCB 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: 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+ Reviewed-by: Shakeel Butt --- 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; + BUG_ON(!PageLocked(page)); mapping = page->mapping; index = page->index;