Re: [PATCH v2] mm/shmem.c: make shmem_mapping() inline

Matthew Wilcox
2020-11-14T19:12:10Z

On Sat, Nov 14, 2020 at 10:50:39AM -0800, Andrew Morton wrote:
> But really, shmem_mapping() isn't worth an out-of-line call from any
> callsite - it would be best to make it inlined everywhere.
>
> - make shmem_aops global
> - declare shmem_aops in shmem_fs.h
> - export shmem_aops to modules for drivers/dma-buf/udmabuf.c
> - include linux/fs.h in shmem_fs.h for address_space_operations (we already
> include fs.h via swap.h, but we shouldn't depend on that)
> - make shmem_mapping() a static inline in shmem_fs.h.

... or use an AS_ bit to make shmem_mapping() global inline without
exposing the shmem_aops symbol. We're not short of AS_ bits, and it's
probably even cheaper than a pointer comparison.

A really good changelog would explain why we need shmem_mapping()
everywhere that we currently use it. It's not immediately obvious why
so many places need to know.