cpufreq: Move cancelling of policy update work just after removing notifiers
PATCH 1/1 cpufreq: Move cancelling of policy update work just after removing notifiers
Commit 099967699ad9 ("cpufreq: Cancel policy update work scheduled before freeing") added cancel_work_sync(policy->update) after the frequency QoS were removed. We can cancel the work just after taking the last CPU in the policy offline and unregistering the notifiers as policy->update cannot be scheduled from anywhere at this point.
However, due to other bugs, doing so still triggered the race between freeing of policy and scheduled policy update work. Now that all those issues are resolved, we can move this cancelling of any scheduled policy update work just after removing min/max notifiers.
--- drivers/cpufreq/cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Hi Rafael,
Based on Viresh's suggestion, I am posting a patch to move this cancel_work_sync earlier though it's not a must have change. I will leave it up to your preference.
Regards,
Sudeep
drivers/cpufreq/cpufreq.c +3 -2
@@ -1268,6 +1268,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)freq_qos_remove_notifier (&policy->constraints,FREQ_QOS_MIN , &policy->nb_min); +/* Cancel any pending policy->update work before freeing the policy. */ +cancel_work_sync (&policy->update); +if (policy->max_freq_req) {/* * CPUFREQ_CREATE_POLICY notification is sent only after
@@ -1279,8 +1282,6 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) }freq_qos_remove_request (policy->min_freq_req); -/* Cancel any pending policy->update work before freeing the policy. */ -cancel_work_sync (&policy->update);kfree (policy->min_freq_req);cpufreq_policy_put_kobj (policy);
Signature · 1 line
2.17.1
Quoted 12 lines · Sudeep Holla
Commit
099967699ad9("cpufreq: Cancel policy update work scheduled before freeing") addedcancel_work_sync(policy->update)after the frequency QoS were removed. We can cancel the work just after taking the last CPU in the policy offline and unregistering the notifiers aspolicy->updatecannot be scheduled from anywhere at this point.However, due to other bugs, doing so still triggered the race between freeing of policy and scheduled policy update work. Now that all those issues are resolved, we can move this cancelling of any scheduled policy update work just after removing min/max notifiers.
Signed-off-by Sudeep Holla <[email protected]>
Quoted 8 lines
--- drivers/cpufreq/cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)Hi Rafael,
Based on Viresh's suggestion, I am posting a patch to move this
cancel_work_syncearlier though it's not a must have change.
For me it is :)
Quoted 20 lines
I will leave it up to your preference.
Regards,
Sudeepdrivers/cpufreq/cpufreq.c +3
-0@@ -1268,6 +1268,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)freq_qos_remove_notifier (&policy->constraints,FREQ_QOS_MIN , &policy->nb_min); +/* Cancel any pending policy->update work before freeing the policy. */ +cancel_work_sync (&policy->update); +if (policy->max_freq_req) {/* * CPUFREQ_CREATE_POLICY notification is sent only after
drivers/cpufreq/cpufreq.c static void cpufreq_policy_free(struct cpufreq_policy *policy) · line 1287
Quoted 8 lines
drivers/cpufreq/cpufreq.c +0
-2@@ -1279,8 +1282,6 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) }freq_qos_remove_request (policy->min_freq_req); -/* Cancel any pending policy->update work before freeing the policy. */ -cancel_work_sync (&policy->update);kfree (policy->min_freq_req);cpufreq_policy_put_kobj (policy);
Thanks for doing this.
Signature · 1 line
viresh
Rafael J. Wysocki
maintainerQuoted 52 lines · Viresh Kumar
Quoted 12 lines · Sudeep Holla
Commit
099967699ad9("cpufreq: Cancel policy update work scheduled before freeing") addedcancel_work_sync(policy->update)after the frequency QoS were removed. We can cancel the work just after taking the last CPU in the policy offline and unregistering the notifiers aspolicy->updatecannot be scheduled from anywhere at this point.However, due to other bugs, doing so still triggered the race between freeing of policy and scheduled policy update work. Now that all those issues are resolved, we can move this cancelling of any scheduled policy update work just after removing min/max notifiers.
Signed-off-by Sudeep Holla <[email protected]>Quoted 8 lines
--- drivers/cpufreq/cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)Hi Rafael,
Based on Viresh's suggestion, I am posting a patch to move this
cancel_work_syncearlier though it's not a must have change.For me it is :)
Quoted 27 lines
I will leave it up to your preference.
Regards,
Sudeepdrivers/cpufreq/cpufreq.c +3
-2@@ -1268,6 +1268,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)freq_qos_remove_notifier (&policy->constraints,FREQ_QOS_MIN , &policy->nb_min); +/* Cancel any pending policy->update work before freeing the policy. */ +cancel_work_sync (&policy->update); +if (policy->max_freq_req) {/* * CPUFREQ_CREATE_POLICY notification is sent only after @@ -1279,8 +1282,6 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) }freq_qos_remove_request (policy->min_freq_req); -/* Cancel any pending policy->update work before freeing the policy. */ -cancel_work_sync (&policy->update);kfree (policy->min_freq_req);
Quoted 5 lines
drivers/cpufreq/cpufreq.c static void cpufreq_policy_free(struct cpufreq_policy *policy) · line 1287
Quoted 1 line
drivers/cpufreq/cpufreq.c +0
-0cpufreq_policy_put_kobj (policy);Thanks for doing this.
Acked-by Viresh Kumar <[email protected]>
Folded into the previous patch and applied.
Please double check the result in the current linux-next branch in my tree.
Viresh Kumar
maintainerQuoted 57 lines · Rafael J. Wysocki
Quoted 56 lines · Viresh Kumar
Quoted 12 lines · Sudeep Holla
Commit
099967699ad9("cpufreq: Cancel policy update work scheduled before freeing") addedcancel_work_sync(policy->update)after the frequency QoS were removed. We can cancel the work just after taking the last CPU in the policy offline and unregistering the notifiers aspolicy->updatecannot be scheduled from anywhere at this point.However, due to other bugs, doing so still triggered the race between freeing of policy and scheduled policy update work. Now that all those issues are resolved, we can move this cancelling of any scheduled policy update work just after removing min/max notifiers.
Signed-off-by Sudeep Holla <[email protected]>Quoted 8 lines
--- drivers/cpufreq/cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)Hi Rafael,
Based on Viresh's suggestion, I am posting a patch to move this
cancel_work_syncearlier though it's not a must have change.For me it is :)
Quoted 20 lines
I will leave it up to your preference.
Regards,
Sudeepdrivers/cpufreq/cpufreq.c +3
-0@@ -1268,6 +1268,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)freq_qos_remove_notifier (&policy->constraints,FREQ_QOS_MIN , &policy->nb_min); +/* Cancel any pending policy->update work before freeing the policy. */ +cancel_work_sync (&policy->update); +if (policy->max_freq_req) {/* * CPUFREQ_CREATE_POLICY notification is sent only after drivers/cpufreq/cpufreq.c static void cpufreq_policy_free(struct cpufreq_policy *policy) · line 1287
Quoted 8 lines
drivers/cpufreq/cpufreq.c +0
-2@@ -1279,8 +1282,6 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) }freq_qos_remove_request (policy->min_freq_req); -/* Cancel any pending policy->update work before freeing the policy. */ -cancel_work_sync (&policy->update);kfree (policy->min_freq_req);cpufreq_policy_put_kobj (policy);Thanks for doing this.
Quoted 5 lines
Quoted 1 line
Acked-by Viresh Kumar <[email protected]>Folded into the previous patch and applied.
Please double check the result in the current linux-next branch in my tree.
I would have kept the blank line after cancel_work_sync() which isn't there anymore.
Signature · 1 line
viresh
Rafael J. Wysocki
maintainerQuoted 59 lines · Viresh Kumar
Quoted 57 lines · Rafael J. Wysocki
Quoted 56 lines · Viresh Kumar
Quoted 12 lines · Sudeep Holla
Commit
099967699ad9("cpufreq: Cancel policy update work scheduled before freeing") addedcancel_work_sync(policy->update)after the frequency QoS were removed. We can cancel the work just after taking the last CPU in the policy offline and unregistering the notifiers aspolicy->updatecannot be scheduled from anywhere at this point.However, due to other bugs, doing so still triggered the race between freeing of policy and scheduled policy update work. Now that all those issues are resolved, we can move this cancelling of any scheduled policy update work just after removing min/max notifiers.
Signed-off-by Sudeep Holla <[email protected]>Quoted 8 lines
--- drivers/cpufreq/cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)Hi Rafael,
Based on Viresh's suggestion, I am posting a patch to move this
cancel_work_syncearlier though it's not a must have change.For me it is :)
Quoted 20 lines
I will leave it up to your preference.
Regards,
Sudeepdrivers/cpufreq/cpufreq.c +3
-0@@ -1268,6 +1268,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)freq_qos_remove_notifier (&policy->constraints,FREQ_QOS_MIN , &policy->nb_min); +/* Cancel any pending policy->update work before freeing the policy. */ +cancel_work_sync (&policy->update); +if (policy->max_freq_req) {/* * CPUFREQ_CREATE_POLICY notification is sent only after drivers/cpufreq/cpufreq.c static void cpufreq_policy_free(struct cpufreq_policy *policy) · line 1287
Quoted 8 lines
drivers/cpufreq/cpufreq.c +0
-2@@ -1279,8 +1282,6 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) }freq_qos_remove_request (policy->min_freq_req); -/* Cancel any pending policy->update work before freeing the policy. */ -cancel_work_sync (&policy->update);kfree (policy->min_freq_req);cpufreq_policy_put_kobj (policy);Thanks for doing this.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Acked-by Viresh Kumar <[email protected]>Folded into the previous patch and applied.
Please double check the result in the current linux-next branch in my tree.
I would have kept the blank line after
cancel_work_sync()which isn't there anymore.
OK, it looks better with the extra blank line, so updated. Thanks!