* [PATCH] tmpfs: change shmem_mapping() to test shmem_aops
@ 2016-12-06 5:52 Hugh Dickins
2016-12-14 21:15 ` Johannes Weiner
0 siblings, 1 reply; 2+ messages in thread
From: Hugh Dickins @ 2016-12-06 5:52 UTC (permalink / raw)
To: Andrew Morton
Cc: Oleg Nesterov, Johannes Weiner, Kirill A. Shutemov, linux-mm
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@google.com>
---
mm/shmem.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
--- 4.9-rc8/mm/shmem.c 2016-11-13 11:44:43.052622519 -0800
+++ linux/mm/shmem.c 2016-12-05 18:54:25.348596732 -0800
@@ -2131,10 +2131,7 @@ static struct inode *shmem_get_inode(str
bool shmem_mapping(struct address_space *mapping)
{
- if (!mapping->host)
- return false;
-
- return mapping->host->i_sb->s_op == &shmem_ops;
+ return mapping->a_ops == &shmem_aops;
}
#ifdef CONFIG_TMPFS
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] tmpfs: change shmem_mapping() to test shmem_aops
2016-12-06 5:52 [PATCH] tmpfs: change shmem_mapping() to test shmem_aops Hugh Dickins
@ 2016-12-14 21:15 ` Johannes Weiner
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Weiner @ 2016-12-14 21:15 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andrew Morton, Oleg Nesterov, Kirill A. Shutemov, linux-mm
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@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
There are actually some existing sites that check for shmemness this
way. Do you see value in converting them?
---
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-14 21:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-06 5:52 [PATCH] tmpfs: change shmem_mapping() to test shmem_aops Hugh Dickins
2016-12-14 21:15 ` Johannes Weiner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.