Skip to content

Commit 9778e7e

Browse files
committed
stress-dev: add --dev-alldev option to exercise all devices
This new option will exercise all devices; the default is just to exercise the first occurrence +of a device (e.g. /dev/i2c-0), this option will exercise all devices (e.g. /dev/i2c-*) and hence will take far more time to work through all the devices. Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
1 parent 90500d7 commit 9778e7e

5 files changed

Lines changed: 25 additions & 9 deletions

File tree

bash-completion/stress-ng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ _stress_ng()
262262
'--cpu-online-all' | \
263263
'--daemon-wait' | \
264264
'--dentry-negative' | \
265+
'--dev-alldev' | \
265266
'--dry-run' | \
266267
'--epollmany-delete' | \
267268
'--eventfd-nonblock' | \

core-opts.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,10 @@ const struct option stress_long_options[] = {
270270
{ "dentrystat", 1, NULL, OPT_dentrystat },
271271

272272
{ "dev", 1, NULL, OPT_dev },
273+
{ "dev-alldev", 0, NULL, OPT_dev_alldev },
273274
{ "dev-file", 1, NULL, OPT_dev_file },
274275
{ "dev-ops", 1, NULL, OPT_dev_ops },
276+
275277
{ "dev-shm", 1, NULL, OPT_dev_shm },
276278
{ "dev-shm-ops", 1, NULL, OPT_dev_shm_ops },
277279

core-opts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ typedef enum {
396396
OPT_dentrystat,
397397

398398
OPT_dev,
399+
OPT_dev_alldev,
399400
OPT_dev_ops,
400401
OPT_dev_file,
401402

stress-dev.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,15 @@ typedef struct dev_info {
236236

237237
static const stress_help_t help[] = {
238238
{ NULL, "dev N", "start N device entry thrashing stressors" },
239+
{ NULL, "dev-alldev", "exercise all devices (rather than just /dev/devname0)" },
239240
{ NULL, "dev-file name","specify the /dev/ file to exercise" },
240241
{ NULL, "dev-ops N", "stop after N device thrashing bogo ops" },
241242
{ NULL, NULL, NULL }
242243
};
243244

244245
static const stress_opt_t opts[] = {
245-
{ OPT_dev_file, "dev-file", TYPE_ID_STR, 0, 0, NULL },
246+
{ OPT_dev_alldev, "dev-alldev", TYPE_ID_BOOL, 0, 1, NULL },
247+
{ OPT_dev_file, "dev-file", TYPE_ID_STR, 0, 0, NULL },
246248
END_OPT,
247249
};
248250

@@ -4467,7 +4469,8 @@ static void stress_dev_infos_get(
44674469
const char *path,
44684470
const char *tty_name,
44694471
dev_info_t **list,
4470-
size_t *list_len)
4472+
size_t *list_len,
4473+
const bool dev_alldev)
44714474
{
44724475
struct dirent **dlist;
44734476
int i;
@@ -4498,10 +4501,10 @@ static void stress_dev_infos_get(
44984501
len = shim_strlen(d->d_name);
44994502

45004503
/*
4501-
* Exercise no more than 3 of the same device
4504+
* Exercise no more than 1 of the same device
45024505
* driver, e.g. ttyS0..ttyS1
45034506
*/
4504-
if (len > 1) {
4507+
if (!dev_alldev && (len > 1)) {
45054508
int dev_n;
45064509
char *ptr = d->d_name + len - 1;
45074510

@@ -4510,10 +4513,11 @@ static void stress_dev_infos_get(
45104513
ptr++;
45114514
if (sscanf(ptr, "%d", &dev_n) != 1)
45124515
continue;
4513-
if (dev_n > 2)
4516+
if (dev_n > 1)
45144517
continue;
45154518
}
45164519

4520+
45174521
(void)stress_fs_make_filename(tmp, sizeof(tmp), path, d->d_name);
45184522

45194523
/* Don't exercise our tty */
@@ -4527,7 +4531,7 @@ static void stress_dev_infos_get(
45274531
continue;
45284532
if ((statbuf.st_mode & flags) == 0)
45294533
continue;
4530-
stress_dev_infos_get(args, tmp, tty_name, list, list_len);
4534+
stress_dev_infos_get(args, tmp, tty_name, list, list_len, dev_alldev);
45314535
break;
45324536
case SHIM_DT_BLK:
45334537
case SHIM_DT_CHR:
@@ -4766,6 +4770,7 @@ static int stress_dev(stress_args_t *args)
47664770
size_t dev_info_list_len = 0;
47674771
sys_dev_info_t *sys_dev_info_list = NULL;
47684772
sys_dev_info_t *sys_dev_info_list_end = NULL;
4773+
bool dev_alldev = false;
47694774

47704775
stress_dev_state_init(&dev_state_null);
47714776

@@ -4774,6 +4779,7 @@ static int stress_dev(stress_args_t *args)
47744779

47754780
(void)shim_memset(ret, 0, sizeof(ret));
47764781

4782+
(void)stress_setting_get("dev-alldev", &dev_alldev);
47774783
(void)stress_setting_get("dev-file", &dev_file);
47784784
if (dev_file) {
47794785
mode_t mode;
@@ -4793,7 +4799,7 @@ static int stress_dev(stress_args_t *args)
47934799

47944800
stress_dev_info_add(args, dev_file, &dev_info_list, &dev_info_list_len, true);
47954801
} else {
4796-
stress_dev_infos_get(args, "/dev", tty_name, &dev_info_list, &dev_info_list_len);
4802+
stress_dev_infos_get(args, "/dev", tty_name, &dev_info_list, &dev_info_list_len, dev_alldev);
47974803
stress_sys_dev_infos_get(args, "/sys/dev", &sys_dev_info_list, &sys_dev_info_list_end, 0);
47984804
}
47994805

stress-ng.1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,8 +2880,14 @@ stop after N non-existtent files are accessed.
28802880
.B \-\-dev N
28812881
start N workers that exercise the /dev devices. Each worker runs 5
28822882
concurrent threads that perform open(2), fstat(2), lseek(2), poll(2),
2883-
fcntl(2), mmap(2), munmap(2), fsync(2) and close(2) on each device.
2884-
Note that watchdog devices are not exercised.
2883+
fcntl(2), mmap(2), munmap(2), fsync(2) and close(2) on the fist occurance
2884+
of each device. Note that watchdog devices are not exercised.
2885+
.TP
2886+
.B \-\-dev\-alldev
2887+
exercise all devices; the default is just to exercise
2888+
the first occurrence of a device (e.g. /dev/i2c-0), this option will
2889+
exercise all devices (e.g. /dev/i2c-*) and hence will take far more
2890+
time to work through all the devices.
28852891
.TP
28862892
.B \-\-dev\-file filename
28872893
specify the device file to exercise, for example, /dev/null. By default

0 commit comments

Comments
 (0)