On Mon, Dec 05, 2016 at 09:52:36PM -0800, Hugh Dickins wrote: > Callers of shmem_mapping() are interested in whether the mapping is > swap backed - except for uprobes, which is interested in whether it > should use shmem_read_mapping_page(). All these callers are better > served by a shmem_mapping() which checks for shmem_aops, than the > current version which goes through several indirections to find where > the inode lives - and has the surprising effect that a private mmap of > /dev/zero satisfies both vma_is_anonymous() and shmem_mapping(), when > that device node is on devtmpfs. I don't think anything in the tree > suffers from that surprise, but it caught me out, and is better fixed. > > Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx> There are actually some existing sites that check for shmemness this way. Do you see value in converting them? --- >From 1f85c9c8b7ec59a804a52f497ed582615b9caed5 Mon Sep 17 00:00:00 2001 From: Johannes Weiner <hannes@xxxxxxxxxxx> Date: Wed, 14 Dec 2016 16:07:35 -0500 Subject: [PATCH] mm: shmem: convert open-coded sites to use shmem_mapping() Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx> --- mm/shmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 41537fd080b9..f1b52c337e62 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1021,7 +1021,7 @@ static void shmem_evict_inode(struct inode *inode) struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); - if (inode->i_mapping->a_ops == &shmem_aops) { + if (shmem_mapping(inode->i_mapping)) { shmem_unacct_size(info->flags, inode->i_size); inode->i_size = 0; shmem_truncate_range(inode, 0, (loff_t)-1); @@ -1671,7 +1671,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, } else { /* shmem_symlink() */ - if (mapping->a_ops != &shmem_aops) + if (!shmem_mapping(mapping)) goto alloc_nohuge; if (shmem_huge == SHMEM_HUGE_DENY || sgp_huge == SGP_NOHUGE) goto alloc_nohuge; @@ -4105,7 +4105,7 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, struct page *page; int error; - BUG_ON(mapping->a_ops != &shmem_aops); + BUG_ON(!shmem_mapping(mapping)); error = shmem_getpage_gfp(inode, index, &page, SGP_CACHE, gfp, NULL, NULL); if (error) -- 2.10.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>