Patch "perf: Optimize perf_pmu_migrate_context()" has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf: Optimize perf_pmu_migrate_context()

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-optimize-perf_pmu_migrate_context.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 24a51b8ceb8373226899a73bebc5be99d14b18d6
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date:   Mon Apr 3 11:08:58 2023 +0200

    perf: Optimize perf_pmu_migrate_context()
    
    [ Upstream commit b168098912926236bbeebaf7795eb7aab76d2b45 ]
    
    Thomas reported that offlining CPUs spends a lot of time in
    synchronize_rcu() as called from perf_pmu_migrate_context() even though
    he's not actually using uncore events.
    
    Turns out, the thing is unconditionally waiting for RCU, even if there's
    no actual events to migrate.
    
    Fixes: 0cda4c023132 ("perf: Introduce perf_pmu_migrate_context()")
    Reported-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
    Tested-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Reviewed-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Reviewed-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
    Link: https://lkml.kernel.org/r/20230403090858.GT4253@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/events/core.c b/kernel/events/core.c
index fad170b475921..4b3205f6bed5e 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -12875,12 +12875,14 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu)
 	__perf_pmu_remove(src_ctx, src_cpu, pmu, &src_ctx->pinned_groups, &events);
 	__perf_pmu_remove(src_ctx, src_cpu, pmu, &src_ctx->flexible_groups, &events);
 
-	/*
-	 * Wait for the events to quiesce before re-instating them.
-	 */
-	synchronize_rcu();
+	if (!list_empty(&events)) {
+		/*
+		 * Wait for the events to quiesce before re-instating them.
+		 */
+		synchronize_rcu();
 
-	__perf_pmu_install(dst_ctx, dst_cpu, pmu, &events);
+		__perf_pmu_install(dst_ctx, dst_cpu, pmu, &events);
+	}
 
 	mutex_unlock(&dst_ctx->mutex);
 	mutex_unlock(&src_ctx->mutex);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux