thermal-core: Use rcu when accessing threshold list
Threshold list will be read in interrupt context. Using
a lock in the interrupt context is not acceptable, but the
list traversal needs to be protected. Because the threshold
list can be updated with a new threshold or an existing
threshold can be removed. Doing a list traversal during the
list mutation may result in unassigned memory access
violation. Use of list_for_each_entry_safe() function for
traversing, won't help. Because this function can help
only if the traversal loop removes the current element, that
is pointed by this iteration.
Use rcu to ensure a safe list traversal without a lock.
Addition or deletion to the threshold list is an infrequent
operation when compared to the threshold list read, which
happens when temperature threshold trips. Using rcu ensures
that read operations are done faster without getting
blocked by a lock and the list write operations are done
in a list safe fashion. Replace the list_for_each_entry_safe()
function with rcu safe list traversal function
list_for_each_entry_rcu(), wherever it is applicable.
Change-Id: I7636711bfc6bd63fe3adaad38a5471e3508e240b
Signed-off-by:
Ram Chandrasekar <rkumbako@codeaurora.org>
Loading
Please register or sign in to comment