aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/futex/core.c16
2 files changed, 13 insertions, 5 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index af673856499d..c4ada32598bd 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -689,7 +689,6 @@ void __mmdrop(struct mm_struct *mm)
mm_pasid_drop(mm);
mm_destroy_cid(mm);
percpu_counter_destroy_many(mm->rss_stat, NR_MM_COUNTERS);
- futex_hash_free(mm);
free_mm(mm);
}
@@ -1138,6 +1137,7 @@ static inline void __mmput(struct mm_struct *mm)
if (mm->binfmt)
module_put(mm->binfmt->module);
lru_gen_del_mm(mm);
+ futex_hash_free(mm);
mmdrop(mm);
}
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index d9bb5567af0c..125804fbb5cb 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1722,12 +1722,9 @@ int futex_mm_init(struct mm_struct *mm)
RCU_INIT_POINTER(mm->futex_phash, NULL);
mm->futex_phash_new = NULL;
/* futex-ref */
+ mm->futex_ref = NULL;
atomic_long_set(&mm->futex_atomic, 0);
mm->futex_batches = get_state_synchronize_rcu();
- mm->futex_ref = alloc_percpu(unsigned int);
- if (!mm->futex_ref)
- return -ENOMEM;
- this_cpu_inc(*mm->futex_ref); /* 0 -> 1 */
return 0;
}
@@ -1801,6 +1798,17 @@ static int futex_hash_allocate(unsigned int hash_slots, unsigned int flags)
}
}
+ if (!mm->futex_ref) {
+ /*
+ * This will always be allocated by the first thread and
+ * therefore requires no locking.
+ */
+ mm->futex_ref = alloc_percpu(unsigned int);
+ if (!mm->futex_ref)
+ return -ENOMEM;
+ this_cpu_inc(*mm->futex_ref); /* 0 -> 1 */
+ }
+
fph = kvzalloc(struct_size(fph, queues, hash_slots),
GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
if (!fph)
06mm/shmem: add hugetlbfs support to memfd_create()Mike Kravetz2-6/+55 2017-09-06mm, devm_memremap_pages: use multi-order radix for ZONE_DEVICE lookupsDan Williams2-14/+39 2017-09-06mm/vmalloc.c: halve the number of comparisons performed in pcpu_get_vm_areas()Wei Yang1-7/+3 2017-09-06mm/vmstat: fix divide error at __fragmentation_indexWen Yang1-0/+3 2017-09-06mm, hugetlb: do not allocate non-migrateable gigantic pages from movable zonesMichal Hocko1-15/+20 2017-09-06userfaultfd: provide pid in userfault msg - add feat unionAndrea Arcangeli2-2/+4 2017-09-06userfaultfd: provide pid in userfault msgAlexey Perevalov2-5/+13 2017-09-06userfaultfd: call userfaultfd_unmap_prep only if __split_vma succeedsAndrea Arcangeli1-7/+15 2017-09-06userfaultfd: selftest: explicit failure if the SIGBUS test failedAndrea Arcangeli1-1/+3 2017-09-06userfaultfd: selftest: exercise UFFDIO_COPY/ZEROPAGE -EEXISTAndrea Arcangeli1-8/+140 2017-09-06userfaultfd: selftest: add tests for UFFD_FEATURE_SIGBUS featurePrakash Sangappa1-3/+124 2017-09-06mm: userfaultfd: add feature to request for a signal deliveryPrakash Sangappa2-1/+12 2017-09-06mm: rename global_page_state to global_zone_page_stateMichal Hocko9-25/+25 2017-09-06mm: shm: use new hugetlb size encoding definitionsMike Kravetz2-19/+29 2017-09-06mm: arch: consolidate mmap hugetlb size encodingsMike Kravetz8-74/+22