Skip to content

Commit 3c6496c

Browse files
committed
refscale: Provide for initialization failure
Current tests all have init() functions that are guaranteed to succeed. But upcoming tests will need to allocate memory, thus possibly failing. This commit therefore handles init() function failure. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 95f93e9 commit 3c6496c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

kernel/rcu/refscale.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static int exp_idx;
124124

125125
// Operations vector for selecting different types of tests.
126126
struct ref_scale_ops {
127-
void (*init)(void);
127+
bool (*init)(void);
128128
void (*cleanup)(void);
129129
void (*readsection)(const int nloops);
130130
void (*delaysection)(const int nloops, const int udl, const int ndl);
@@ -162,8 +162,9 @@ static void ref_rcu_delay_section(const int nloops, const int udl, const int ndl
162162
}
163163
}
164164

165-
static void rcu_sync_scale_init(void)
165+
static bool rcu_sync_scale_init(void)
166166
{
167+
return true;
167168
}
168169

169170
static struct ref_scale_ops rcu_ops = {
@@ -315,9 +316,10 @@ static struct ref_scale_ops refcnt_ops = {
315316
// Definitions for rwlock
316317
static rwlock_t test_rwlock;
317318

318-
static void ref_rwlock_init(void)
319+
static bool ref_rwlock_init(void)
319320
{
320321
rwlock_init(&test_rwlock);
322+
return true;
321323
}
322324

323325
static void ref_rwlock_section(const int nloops)
@@ -351,9 +353,10 @@ static struct ref_scale_ops rwlock_ops = {
351353
// Definitions for rwsem
352354
static struct rw_semaphore test_rwsem;
353355

354-
static void ref_rwsem_init(void)
356+
static bool ref_rwsem_init(void)
355357
{
356358
init_rwsem(&test_rwsem);
359+
return true;
357360
}
358361

359362
static void ref_rwsem_section(const int nloops)
@@ -833,7 +836,10 @@ ref_scale_init(void)
833836
goto unwind;
834837
}
835838
if (cur_ops->init)
836-
cur_ops->init();
839+
if (!cur_ops->init()) {
840+
firsterr = -EUCLEAN;
841+
goto unwind;
842+
}
837843

838844
ref_scale_print_module_parms(cur_ops, "Start of test");
839845

0 commit comments

Comments
 (0)