From patchwork Fri Mar 4 04:15:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12768440 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 10EE9C433EF for ; Fri, 4 Mar 2022 04:15:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94F608D0002; Thu, 3 Mar 2022 23:15:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D6928D0001; Thu, 3 Mar 2022 23:15:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C66F8D0002; Thu, 3 Mar 2022 23:15:15 -0500 (EST) 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 6E83D8D0001 for ; Thu, 3 Mar 2022 23:15:15 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3D43823551 for ; Fri, 4 Mar 2022 04:15:15 +0000 (UTC) X-FDA: 79205388990.15.8CEBAAC Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by imf17.hostedemail.com (Postfix) with ESMTP id BD9FB40008 for ; Fri, 4 Mar 2022 04:15:14 +0000 (UTC) Received: by mail-ot1-f52.google.com with SMTP id k9-20020a056830242900b005ad25f8ebfdso6452701ots.7 for ; Thu, 03 Mar 2022 20:15:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version; bh=hiQtnrOduuW7BW90xYXmhrv/eSP4mmgn+idI2n3K9fc=; b=QU/lW7kQkitT6k7Ffnu4URV7kwjP3KK0xNFeOXJ1jO1EuFikMFRNg/96S4t5Hwtind 41T9ofu0g++aS8z9C/cHnafXFrcWNH3fIHbilVVO5j5mczlSYDyODv/Pv1ewtEYS/r2n ueiK3J38Esi6Csl3Bc87xXV6Ch/rH6UZliuxEfnmwqJidQReYJQIrM99P3Zxfnf4l3Db 68ER8sxiUu0NgfU/08piqEG4PSMUFpAEyZaCXcdCajeqCiXVf+8wMy0cmfdYJVekVMeM 008oSSCHOgKAV827TsdRt2VYJqqvx2CMl2CutyHFvukKxY9rZ+cdozxwW9tlGz+UoZdh rMSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version; bh=hiQtnrOduuW7BW90xYXmhrv/eSP4mmgn+idI2n3K9fc=; b=usspcceDdPtuPx4ODyr92yBD9rFd3YAKJZ2/kVCqT4su+1/77YMxYOtWyJx4IXohYl o3CFmHRLafJWlK98xgCgMHEMMAMO2Fmg4sw7dhbL21qq1w7stOI/HfAJ0yf6LYc/c1Di K6zS6IBot4sEkqd54Q5TZhOMK3vHP72eK1TgLXj7Fri4JInxOr6Tw8Os+07OlD2hyt0J 0Zy1WqIdfSxxJXyST1nxiuKMBXW69UOf8/9x/pO2QOEBrVDCoVsXlPxeNuVyfemPW+Lo Y75x9woMF+cmXfkEvW88wz7clnUDzijXSeB7EVl3tD/iw+y6H5ANo4fUXDEYYq/G43q1 G8PQ== X-Gm-Message-State: AOAM533Q9R+7bP9RmtmklVChSPwkrmI+P4OJan/cVyWbCMibPdqKrfA4 nIuQl41PT6m8ZUUyGEXyfWPfqjZMdipRAg== X-Google-Smtp-Source: ABdhPJwfmf/SyXiLX1p8JjJdtL8b+QTmNlZ1aWE5uD7cx+QyTZ+kc6QhmHbz3Eo9hdrTZRBgGqEV1A== X-Received: by 2002:a05:6830:1cc2:b0:5af:f66a:55bb with SMTP id p2-20020a0568301cc200b005aff66a55bbmr16601690otg.224.1646367313924; Thu, 03 Mar 2022 20:15:13 -0800 (PST) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id h5-20020a056870170500b000d17a9b25d8sm2073735oae.26.2022.03.03.20.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 20:15:13 -0800 (PST) Date: Thu, 3 Mar 2022 20:15:11 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Andrew Morton cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH mmotm] shmem: mapping_set_exiting() to help mapped resilience Message-ID: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: BD9FB40008 X-Stat-Signature: pbf193jrkar6pmr16p6bfja7xnowi4g4 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="QU/lW7kQ"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of hughd@google.com designates 209.85.210.52 as permitted sender) smtp.mailfrom=hughd@google.com X-HE-Tag: 1646367314-265308 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: 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". Fixes: 06b241f32c71 ("mm: __delete_from_page_cache show Bad page if mapped") Signed-off-by: Hugh Dickins --- mm/shmem.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1129,6 +1129,7 @@ static void shmem_evict_inode(struct inode *inode) 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);