From patchwork Tue Mar 22 21:39:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12789070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 652B3C433F5 for ; Tue, 22 Mar 2022 21:40:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8E996B007B; Tue, 22 Mar 2022 17:40:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3BED6B007E; Tue, 22 Mar 2022 17:40:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2BFD6B0082; Tue, 22 Mar 2022 17:40:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id C39AD6B007B for ; Tue, 22 Mar 2022 17:40:02 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 990AF81A34 for ; Tue, 22 Mar 2022 21:40:02 +0000 (UTC) X-FDA: 79273340244.07.4208386 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf21.hostedemail.com (Postfix) with ESMTP id 2EA131C0027 for ; Tue, 22 Mar 2022 21:40:02 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F007DB81DAF; Tue, 22 Mar 2022 21:40:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80C97C340EC; Tue, 22 Mar 2022 21:39:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647985199; bh=WwkNuOjD3DZPNyweqoSPUm+7FixY1iuGDWC8FvdWHQE=; h=Date:To:From:In-Reply-To:Subject:From; b=S8WEkbVc++ytJtd8t6sAEtqoJLZlKhwLjg5pm0/AFmTKXWS46OX8rc4qbNO76X5Xs mNMT5oOLF+GA3mWPhFP1fWfM+xcxSozwxJl6m75pqGMgpOxwT+/gO/u/Yikl2GSf+u jK3PxN4Oo/sot7853ON+MWMPLl/qFqwdaDGTObk4= Date: Tue, 22 Mar 2022 14:39:58 -0700 To: hughd@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220322143803.04a5e59a07e48284f196a2f9@linux-foundation.org> Subject: [patch 029/227] shmem: mapping_set_exiting() to help mapped resilience Message-Id: <20220322213959.80C97C340EC@smtp.kernel.org> Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=S8WEkbVc; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: jgzapooe6e43kqfaw9ajzu8qmpdfcqm5 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2EA131C0027 X-HE-Tag: 1647985202-771006 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: From: Hugh Dickins Subject: shmem: mapping_set_exiting() to help mapped resilience When I added page_mapped() resilience in __delete_from_page_cache() for the mapping_exiting() case, I missed that mapping_set_exiting() is done in truncate_inode_pages_final(), which is not actually called for shmem. (Today, it is folio_mapped() resilience in filemap_unaccount_folio().) So the fixup to avoid a memory leak in this case never worked on shmem: add a mapping_set_exiting() in shmem_evict_inode() at last. But this is hardly a candidate for stable, since it's only useful if "Bad page". Link: https://lkml.kernel.org/r/beefffda-6326-e36d-2d41-ed15b51af872@google.com Fixes: 06b241f32c71 ("mm: __delete_from_page_cache show Bad page if mapped") Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton --- mm/shmem.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/shmem.c~shmem-mapping_set_exiting-to-help-mapped-resilience +++ a/mm/shmem.c @@ -1129,6 +1129,7 @@ static void shmem_evict_inode(struct ino if (shmem_mapping(inode->i_mapping)) { shmem_unacct_size(info->flags, inode->i_size); inode->i_size = 0; + mapping_set_exiting(inode->i_mapping); shmem_truncate_range(inode, 0, (loff_t)-1); if (!list_empty(&info->shrinklist)) { spin_lock(&sbinfo->shrinklist_lock);