Skip to content

Commit 918b351

Browse files
committed
refperf: Change readdelay module parameter to nanoseconds
The current units of microseconds are too coarse, so this commit changes the units to nanoseconds. However, ndelay is used only for the nanoseconds with udelay being used for whole microseconds. For example, setting refperf.readdelay=1500 results in a udelay(1) followed by an ndelay(500). Suggested-by: Akira Yokosawa <[email protected]> [ paulmck: Abstracted delay per Akira feedback and move from 80 to 100 lines. ] [ paulmck: Fix names as suggested by kbuild test robot. ] Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 7c944d7 commit 918b351

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

kernel/rcu/refperf.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ torture_param(long, loops, 10000, "Number of loops per experiment.");
6666
torture_param(int, nreaders, -1, "Number of readers, -1 for 75% of CPUs.");
6767
// Number of runs.
6868
torture_param(int, nruns, 30, "Number of experiments to run.");
69-
// Reader delay in microseconds, 0 for no delay.
70-
torture_param(int, readdelay, 0, "Read-side delay in microseconds.");
69+
// Reader delay in nanoseconds, 0 for no delay.
70+
torture_param(int, readdelay, 0, "Read-side delay in nanoseconds.");
7171

7272
#ifdef MODULE
7373
# define REFPERF_SHUTDOWN 0
@@ -111,12 +111,20 @@ struct ref_perf_ops {
111111
void (*init)(void);
112112
void (*cleanup)(void);
113113
void (*readsection)(const int nloops);
114-
void (*delaysection)(const int nloops, const int ndelay);
114+
void (*delaysection)(const int nloops, const int udl, const int ndl);
115115
const char *name;
116116
};
117117

118118
static struct ref_perf_ops *cur_ops;
119119

120+
static void un_delay(const int udl, const int ndl)
121+
{
122+
if (udl)
123+
udelay(udl);
124+
if (ndl)
125+
ndelay(ndl);
126+
}
127+
120128
static void ref_rcu_read_section(const int nloops)
121129
{
122130
int i;
@@ -127,13 +135,13 @@ static void ref_rcu_read_section(const int nloops)
127135
}
128136
}
129137

130-
static void ref_rcu_delay_section(const int nloops, const int ndelay)
138+
static void ref_rcu_delay_section(const int nloops, const int udl, const int ndl)
131139
{
132140
int i;
133141

134142
for (i = nloops; i >= 0; i--) {
135143
rcu_read_lock();
136-
udelay(ndelay);
144+
un_delay(udl, ndl);
137145
rcu_read_unlock();
138146
}
139147
}
@@ -165,14 +173,14 @@ static void srcu_ref_perf_read_section(const int nloops)
165173
}
166174
}
167175

168-
static void srcu_ref_perf_delay_section(const int nloops, const int ndelay)
176+
static void srcu_ref_perf_delay_section(const int nloops, const int udl, const int ndl)
169177
{
170178
int i;
171179
int idx;
172180

173181
for (i = nloops; i >= 0; i--) {
174182
idx = srcu_read_lock(srcu_ctlp);
175-
udelay(ndelay);
183+
un_delay(udl, ndl);
176184
srcu_read_unlock(srcu_ctlp, idx);
177185
}
178186
}
@@ -197,13 +205,13 @@ static void ref_refcnt_section(const int nloops)
197205
}
198206
}
199207

200-
static void ref_refcnt_delay_section(const int nloops, const int ndelay)
208+
static void ref_refcnt_delay_section(const int nloops, const int udl, const int ndl)
201209
{
202210
int i;
203211

204212
for (i = nloops; i >= 0; i--) {
205213
atomic_inc(&refcnt);
206-
udelay(ndelay);
214+
un_delay(udl, ndl);
207215
atomic_dec(&refcnt);
208216
}
209217
}
@@ -233,13 +241,13 @@ static void ref_rwlock_section(const int nloops)
233241
}
234242
}
235243

236-
static void ref_rwlock_delay_section(const int nloops, const int ndelay)
244+
static void ref_rwlock_delay_section(const int nloops, const int udl, const int ndl)
237245
{
238246
int i;
239247

240248
for (i = nloops; i >= 0; i--) {
241249
read_lock(&test_rwlock);
242-
udelay(ndelay);
250+
un_delay(udl, ndl);
243251
read_unlock(&test_rwlock);
244252
}
245253
}
@@ -269,13 +277,13 @@ static void ref_rwsem_section(const int nloops)
269277
}
270278
}
271279

272-
static void ref_rwsem_delay_section(const int nloops, const int ndelay)
280+
static void ref_rwsem_delay_section(const int nloops, const int udl, const int ndl)
273281
{
274282
int i;
275283

276284
for (i = nloops; i >= 0; i--) {
277285
down_read(&test_rwsem);
278-
udelay(ndelay);
286+
un_delay(udl, ndl);
279287
up_read(&test_rwsem);
280288
}
281289
}
@@ -292,7 +300,7 @@ static void rcu_perf_one_reader(void)
292300
if (readdelay <= 0)
293301
cur_ops->readsection(loops);
294302
else
295-
cur_ops->delaysection(loops, readdelay);
303+
cur_ops->delaysection(loops, readdelay / 1000, readdelay % 1000);
296304
}
297305

298306
// Reader kthread. Repeatedly does empty RCU read-side

0 commit comments

Comments
 (0)