lkml.org 
[lkml]   [2016]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH]optimize error handling in tick_check_new_device
Date
In the function tick_check_new_device, module error is handled after checking
if the newdev should go as broadcast-installation device in the functions
tick_check_percpu and tick_check_preferred. In case the try_module_get returns
false, the above 2 calls are extra thus wasting CPU cycles.

Shifting the try_module_get as first error handling saves CPU cycles when there
is nothing to do in case of module related error.

Signed-off-by:Gaurav Jindal<gaurav.jindal@spreadtrum.com>
Co-developed-by:Sanjeev Yadav<sanjeev.yadav@spreadtrum.com>

---

diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 4fcd99e..23faf4a 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -307,6 +307,9 @@ void tick_check_new_device(struct clock_event_device *newdev)
td = &per_cpu(tick_cpu_device, cpu);
curdev = td->evtdev;

+ if (!try_module_get(newdev->owner))
+ return;
+
/* cpu local device ? */
if (!tick_check_percpu(curdev, newdev, cpu))
goto out_bc;
@@ -315,8 +318,6 @@ void tick_check_new_device(struct clock_event_device *newdev)
if (!tick_check_preferred(curdev, newdev))
goto out_bc;

- if (!try_module_get(newdev->owner))
- return;

/*
* Replace the eventually existing device by the new
\
 
 \ /
  Last update: 2016-07-27 15:01    [W:1.749 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site