]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: convert uprobes to mm_flags_*() accessors
authorLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Tue, 12 Aug 2025 15:44:14 +0000 (16:44 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 12 Sep 2025 00:24:53 +0000 (17:24 -0700)
As part of the effort to move to mm->flags becoming a bitmap field,
convert existing users to making use of the mm_flags_*() accessors which
will, when the conversion is complete, be the only means of accessing
mm_struct flags.

No functional change intended.

Link: https://lkml.kernel.org/r/1d4fe5963904cc0c707da1f53fbfe6471d3eff10.1755012943.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Borislav Betkov <bp@alien8.de>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Marc Rutland <mark.rutland@arm.com>
Cc: Mariano Pache <npache@redhat.com>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Mel Gorman <mgorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Namhyung kim <namhyung@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: xu xin <xu.xin16@zte.com.cn>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/events/uprobes.c

index 7ca1940607bd8340d2f4d1b74faccd40c1cfdc70..31a12b60055f7814c2b28e1bda8ae920ae3a9e39 100644 (file)
@@ -1153,15 +1153,15 @@ static int install_breakpoint(struct uprobe *uprobe, struct vm_area_struct *vma,
         * set MMF_HAS_UPROBES in advance for uprobe_pre_sstep_notifier(),
         * the task can hit this breakpoint right after __replace_page().
         */
-       first_uprobe = !test_bit(MMF_HAS_UPROBES, &mm->flags);
+       first_uprobe = !mm_flags_test(MMF_HAS_UPROBES, mm);
        if (first_uprobe)
-               set_bit(MMF_HAS_UPROBES, &mm->flags);
+               mm_flags_set(MMF_HAS_UPROBES, mm);
 
        ret = set_swbp(&uprobe->arch, vma, vaddr);
        if (!ret)
-               clear_bit(MMF_RECALC_UPROBES, &mm->flags);
+               mm_flags_clear(MMF_RECALC_UPROBES, mm);
        else if (first_uprobe)
-               clear_bit(MMF_HAS_UPROBES, &mm->flags);
+               mm_flags_clear(MMF_HAS_UPROBES, mm);
 
        return ret;
 }
@@ -1171,7 +1171,7 @@ static int remove_breakpoint(struct uprobe *uprobe, struct vm_area_struct *vma,
 {
        struct mm_struct *mm = vma->vm_mm;
 
-       set_bit(MMF_RECALC_UPROBES, &mm->flags);
+       mm_flags_set(MMF_RECALC_UPROBES, mm);
        return set_orig_insn(&uprobe->arch, vma, vaddr);
 }
 
@@ -1303,7 +1303,7 @@ register_for_each_vma(struct uprobe *uprobe, struct uprobe_consumer *new)
                        /* consult only the "caller", new consumer. */
                        if (consumer_filter(new, mm))
                                err = install_breakpoint(uprobe, vma, info->vaddr);
-               } else if (test_bit(MMF_HAS_UPROBES, &mm->flags)) {
+               } else if (mm_flags_test(MMF_HAS_UPROBES, mm)) {
                        if (!filter_chain(uprobe, mm))
                                err |= remove_breakpoint(uprobe, vma, info->vaddr);
                }
@@ -1595,7 +1595,7 @@ int uprobe_mmap(struct vm_area_struct *vma)
 
        if (vma->vm_file &&
            (vma->vm_flags & (VM_WRITE|VM_SHARED)) == VM_WRITE &&
-           test_bit(MMF_HAS_UPROBES, &vma->vm_mm->flags))
+           mm_flags_test(MMF_HAS_UPROBES, vma->vm_mm))
                delayed_ref_ctr_inc(vma);
 
        if (!valid_vma(vma, true))
@@ -1655,12 +1655,12 @@ void uprobe_munmap(struct vm_area_struct *vma, unsigned long start, unsigned lon
        if (!atomic_read(&vma->vm_mm->mm_users)) /* called by mmput() ? */
                return;
 
-       if (!test_bit(MMF_HAS_UPROBES, &vma->vm_mm->flags) ||
-            test_bit(MMF_RECALC_UPROBES, &vma->vm_mm->flags))
+       if (!mm_flags_test(MMF_HAS_UPROBES, vma->vm_mm) ||
+            mm_flags_test(MMF_RECALC_UPROBES, vma->vm_mm))
                return;
 
        if (vma_has_uprobes(vma, start, end))
-               set_bit(MMF_RECALC_UPROBES, &vma->vm_mm->flags);
+               mm_flags_set(MMF_RECALC_UPROBES, vma->vm_mm);
 }
 
 static vm_fault_t xol_fault(const struct vm_special_mapping *sm,
@@ -1823,10 +1823,10 @@ void uprobe_end_dup_mmap(void)
 
 void uprobe_dup_mmap(struct mm_struct *oldmm, struct mm_struct *newmm)
 {
-       if (test_bit(MMF_HAS_UPROBES, &oldmm->flags)) {
-               set_bit(MMF_HAS_UPROBES, &newmm->flags);
+       if (mm_flags_test(MMF_HAS_UPROBES, oldmm)) {
+               mm_flags_set(MMF_HAS_UPROBES, newmm);
                /* unconditionally, dup_mmap() skips VM_DONTCOPY vmas */
-               set_bit(MMF_RECALC_UPROBES, &newmm->flags);
+               mm_flags_set(MMF_RECALC_UPROBES, newmm);
        }
 }
 
@@ -2370,7 +2370,7 @@ static void mmf_recalc_uprobes(struct mm_struct *mm)
                        return;
        }
 
-       clear_bit(MMF_HAS_UPROBES, &mm->flags);
+       mm_flags_clear(MMF_HAS_UPROBES, mm);
 }
 
 static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
@@ -2468,7 +2468,7 @@ static struct uprobe *find_active_uprobe_rcu(unsigned long bp_vaddr, int *is_swb
                *is_swbp = -EFAULT;
        }
 
-       if (!uprobe && test_and_clear_bit(MMF_RECALC_UPROBES, &mm->flags))
+       if (!uprobe && mm_flags_test_and_clear(MMF_RECALC_UPROBES, mm))
                mmf_recalc_uprobes(mm);
        mmap_read_unlock(mm);
 
@@ -2818,7 +2818,7 @@ int uprobe_pre_sstep_notifier(struct pt_regs *regs)
        if (!current->mm)
                return 0;
 
-       if (!test_bit(MMF_HAS_UPROBES, &current->mm->flags) &&
+       if (!mm_flags_test(MMF_HAS_UPROBES, current->mm) &&
            (!current->utask || !current->utask->return_instances))
                return 0;