Re: [PATCH] ipc/shm.c add ->pagesize function to shm_vm_ops

From: Jane Chu
Date: Mon Jul 30 2018 - 23:09:16 EST


Hi, Davidlohr,

On 7/30/2018 9:44 AM, Davidlohr Bueso wrote:

On Fri, 27 Jul 2018, Jane Chu wrote:

Commit 05ea88608d4e13 (mm, hugetlbfs: introduce ->pagesize() to
vm_operations_struct) adds a new ->pagesize() function to
hugetlb_vm_ops, intended to cover all hugetlbfs backed files.

With System V shared memory model, if "huge page" is specified,
the "shared memory" is backed by hugetlbfs files, but the mappings
initiated via shmget/shmat have their original vm_ops overwritten
with shm_vm_ops, so we need to add a ->pagesize function to shm_vm_ops.
Otherwise, vma_kernel_pagesize() returns PAGE_SIZE given a hugetlbfs
backed vma, result in below BUG:

fs/hugetlbfs/inode.c
ÂÂÂÂÂÂ 443ÂÂÂÂÂÂÂÂÂÂÂÂ if (unlikely(page_mapped(page))) {
ÂÂÂÂÂÂ 444ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ BUG_ON(truncate_op);

[Â 242.268342] hugetlbfs: oracle (4592): Using mlock ulimits for SHM_HUGETLB is deprecated
[Â 282.653208] ------------[ cut here ]------------
[Â 282.708447] kernel BUG at fs/hugetlbfs/inode.c:444!
[Â 282.818957] Modules linked in: nfsv3 rpcsec_gss_krb5 nfsv4 ...
[Â 284.025873] CPU: 35 PID: 5583 Comm: oracle_5583_sbt Not tainted 4.14.35-1829.el7uek.x86_64 #2
[Â 284.246609] task: ffff9bf0507aaf80 task.stack: ffffa9e625628000
[Â 284.317455] RIP: 0010:remove_inode_hugepages+0x3db/0x3e2
....
[Â 285.292389] Call Trace:
[Â 285.321630]Â hugetlbfs_evict_inode+0x1e/0x3e
[Â 285.372707]Â evict+0xdb/0x1af
[Â 285.408185]Â iput+0x1a2/0x1f7
[Â 285.443661]Â dentry_unlink_inode+0xc6/0xf0
[Â 285.492661]Â __dentry_kill+0xd8/0x18d
[Â 285.536459]Â dput+0x1b5/0x1ed
[Â 285.571939]Â __fput+0x18b/0x216
[Â 285.609495]Â ____fput+0xe/0x10
[Â 285.646030]Â task_work_run+0x90/0xa7
[Â 285.688788]Â exit_to_usermode_loop+0xdd/0x116
[Â 285.740905]Â do_syscall_64+0x187/0x1ae
[Â 285.785740]Â entry_SYSCALL_64_after_hwframe+0x150/0x0

Suggested-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
Signed-off-by: Jane Chu <jane.chu@xxxxxxxxxx>

Acked-by: Davidlohr Bueso <dbueso@xxxxxxx>

Thank you!

-jane