linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH mmotm] shmem: mapping_set_exiting() to help mapped resilience
@ 2022-03-04  4:15 Hugh Dickins
  0 siblings, 0 replies; only message in thread
From: Hugh Dickins @ 2022-03-04  4:15 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-mm

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 <hughd@google.com>
---

 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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-04  4:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04  4:15 [PATCH mmotm] shmem: mapping_set_exiting() to help mapped resilience Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox