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.

mm: convert uprobes to mm_flags_*() accessors

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>

authored by

Lorenzo Stoakes and committed by
Andrew Morton
c0951573 4141c2dc

+16 -16
+16 -16
kernel/events/uprobes.c
··· 1153 1153 * set MMF_HAS_UPROBES in advance for uprobe_pre_sstep_notifier(), 1154 1154 * the task can hit this breakpoint right after __replace_page(). 1155 1155 */ 1156 - first_uprobe = !test_bit(MMF_HAS_UPROBES, &mm->flags); 1156 + first_uprobe = !mm_flags_test(MMF_HAS_UPROBES, mm); 1157 1157 if (first_uprobe) 1158 - set_bit(MMF_HAS_UPROBES, &mm->flags); 1158 + mm_flags_set(MMF_HAS_UPROBES, mm); 1159 1159 1160 1160 ret = set_swbp(&uprobe->arch, vma, vaddr); 1161 1161 if (!ret) 1162 - clear_bit(MMF_RECALC_UPROBES, &mm->flags); 1162 + mm_flags_clear(MMF_RECALC_UPROBES, mm); 1163 1163 else if (first_uprobe) 1164 - clear_bit(MMF_HAS_UPROBES, &mm->flags); 1164 + mm_flags_clear(MMF_HAS_UPROBES, mm); 1165 1165 1166 1166 return ret; 1167 1167 } ··· 1171 1171 { 1172 1172 struct mm_struct *mm = vma->vm_mm; 1173 1173 1174 - set_bit(MMF_RECALC_UPROBES, &mm->flags); 1174 + mm_flags_set(MMF_RECALC_UPROBES, mm); 1175 1175 return set_orig_insn(&uprobe->arch, vma, vaddr); 1176 1176 } 1177 1177 ··· 1303 1303 /* consult only the "caller", new consumer. */ 1304 1304 if (consumer_filter(new, mm)) 1305 1305 err = install_breakpoint(uprobe, vma, info->vaddr); 1306 - } else if (test_bit(MMF_HAS_UPROBES, &mm->flags)) { 1306 + } else if (mm_flags_test(MMF_HAS_UPROBES, mm)) { 1307 1307 if (!filter_chain(uprobe, mm)) 1308 1308 err |= remove_breakpoint(uprobe, vma, info->vaddr); 1309 1309 } ··· 1595 1595 1596 1596 if (vma->vm_file && 1597 1597 (vma->vm_flags & (VM_WRITE|VM_SHARED)) == VM_WRITE && 1598 - test_bit(MMF_HAS_UPROBES, &vma->vm_mm->flags)) 1598 + mm_flags_test(MMF_HAS_UPROBES, vma->vm_mm)) 1599 1599 delayed_ref_ctr_inc(vma); 1600 1600 1601 1601 if (!valid_vma(vma, true)) ··· 1655 1655 if (!atomic_read(&vma->vm_mm->mm_users)) /* called by mmput() ? */ 1656 1656 return; 1657 1657 1658 - if (!test_bit(MMF_HAS_UPROBES, &vma->vm_mm->flags) || 1659 - test_bit(MMF_RECALC_UPROBES, &vma->vm_mm->flags)) 1658 + if (!mm_flags_test(MMF_HAS_UPROBES, vma->vm_mm) || 1659 + mm_flags_test(MMF_RECALC_UPROBES, vma->vm_mm)) 1660 1660 return; 1661 1661 1662 1662 if (vma_has_uprobes(vma, start, end)) 1663 - set_bit(MMF_RECALC_UPROBES, &vma->vm_mm->flags); 1663 + mm_flags_set(MMF_RECALC_UPROBES, vma->vm_mm); 1664 1664 } 1665 1665 1666 1666 static vm_fault_t xol_fault(const struct vm_special_mapping *sm, ··· 1823 1823 1824 1824 void uprobe_dup_mmap(struct mm_struct *oldmm, struct mm_struct *newmm) 1825 1825 { 1826 - if (test_bit(MMF_HAS_UPROBES, &oldmm->flags)) { 1827 - set_bit(MMF_HAS_UPROBES, &newmm->flags); 1826 + if (mm_flags_test(MMF_HAS_UPROBES, oldmm)) { 1827 + mm_flags_set(MMF_HAS_UPROBES, newmm); 1828 1828 /* unconditionally, dup_mmap() skips VM_DONTCOPY vmas */ 1829 - set_bit(MMF_RECALC_UPROBES, &newmm->flags); 1829 + mm_flags_set(MMF_RECALC_UPROBES, newmm); 1830 1830 } 1831 1831 } 1832 1832 ··· 2370 2370 return; 2371 2371 } 2372 2372 2373 - clear_bit(MMF_HAS_UPROBES, &mm->flags); 2373 + mm_flags_clear(MMF_HAS_UPROBES, mm); 2374 2374 } 2375 2375 2376 2376 static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr) ··· 2468 2468 *is_swbp = -EFAULT; 2469 2469 } 2470 2470 2471 - if (!uprobe && test_and_clear_bit(MMF_RECALC_UPROBES, &mm->flags)) 2471 + if (!uprobe && mm_flags_test_and_clear(MMF_RECALC_UPROBES, mm)) 2472 2472 mmf_recalc_uprobes(mm); 2473 2473 mmap_read_unlock(mm); 2474 2474 ··· 2818 2818 if (!current->mm) 2819 2819 return 0; 2820 2820 2821 - if (!test_bit(MMF_HAS_UPROBES, &current->mm->flags) && 2821 + if (!mm_flags_test(MMF_HAS_UPROBES, current->mm) && 2822 2822 (!current->utask || !current->utask->return_instances)) 2823 2823 return 0; 2824 2824