Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1630936pxm; Thu, 3 Mar 2022 23:54:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyG4sAZZSz59M8oZbu/ZABhxXmlK1fn11eCP27tidv2nFAxz7ghcfCivQ+0YKCY4YkPeqEp X-Received: by 2002:a05:6a00:140f:b0:4e0:6995:9c48 with SMTP id l15-20020a056a00140f00b004e069959c48mr41944753pfu.59.1646380478430; Thu, 03 Mar 2022 23:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646380478; cv=none; d=google.com; s=arc-20160816; b=Xva8ouGNQdpgVSrtkYbPAzVDHUCxHx7MTSFqcwyItbBB2NsZ5IzvcoieoZKPEHWgG1 opI4xkKaq4B6e/zjKsghimdEUeBgeT2Vl93dLRuuOHp17vc8FhQXqm0zXTZBuQ57OqFE TxLqq8nhLx89040VY4W8KxKAMqxnMFldn5t45AOcGWUDDWwF4bt3SUkpHuF2U3m8PXVc eFJjUjw5EMaudIz+PI8TC/cekOhk8aw7SCO/0BG+GOwSA0tMaxoF0/YmIU5pPhLBfHhY 0PrwB/HZStUMWfdGyB/Kog5C/0aBzTaCWUQPYY7CYIvDHEuaC4OI3nJSUBJu3fhZJ6JV LZBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=hiQtnrOduuW7BW90xYXmhrv/eSP4mmgn+idI2n3K9fc=; b=JB/PlyyYYCx6Cw/U1HoBpwSdBnWqeAWMXS4yEhw4V98p8jHJZO3frgBTFTjK0J/Q32 ApKJRYtPUVVk6V0KQBUiL/FRvj0lFh8XoB11/CHuPcjVdck6C8uUya/dl5u/NX4lL8aJ V/pwiVJn7ESdiZ3BEFLQgN/rW2nr0HJi8nRl2BAtmbFUrI0X1WMKj7mQO6FXpzTnIWW9 hN79a9Jm2HLa2KWzFDgTwt5RehXPF6ml4JKvAZs3rcG4Xzq7YpD9nc8xRfSRVwdq+vr3 AJgOMx4Y/qTT4oHawwKmtXCLECUNZ4ChBTa31DF2UsJuyAYBYq+16rp5csKzioB1Lmqp 5u1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="QU/lW7kQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a170902a60800b0014f992a21dbsi3714399plq.111.2022.03.03.23.54.23; Thu, 03 Mar 2022 23:54:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="QU/lW7kQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237877AbiCDEQD (ORCPT + 99 others); Thu, 3 Mar 2022 23:16:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231585AbiCDEQC (ORCPT ); Thu, 3 Mar 2022 23:16:02 -0500 Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C51D417FD2C for ; Thu, 3 Mar 2022 20:15:14 -0800 (PST) Received: by mail-ot1-x330.google.com with SMTP id g6-20020a9d6486000000b005acf9a0b644so6425431otl.12 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=SmIh9Cl8o5ekqPtt8BwHDS4P43chZYnNCVZ2Rib1/qJv0nlJSVSlrpPYEq6r0fDJ37 WwLVa4zTC6nELkyrIoO+I1GuE7ggB7dIQyVnjRYeOrJ3WMt6ZWDCS7ZlmMes6HXKN/Bc 4vHExHDu2JcLjaqiMwDJeaQlcNwZC4pJulKZ97bBaowWDgZ0O9Ynzr9D41snb/2+Shon yFMHr/eYRkrHlA7b2L8LDkC6oQ8uev/1Lr0jW8uNv3oOGUuWYM24SRxxFY/Y6xZvByU1 iB9srsUUqQ+NqxJ/6HK91D7/5PlEi79JRu6QjFfBb2z1YrpQ4MJDr6BtIl85dBvSgI91 mSPA== X-Gm-Message-State: AOAM53297QxJxFiJC2HYp3nu1l0EOM+jHTnmo3tYEP4wkqN3RPIwpPWO uDHlbodhWRpiT0fxuHnz2LO+eA== 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 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);