Merge branch 'akpm' (patches from Andrew)
[linux-block.git] / kernel / bpf / stackmap.c
index 7b8381ce40a03b41e90004f7c87fd18c483f1656..599488f25e4044cde56550c051381af592164dd8 100644 (file)
@@ -33,7 +33,7 @@ struct bpf_stack_map {
 /* irq_work to run up_read() for build_id lookup in nmi context */
 struct stack_map_irq_work {
        struct irq_work irq_work;
-       struct rw_semaphore *sem;
+       struct mm_struct *mm;
 };
 
 static void do_up_read(struct irq_work *entry)
@@ -44,8 +44,7 @@ static void do_up_read(struct irq_work *entry)
                return;
 
        work = container_of(entry, struct stack_map_irq_work, irq_work);
-       up_read_non_owner(work->sem);
-       work->sem = NULL;
+       mmap_read_unlock_non_owner(work->mm);
 }
 
 static DEFINE_PER_CPU(struct stack_map_irq_work, up_read_work);
@@ -317,7 +316,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
         * with build_id.
         */
        if (!user || !current || !current->mm || irq_work_busy ||
-           down_read_trylock(&current->mm->mmap_sem) == 0) {
+           !mmap_read_trylock_non_owner(current->mm)) {
                /* cannot access current->mm, fall back to ips */
                for (i = 0; i < trace_nr; i++) {
                        id_offs[i].status = BPF_STACK_BUILD_ID_IP;
@@ -342,16 +341,10 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
        }
 
        if (!work) {
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock_non_owner(current->mm);
        } else {
-               work->sem = &current->mm->mmap_sem;
+               work->mm = current->mm;
                irq_work_queue(&work->irq_work);
-               /*
-                * The irq_work will release the mmap_sem with
-                * up_read_non_owner(). The rwsem_release() is called
-                * here to release the lock from lockdep's perspective.
-                */
-               rwsem_release(&current->mm->mmap_sem.dep_map, _RET_IP_);
        }
 }