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.

perf: Use scoped_guard() for mmap_mutex in perf_mmap()

Mostly just re-indent noise.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Link: https://lore.kernel.org/r/20250812104019.838047976@infradead.org

+14 -21
+14 -21
kernel/events/core.c
··· 7146 7146 if (vma_size != PAGE_SIZE * nr_pages) 7147 7147 return -EINVAL; 7148 7148 7149 - mutex_lock(&event->mmap_mutex); 7150 - ret = -EINVAL; 7149 + scoped_guard (mutex, &event->mmap_mutex) { 7150 + /* 7151 + * This relies on __pmu_detach_event() taking mmap_mutex after marking 7152 + * the event REVOKED. Either we observe the state, or __pmu_detach_event() 7153 + * will detach the rb created here. 7154 + */ 7155 + if (event->state <= PERF_EVENT_STATE_REVOKED) 7156 + return -ENODEV; 7151 7157 7152 - /* 7153 - * This relies on __pmu_detach_event() taking mmap_mutex after marking 7154 - * the event REVOKED. Either we observe the state, or __pmu_detach_event() 7155 - * will detach the rb created here. 7156 - */ 7157 - if (event->state <= PERF_EVENT_STATE_REVOKED) { 7158 - ret = -ENODEV; 7159 - goto unlock; 7158 + if (vma->vm_pgoff == 0) 7159 + ret = perf_mmap_rb(vma, event, nr_pages); 7160 + else 7161 + ret = perf_mmap_aux(vma, event, nr_pages); 7162 + if (ret) 7163 + return ret; 7160 7164 } 7161 - 7162 - if (vma->vm_pgoff == 0) 7163 - ret = perf_mmap_rb(vma, event, nr_pages); 7164 - else 7165 - ret = perf_mmap_aux(vma, event, nr_pages); 7166 - 7167 - unlock: 7168 - mutex_unlock(&event->mmap_mutex); 7169 - 7170 - if (ret) 7171 - return ret; 7172 7165 7173 7166 /* 7174 7167 * Since pinned accounting is per vm we cannot allow fork() to copy our