Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

shm: fix the filename of hugetlb sysv shared memory

Some user space tools need to identify SYSV shared memory when examining
/proc/<pid>/maps. To do so they look for a block device with major zero, a
dentry named SYSV<sysv key>, and having the minor of the internal sysv
shared memory kernel mount.

To help these tools and to make it easier for people just browsing
/proc/<pid>/maps this patch modifies hugetlb sysv shared memory to use the
SYSV<key> dentry naming convention.

User space tools will still have to be aware that hugetlb sysv shared
memory lives on a different internal kernel mount and so has a different
block device minor number from the rest of sysv shared memory.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Albert Cahalan <acahalan@gmail.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Eric W. Biederman and committed by
Linus Torvalds
9d66586f 22741925

+7 -10
+2 -5
fs/hugetlbfs/inode.c
··· 736 736 can_do_mlock()); 737 737 } 738 738 739 - struct file *hugetlb_zero_setup(size_t size) 739 + struct file *hugetlb_file_setup(const char *name, size_t size) 740 740 { 741 741 int error = -ENOMEM; 742 742 struct file *file; 743 743 struct inode *inode; 744 744 struct dentry *dentry, *root; 745 745 struct qstr quick_string; 746 - char buf[16]; 747 - static atomic_t counter; 748 746 749 747 if (!hugetlbfs_vfsmount) 750 748 return ERR_PTR(-ENOENT); ··· 754 756 return ERR_PTR(-ENOMEM); 755 757 756 758 root = hugetlbfs_vfsmount->mnt_root; 757 - snprintf(buf, 16, "%u", atomic_inc_return(&counter)); 758 - quick_string.name = buf; 759 + quick_string.name = name; 759 760 quick_string.len = strlen(quick_string.name); 760 761 quick_string.hash = 0; 761 762 dentry = d_alloc(root, &quick_string);
+2 -2
include/linux/hugetlb.h
··· 163 163 164 164 extern const struct file_operations hugetlbfs_file_operations; 165 165 extern struct vm_operations_struct hugetlb_vm_ops; 166 - struct file *hugetlb_zero_setup(size_t); 166 + struct file *hugetlb_file_setup(const char *name, size_t); 167 167 int hugetlb_get_quota(struct address_space *mapping); 168 168 void hugetlb_put_quota(struct address_space *mapping); 169 169 ··· 185 185 186 186 #define is_file_hugepages(file) 0 187 187 #define set_file_hugepages(file) BUG() 188 - #define hugetlb_zero_setup(size) ERR_PTR(-ENOSYS) 188 + #define hugetlb_file_setup(name,size) ERR_PTR(-ENOSYS) 189 189 190 190 #endif /* !CONFIG_HUGETLBFS */ 191 191
+3 -3
ipc/shm.c
··· 366 366 return error; 367 367 } 368 368 369 + sprintf (name, "SYSV%08x", key); 369 370 if (shmflg & SHM_HUGETLB) { 370 - /* hugetlb_zero_setup takes care of mlock user accounting */ 371 - file = hugetlb_zero_setup(size); 371 + /* hugetlb_file_setup takes care of mlock user accounting */ 372 + file = hugetlb_file_setup(name, size); 372 373 shp->mlock_user = current->user; 373 374 } else { 374 375 int acctflag = VM_ACCOUNT; ··· 380 379 if ((shmflg & SHM_NORESERVE) && 381 380 sysctl_overcommit_memory != OVERCOMMIT_NEVER) 382 381 acctflag = 0; 383 - sprintf (name, "SYSV%08x", key); 384 382 file = shmem_file_setup(name, size, acctflag); 385 383 } 386 384 error = PTR_ERR(file);