mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
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
This commit is contained in:
@@ -7146,30 +7146,23 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
if (vma_size != PAGE_SIZE * nr_pages)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&event->mmap_mutex);
|
||||
ret = -EINVAL;
|
||||
scoped_guard (mutex, &event->mmap_mutex) {
|
||||
/*
|
||||
* This relies on __pmu_detach_event() taking mmap_mutex after marking
|
||||
* the event REVOKED. Either we observe the state, or __pmu_detach_event()
|
||||
* will detach the rb created here.
|
||||
*/
|
||||
if (event->state <= PERF_EVENT_STATE_REVOKED)
|
||||
return -ENODEV;
|
||||
|
||||
/*
|
||||
* This relies on __pmu_detach_event() taking mmap_mutex after marking
|
||||
* the event REVOKED. Either we observe the state, or __pmu_detach_event()
|
||||
* will detach the rb created here.
|
||||
*/
|
||||
if (event->state <= PERF_EVENT_STATE_REVOKED) {
|
||||
ret = -ENODEV;
|
||||
goto unlock;
|
||||
if (vma->vm_pgoff == 0)
|
||||
ret = perf_mmap_rb(vma, event, nr_pages);
|
||||
else
|
||||
ret = perf_mmap_aux(vma, event, nr_pages);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (vma->vm_pgoff == 0)
|
||||
ret = perf_mmap_rb(vma, event, nr_pages);
|
||||
else
|
||||
ret = perf_mmap_aux(vma, event, nr_pages);
|
||||
|
||||
unlock:
|
||||
mutex_unlock(&event->mmap_mutex);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* Since pinned accounting is per vm we cannot allow fork() to copy our
|
||||
* vma.
|
||||
|
||||
Reference in New Issue
Block a user