Skip to content

Commit da35048

Browse files
npigginmcgrof
authored andcommitted
kallsyms: Fix scheduling with interrupts disabled in self-test
kallsyms_on_each* may schedule so must not be called with interrupts disabled. The iteration function could disable interrupts, but this also changes lookup_symbol() to match the change to the other timing code. Reported-by: Erhard F. <erhard_f@mailbox.org> Link: https://lore.kernel.org/all/bug-216902-206035@https.bugzilla.kernel.org%2F/ Reported-by: kernel test robot <oliver.sang@intel.com> Link: https://lore.kernel.org/oe-lkp/202212251728.8d0872ff-oliver.sang@intel.com Fixes: 30f3bb0 ("kallsyms: Add self-test facility") Tested-by: "Erhard F." <erhard_f@mailbox.org> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent 88603b6 commit da35048

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

kernel/kallsyms_selftest.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,11 @@ static void test_kallsyms_compression_ratio(void)
157157
static int lookup_name(void *data, const char *name, struct module *mod, unsigned long addr)
158158
{
159159
u64 t0, t1, t;
160-
unsigned long flags;
161160
struct test_stat *stat = (struct test_stat *)data;
162161

163-
local_irq_save(flags);
164-
t0 = sched_clock();
162+
t0 = ktime_get_ns();
165163
(void)kallsyms_lookup_name(name);
166-
t1 = sched_clock();
167-
local_irq_restore(flags);
164+
t1 = ktime_get_ns();
168165

169166
t = t1 - t0;
170167
if (t < stat->min)
@@ -234,18 +231,15 @@ static int find_symbol(void *data, const char *name, struct module *mod, unsigne
234231
static void test_perf_kallsyms_on_each_symbol(void)
235232
{
236233
u64 t0, t1;
237-
unsigned long flags;
238234
struct test_stat stat;
239235

240236
memset(&stat, 0, sizeof(stat));
241237
stat.max = INT_MAX;
242238
stat.name = stub_name;
243239
stat.perf = 1;
244-
local_irq_save(flags);
245-
t0 = sched_clock();
240+
t0 = ktime_get_ns();
246241
kallsyms_on_each_symbol(find_symbol, &stat);
247-
t1 = sched_clock();
248-
local_irq_restore(flags);
242+
t1 = ktime_get_ns();
249243
pr_info("kallsyms_on_each_symbol() traverse all: %lld ns\n", t1 - t0);
250244
}
251245

@@ -270,17 +264,14 @@ static int match_symbol(void *data, unsigned long addr)
270264
static void test_perf_kallsyms_on_each_match_symbol(void)
271265
{
272266
u64 t0, t1;
273-
unsigned long flags;
274267
struct test_stat stat;
275268

276269
memset(&stat, 0, sizeof(stat));
277270
stat.max = INT_MAX;
278271
stat.name = stub_name;
279-
local_irq_save(flags);
280-
t0 = sched_clock();
272+
t0 = ktime_get_ns();
281273
kallsyms_on_each_match_symbol(match_symbol, stat.name, &stat);
282-
t1 = sched_clock();
283-
local_irq_restore(flags);
274+
t1 = ktime_get_ns();
284275
pr_info("kallsyms_on_each_match_symbol() traverse all: %lld ns\n", t1 - t0);
285276
}
286277

0 commit comments

Comments
 (0)