lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-7a46c594bf7f1f2eeb1e12d4b857d5f581957a92@git.kernel.org>
Date:	Fri, 13 Mar 2009 04:03:57 GMT
From:	Li Zefan <lizf@...fujitsu.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org, hpa@...or.com, mingo@...hat.com,
	a.p.zijlstra@...llo.nl, lizf@...fujitsu.com, menage@...gle.com,
	balbir@...ux.vnet.ibm.com, bharata@...ux.vnet.ibm.com,
	tglx@...utronix.de, mingo@...e.hu
Subject: [tip:core/percpu] cpuacct: reduce one NULL check in fast-path

Commit-ID:  7a46c594bf7f1f2eeb1e12d4b857d5f581957a92
Gitweb:     http://git.kernel.org/tip/7a46c594bf7f1f2eeb1e12d4b857d5f581957a92
Author:     Li Zefan <lizf@...fujitsu.com>
AuthorDate: Thu, 12 Mar 2009 09:23:01 +0800
Commit:     Ingo Molnar <mingo@...e.hu>
CommitDate: Fri, 13 Mar 2009 04:54:58 +0100

cpuacct: reduce one NULL check in fast-path

Impact: micro-optimization

In cpuacct_charge(), task_ca() will never return NULL, so change
for(...) to do { } while(...) to save one NULL check.

Signed-off-by: Li Zefan <lizf@...fujitsu.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Paul Menage <menage@...gle.com>
Cc: Balbir Singh <balbir@...ux.vnet.ibm.com>
Cc: Bharata B Rao <bharata@...ux.vnet.ibm.com>
LKML-Reference: <49B863F5.2060400@...fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@...e.hu>


---
 kernel/sched.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 0a76d0b..61e6356 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9599,10 +9599,11 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
 	cpu = task_cpu(tsk);
 	ca = task_ca(tsk);
 
-	for (; ca; ca = ca->parent) {
+	do {
 		u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
 		*cpuusage += cputime;
-	}
+		ca = ca->parent;
+	} while (ca);
 }
 
 struct cgroup_subsys cpuacct_subsys = {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ