Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp558015pxk; Sun, 30 Aug 2020 14:06:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmEsEIWXE3Kb0UGAO6a1MVwq5CPjETTLr6F82mEMUq2Gh7LB1IlOJHR52A7dqnKh+yrZq+ X-Received: by 2002:aa7:d88b:: with SMTP id u11mr8407093edq.21.1598821593560; Sun, 30 Aug 2020 14:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598821593; cv=none; d=google.com; s=arc-20160816; b=C2LLyEwDjS+7C/6DvUGniJu8eXTFJDVkHxru8TqM8iszKdCEWWzDdclB2/PfXJPY5X gnIE8ODEMKV+W3ADNM2UD8bDfO7jXeK+lne7BUw8BSd0uQLUQR3MoPkHfAWIzndux7y4 9tFHH7Y/wFh2eFf/FoXGqI7PBxi1kMz82iXxCOVPSbvyfpseRM8VAFT0uvLntTuvwOVf 35/ImlqqIAGaNGcdlgQf4Jq/AYbZC6lY8EznqESZacvYsviNKOYxO8/WzNf2bGt/Gy82 4272NCcts62rVTQtMgaQbDHaBZo6u8FA1RJy0PvwWXjIUReMi5lrsxQK+asrRDQFbbw9 vmiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=coS1VgOeVvuW3zilDte6RopNvB+JCPXBV06ZRlXDP00=; b=VY/DW6Wm1Fkbw8F5xepuupR5OMt1bCedovTAWH/atJsF9aTd3FoSqEVZAS+jvG2R7w Q6UoDOH8UTVgs9bAlcobjeOk2kWvUg8SZiJyS7IjwBVwEZKFGvjx/KGLX/67mhG0Qu/R 0T8KbazP/h6TOb06DBkscXINYp6jUQIevemEyIOj5T9yheRfc+7f38tS0SBtzuOL2D+v JcOdj8bisiNU5dtqkrVGBnGtOuzfnF7XvvIrCT7ltG39FS0U6n7PmBo0z0A1N8ofJYMb 2tR5v8p4SBvsYBhP5Ii+sYVpLJ3eIbNRHfoTF0G4bW3pcWeUEQQZgNfu6lPI7Vjz/yVb y1sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mLgm8Hki; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si4021778edw.108.2020.08.30.14.06.10; Sun, 30 Aug 2020 14:06:33 -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=@google.com header.s=20161025 header.b=mLgm8Hki; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbgH3VE6 (ORCPT + 99 others); Sun, 30 Aug 2020 17:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgH3VE5 (ORCPT ); Sun, 30 Aug 2020 17:04:57 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7E8DC061573 for ; Sun, 30 Aug 2020 14:04:56 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id 185so2533481oie.11 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=bqe0IrhF9KpId5pmPq91cVA9u3bM2QgPQYss3/aA9qqoHU/mi6aI/ibh0s+8HRtOcD nwyeCNX9pceC8ENFuJg+u9pEu9pRl45K+6FFbJNG4CVrw74GdtyarVFmNRupFndT/H/X zNWWMQ7gZPVIbYelBDTBSWEXkJ1Uy/aoNaPOGQFmJlrNwvu9XS9KuVVikndCw8jSAbn8 jY9cXCRGjgmCLwMc4RL/xAznNVfzwKRWKSJrNSOgEilEWdZznl/wJ/CbtTBWXZCuA7UM GG3HJ1bHXALJiY6h8dQF1p/ab5tGKJfjTwrBsI3nhv4qqH8xC8fHBpvq5gpNEhD4lXz0 PNFg== X-Gm-Message-State: AOAM532vq68GQ5BaPAAINN28I4HjNKSlziNvP1YJtFivdcRZ+hsdV2L4 O7VzXgVMaATlv6aK6aAUTDCSsA== 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 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + BUG_ON(!PageLocked(page)); mapping = page->mapping; index = page->index;