[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220718192844.1805158-12-yury.norov@gmail.com>
Date: Mon, 18 Jul 2022 12:28:39 -0700
From: Yury Norov <yury.norov@...il.com>
To: linux-kernel@...r.kernel.org,
Alexander Lobakin <alexandr.lobakin@...el.com>,
Alexei Starovoitov <ast@...nel.org>,
Alexey Klimov <aklimov@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andrii Nakryiko <andrii@...nel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Ben Segall <bsegall@...gle.com>,
Christoph Lameter <cl@...ux.com>,
Dan Williams <dan.j.williams@...el.com>,
Daniel Borkmann <daniel@...earbox.net>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Dennis Zhou <dennis@...nel.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Eric Dumazet <edumazet@...gle.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Guenter Roeck <linux@...ck-us.net>,
Ingo Molnar <mingo@...hat.com>,
Isabella Basso <isabbasso@...eup.net>,
John Fastabend <john.fastabend@...il.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Juergen Gross <jgross@...e.com>,
Juri Lelli <juri.lelli@...hat.com>,
KP Singh <kpsingh@...nel.org>,
Kees Cook <keescook@...omium.org>,
Martin KaFai Lau <kafai@...com>,
Mel Gorman <mgorman@...e.de>, Miroslav Benes <mbenes@...e.cz>,
Nathan Chancellor <nathan@...nel.org>,
"Paul E . McKenney" <paulmck@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Randy Dunlap <rdunlap@...radead.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Song Liu <songliubraving@...com>,
Steven Rostedt <rostedt@...dmis.org>,
Tejun Heo <tj@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Valentin Schneider <vschneid@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Vlastimil Babka <vbabka@...e.cz>, Yonghong Song <yhs@...com>,
Yury Norov <yury.norov@...il.com>, linux-mm@...ck.org,
netdev@...r.kernel.org, bpf@...r.kernel.org
Subject: [PATCH 11/16] time: optimize tick_check_preferred()
tick_check_preferred() calls cpumask_equal() even if
curdev->cpumask == newdev->cpumask. Fix it.
Caught with CONFIG_DEBUG_BITMAP:
[ 0.079109] Call trace:
[ 0.079124] __bitmap_check_params+0x144/0x250
[ 0.079161] tick_check_replacement+0x1a4/0x320
[ 0.079203] tick_check_new_device+0x50/0x110
[ 0.079237] clockevents_register_device+0x74/0x1c0
[ 0.079268] dummy_timer_starting_cpu+0x6c/0x80
[ 0.079310] cpuhp_invoke_callback+0x104/0x20c
[ 0.079353] cpuhp_invoke_callback_range+0x70/0xf0
[ 0.079401] notify_cpu_starting+0xac/0xcc
[ 0.079434] secondary_start_kernel+0xe4/0x154
[ 0.079471] __secondary_switched+0xa0/0xa4
[ 0.079516] ---[ end trace 0000000000000000 ]---
[ 0.079542] b1: ffffbfec4703b890
[ 0.079553] b2: ffffbfec4703b890
[ 0.079566] b3: 0
[ 0.079576] nbits: 256
[ 0.079588] start: 0
[ 0.079598] off: 0
[ 0.079609] Bitmap: parameters check failed
[ 0.079619] include/linux/bitmap.h [419]: bitmap_equal
Signed-off-by: Yury Norov <yury.norov@...il.com>
---
kernel/time/tick-common.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 46789356f856..fdd5ae1a074b 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -316,9 +316,13 @@ static bool tick_check_preferred(struct clock_event_device *curdev,
* Use the higher rated one, but prefer a CPU local device with a lower
* rating than a non-CPU local device
*/
- return !curdev ||
- newdev->rating > curdev->rating ||
- !cpumask_equal(curdev->cpumask, newdev->cpumask);
+ if (!curdev || newdev->rating > curdev->rating)
+ return true;
+
+ if (newdev->cpumask == curdev->cpumask)
+ return false;
+
+ return !cpumask_equal(curdev->cpumask, newdev->cpumask);
}
/*
--
2.34.1
Powered by blists - more mailing lists