Skip to content

Commit 5e3cb66

Browse files
mjkravetzsmb49
authored andcommitted
hugetlbfs: hugetlb_fault_mutex_hash() cleanup
BugLink: https://bugs.launchpad.net/bugs/1923220 commit 5525463 upstream. A new clang diagnostic (-Wsizeof-array-div) warns about the calculation to determine the number of u32's in an array of unsigned longs. Suppress warning by adding parentheses. While looking at the above issue, noticed that the 'address' parameter to hugetlb_fault_mutex_hash is no longer used. So, remove it from the definition and all callers. No functional change. Link: http://lkml.kernel.org/r/20190919011847.18400-1-mike.kravetz@oracle.com Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com> Reported-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: Davidlohr Bueso <dbueso@suse.de> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Ilie Halip <ilie.halip@gmail.com> Cc: David Bolvansky <david.bolvansky@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 5914e8c commit 5e3cb66

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

fs/hugetlbfs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
440440
u32 hash;
441441

442442
index = page->index;
443-
hash = hugetlb_fault_mutex_hash(h, mapping, index, 0);
443+
hash = hugetlb_fault_mutex_hash(h, mapping, index);
444444
mutex_lock(&hugetlb_fault_mutex_table[hash]);
445445

446446
/*
@@ -644,7 +644,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
644644
addr = index * hpage_size;
645645

646646
/* mutex taken here, fault path and hole punch */
647-
hash = hugetlb_fault_mutex_hash(h, mapping, index, addr);
647+
hash = hugetlb_fault_mutex_hash(h, mapping, index);
648648
mutex_lock(&hugetlb_fault_mutex_table[hash]);
649649

650650
/* See if already present in mapping to avoid alloc/free */

include/linux/hugetlb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void free_huge_page(struct page *page);
106106
void hugetlb_fix_reserve_counts(struct inode *inode);
107107
extern struct mutex *hugetlb_fault_mutex_table;
108108
u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
109-
pgoff_t idx, unsigned long address);
109+
pgoff_t idx);
110110

111111
pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud);
112112

mm/hugetlb.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4020,7 +4020,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
40204020
* handling userfault. Reacquire after handling
40214021
* fault to make calling code simpler.
40224022
*/
4023-
hash = hugetlb_fault_mutex_hash(h, mapping, idx, haddr);
4023+
hash = hugetlb_fault_mutex_hash(h, mapping, idx);
40244024
mutex_unlock(&hugetlb_fault_mutex_table[hash]);
40254025
ret = handle_userfault(&vmf, VM_UFFD_MISSING);
40264026
mutex_lock(&hugetlb_fault_mutex_table[hash]);
@@ -4148,15 +4148,15 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
41484148

41494149
#ifdef CONFIG_SMP
41504150
u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
4151-
pgoff_t idx, unsigned long address)
4151+
pgoff_t idx)
41524152
{
41534153
unsigned long key[2];
41544154
u32 hash;
41554155

41564156
key[0] = (unsigned long) mapping;
41574157
key[1] = idx;
41584158

4159-
hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
4159+
hash = jhash2((u32 *)&key, sizeof(key)/(sizeof(u32)), 0);
41604160

41614161
return hash & (num_fault_mutexes - 1);
41624162
}
@@ -4166,7 +4166,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
41664166
* return 0 and avoid the hashing overhead.
41674167
*/
41684168
u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
4169-
pgoff_t idx, unsigned long address)
4169+
pgoff_t idx)
41704170
{
41714171
return 0;
41724172
}
@@ -4210,7 +4210,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
42104210
* get spurious allocation failures if two CPUs race to instantiate
42114211
* the same page in the page cache.
42124212
*/
4213-
hash = hugetlb_fault_mutex_hash(h, mapping, idx, haddr);
4213+
hash = hugetlb_fault_mutex_hash(h, mapping, idx);
42144214
mutex_lock(&hugetlb_fault_mutex_table[hash]);
42154215

42164216
entry = huge_ptep_get(ptep);

mm/userfaultfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
269269
*/
270270
idx = linear_page_index(dst_vma, dst_addr);
271271
mapping = dst_vma->vm_file->f_mapping;
272-
hash = hugetlb_fault_mutex_hash(h, mapping, idx, dst_addr);
272+
hash = hugetlb_fault_mutex_hash(h, mapping, idx);
273273
mutex_lock(&hugetlb_fault_mutex_table[hash]);
274274

275275
err = -ENOMEM;

0 commit comments

Comments
 (0)