mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gaurav Jindal (Gaurav Jindal)" <Gaurav.Jindal@spreadtrum.com>
To: "tglx@linutronix.de" <tglx@linutronix.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Sanjeev Yadav (Sanjeev Kumar Yadav)"
	<Sanjeev.Yadav@spreadtrum.com>
Subject: [PATCH]optimize error handling in tick_check_new_device
Date: Wed, 27 Jul 2016 12:06:17 +0000	[thread overview]
Message-ID: <20160727120609.GA3773@gauravjindalubtnb.del.spreadtrum.com> (raw)

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

             reply	other threads:[~2016-07-27 12:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-27 12:06 Gaurav Jindal (Gaurav Jindal) [this message]
2016-07-27 12:23 ` Nicolai Stange
2016-07-28 14:50 ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160727120609.GA3773@gauravjindalubtnb.del.spreadtrum.com \
    --to=gaurav.jindal@spreadtrum.com \
    --cc=Sanjeev.Yadav@spreadtrum.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®