From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755786AbcG0MHV (ORCPT ); Wed, 27 Jul 2016 08:07:21 -0400 Received: from sci-ig2.spreadtrum.com ([222.66.158.135]:48743 "EHLO SHSQR01.spreadtrum.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753872AbcG0MHU convert rfc822-to-8bit (ORCPT ); Wed, 27 Jul 2016 08:07:20 -0400 From: "Gaurav Jindal (Gaurav Jindal)" To: "tglx@linutronix.de" CC: "linux-kernel@vger.kernel.org" , "Sanjeev Yadav (Sanjeev Kumar Yadav)" Subject: [PATCH]optimize error handling in tick_check_new_device Thread-Topic: [PATCH]optimize error handling in tick_check_new_device Thread-Index: AQHR5/9H3lexYi7KcUiIVoyAvwRuTg== Date: Wed, 27 Jul 2016 12:06:17 +0000 Message-ID: <20160727120609.GA3773@gauravjindalubtnb.del.spreadtrum.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.1.253] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-MAIL: SHSQR01.spreadtrum.com u6RC6Zgg083413 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Co-developed-by:Sanjeev Yadav --- 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