diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig.debug | 7 | ||||
| -rw-r--r-- | lib/fault-inject.c | 8 | ||||
| -rw-r--r-- | lib/mpi/mpicoder.c | 4 | ||||
| -rw-r--r-- | lib/test_kmod.c | 16 | ||||
| -rw-r--r-- | lib/test_rhashtable.c | 57 | ||||
| -rw-r--r-- | lib/test_uuid.c | 2 |
6 files changed, 59 insertions, 35 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 98fe715522e8..c617b9d1d6cb 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -798,6 +798,13 @@ config HARDLOCKUP_DETECTOR_PERF | |||
| 798 | select SOFTLOCKUP_DETECTOR | 798 | select SOFTLOCKUP_DETECTOR |
| 799 | 799 | ||
| 800 | # | 800 | # |
| 801 | # Enables a timestamp based low pass filter to compensate for perf based | ||
| 802 | # hard lockup detection which runs too fast due to turbo modes. | ||
| 803 | # | ||
| 804 | config HARDLOCKUP_CHECK_TIMESTAMP | ||
| 805 | bool | ||
| 806 | |||
| 807 | # | ||
| 801 | # arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard | 808 | # arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard |
| 802 | # lockup detector rather than the perf based detector. | 809 | # lockup detector rather than the perf based detector. |
| 803 | # | 810 | # |
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index 7d315fdb9f13..cf7b129b0b2b 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
| @@ -110,10 +110,12 @@ bool should_fail(struct fault_attr *attr, ssize_t size) | |||
| 110 | if (in_task()) { | 110 | if (in_task()) { |
| 111 | unsigned int fail_nth = READ_ONCE(current->fail_nth); | 111 | unsigned int fail_nth = READ_ONCE(current->fail_nth); |
| 112 | 112 | ||
| 113 | if (fail_nth && !WRITE_ONCE(current->fail_nth, fail_nth - 1)) | 113 | if (fail_nth) { |
| 114 | goto fail; | 114 | if (!WRITE_ONCE(current->fail_nth, fail_nth - 1)) |
| 115 | goto fail; | ||
| 115 | 116 | ||
| 116 | return false; | 117 | return false; |
| 118 | } | ||
| 117 | } | 119 | } |
| 118 | 120 | ||
| 119 | /* No need to check any other properties if the probability is 0 */ | 121 | /* No need to check any other properties if the probability is 0 */ |
diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c index 5a0f75a3bf01..eead4b339466 100644 --- a/lib/mpi/mpicoder.c +++ b/lib/mpi/mpicoder.c | |||
| @@ -364,11 +364,11 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes) | |||
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | miter.consumed = lzeros; | 366 | miter.consumed = lzeros; |
| 367 | sg_miter_stop(&miter); | ||
| 368 | 367 | ||
| 369 | nbytes -= lzeros; | 368 | nbytes -= lzeros; |
| 370 | nbits = nbytes * 8; | 369 | nbits = nbytes * 8; |
| 371 | if (nbits > MAX_EXTERN_MPI_BITS) { | 370 | if (nbits > MAX_EXTERN_MPI_BITS) { |
| 371 | sg_miter_stop(&miter); | ||
| 372 | pr_info("MPI: mpi too large (%u bits)\n", nbits); | 372 | pr_info("MPI: mpi too large (%u bits)\n", nbits); |
| 373 | return NULL; | 373 | return NULL; |
| 374 | } | 374 | } |
| @@ -376,6 +376,8 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes) | |||
| 376 | if (nbytes > 0) | 376 | if (nbytes > 0) |
| 377 | nbits -= count_leading_zeros(*buff) - (BITS_PER_LONG - 8); | 377 | nbits -= count_leading_zeros(*buff) - (BITS_PER_LONG - 8); |
| 378 | 378 | ||
| 379 | sg_miter_stop(&miter); | ||
| 380 | |||
| 379 | nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB); | 381 | nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB); |
| 380 | val = mpi_alloc(nlimbs); | 382 | val = mpi_alloc(nlimbs); |
| 381 | if (!val) | 383 | if (!val) |
diff --git a/lib/test_kmod.c b/lib/test_kmod.c index 6c1d678bcf8b..ff9148969b92 100644 --- a/lib/test_kmod.c +++ b/lib/test_kmod.c | |||
| @@ -485,7 +485,7 @@ static ssize_t config_show(struct device *dev, | |||
| 485 | config->test_driver); | 485 | config->test_driver); |
| 486 | else | 486 | else |
| 487 | len += snprintf(buf+len, PAGE_SIZE - len, | 487 | len += snprintf(buf+len, PAGE_SIZE - len, |
| 488 | "driver:\tEMTPY\n"); | 488 | "driver:\tEMPTY\n"); |
| 489 | 489 | ||
| 490 | if (config->test_fs) | 490 | if (config->test_fs) |
| 491 | len += snprintf(buf+len, PAGE_SIZE - len, | 491 | len += snprintf(buf+len, PAGE_SIZE - len, |
| @@ -493,7 +493,7 @@ static ssize_t config_show(struct device *dev, | |||
| 493 | config->test_fs); | 493 | config->test_fs); |
| 494 | else | 494 | else |
| 495 | len += snprintf(buf+len, PAGE_SIZE - len, | 495 | len += snprintf(buf+len, PAGE_SIZE - len, |
| 496 | "fs:\tEMTPY\n"); | 496 | "fs:\tEMPTY\n"); |
| 497 | 497 | ||
| 498 | mutex_unlock(&test_dev->config_mutex); | 498 | mutex_unlock(&test_dev->config_mutex); |
| 499 | 499 | ||
| @@ -746,11 +746,11 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev, | |||
| 746 | strlen(test_str)); | 746 | strlen(test_str)); |
| 747 | break; | 747 | break; |
| 748 | case TEST_KMOD_FS_TYPE: | 748 | case TEST_KMOD_FS_TYPE: |
| 749 | break; | ||
| 750 | kfree_const(config->test_fs); | 749 | kfree_const(config->test_fs); |
| 751 | config->test_driver = NULL; | 750 | config->test_driver = NULL; |
| 752 | copied = config_copy_test_fs(config, test_str, | 751 | copied = config_copy_test_fs(config, test_str, |
| 753 | strlen(test_str)); | 752 | strlen(test_str)); |
| 753 | break; | ||
| 754 | default: | 754 | default: |
| 755 | mutex_unlock(&test_dev->config_mutex); | 755 | mutex_unlock(&test_dev->config_mutex); |
| 756 | return -EINVAL; | 756 | return -EINVAL; |
| @@ -880,10 +880,10 @@ static int test_dev_config_update_uint_sync(struct kmod_test_device *test_dev, | |||
| 880 | int (*test_sync)(struct kmod_test_device *test_dev)) | 880 | int (*test_sync)(struct kmod_test_device *test_dev)) |
| 881 | { | 881 | { |
| 882 | int ret; | 882 | int ret; |
| 883 | long new; | 883 | unsigned long new; |
| 884 | unsigned int old_val; | 884 | unsigned int old_val; |
| 885 | 885 | ||
| 886 | ret = kstrtol(buf, 10, &new); | 886 | ret = kstrtoul(buf, 10, &new); |
| 887 | if (ret) | 887 | if (ret) |
| 888 | return ret; | 888 | return ret; |
| 889 | 889 | ||
| @@ -918,9 +918,9 @@ static int test_dev_config_update_uint_range(struct kmod_test_device *test_dev, | |||
| 918 | unsigned int max) | 918 | unsigned int max) |
| 919 | { | 919 | { |
| 920 | int ret; | 920 | int ret; |
| 921 | long new; | 921 | unsigned long new; |
| 922 | 922 | ||
| 923 | ret = kstrtol(buf, 10, &new); | 923 | ret = kstrtoul(buf, 10, &new); |
| 924 | if (ret) | 924 | if (ret) |
| 925 | return ret; | 925 | return ret; |
| 926 | 926 | ||
| @@ -1146,7 +1146,7 @@ static struct kmod_test_device *register_test_dev_kmod(void) | |||
| 1146 | struct kmod_test_device *test_dev = NULL; | 1146 | struct kmod_test_device *test_dev = NULL; |
| 1147 | int ret; | 1147 | int ret; |
| 1148 | 1148 | ||
| 1149 | mutex_unlock(®_dev_mutex); | 1149 | mutex_lock(®_dev_mutex); |
| 1150 | 1150 | ||
| 1151 | /* int should suffice for number of devices, test for wrap */ | 1151 | /* int should suffice for number of devices, test for wrap */ |
| 1152 | if (unlikely(num_test_devs + 1) < 0) { | 1152 | if (unlikely(num_test_devs + 1) < 0) { |
diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c index 64e899b63337..0ffca990a833 100644 --- a/lib/test_rhashtable.c +++ b/lib/test_rhashtable.c | |||
| @@ -56,8 +56,13 @@ static bool enomem_retry = false; | |||
| 56 | module_param(enomem_retry, bool, 0); | 56 | module_param(enomem_retry, bool, 0); |
| 57 | MODULE_PARM_DESC(enomem_retry, "Retry insert even if -ENOMEM was returned (default: off)"); | 57 | MODULE_PARM_DESC(enomem_retry, "Retry insert even if -ENOMEM was returned (default: off)"); |
| 58 | 58 | ||
| 59 | struct test_obj_val { | ||
| 60 | int id; | ||
| 61 | int tid; | ||
| 62 | }; | ||
| 63 | |||
| 59 | struct test_obj { | 64 | struct test_obj { |
| 60 | int value; | 65 | struct test_obj_val value; |
| 61 | struct rhash_head node; | 66 | struct rhash_head node; |
| 62 | }; | 67 | }; |
| 63 | 68 | ||
| @@ -72,7 +77,7 @@ static struct test_obj array[MAX_ENTRIES]; | |||
| 72 | static struct rhashtable_params test_rht_params = { | 77 | static struct rhashtable_params test_rht_params = { |
| 73 | .head_offset = offsetof(struct test_obj, node), | 78 | .head_offset = offsetof(struct test_obj, node), |
| 74 | .key_offset = offsetof(struct test_obj, value), | 79 | .key_offset = offsetof(struct test_obj, value), |
| 75 | .key_len = sizeof(int), | 80 | .key_len = sizeof(struct test_obj_val), |
| 76 | .hashfn = jhash, | 81 | .hashfn = jhash, |
| 77 | .nulls_base = (3U << RHT_BASE_SHIFT), | 82 | .nulls_base = (3U << RHT_BASE_SHIFT), |
| 78 | }; | 83 | }; |
| @@ -109,24 +114,26 @@ static int __init test_rht_lookup(struct rhashtable *ht) | |||
| 109 | for (i = 0; i < entries * 2; i++) { | 114 | for (i = 0; i < entries * 2; i++) { |
| 110 | struct test_obj *obj; | 115 | struct test_obj *obj; |
| 111 | bool expected = !(i % 2); | 116 | bool expected = !(i % 2); |
| 112 | u32 key = i; | 117 | struct test_obj_val key = { |
| 118 | .id = i, | ||
| 119 | }; | ||
| 113 | 120 | ||
| 114 | if (array[i / 2].value == TEST_INSERT_FAIL) | 121 | if (array[i / 2].value.id == TEST_INSERT_FAIL) |
| 115 | expected = false; | 122 | expected = false; |
| 116 | 123 | ||
| 117 | obj = rhashtable_lookup_fast(ht, &key, test_rht_params); | 124 | obj = rhashtable_lookup_fast(ht, &key, test_rht_params); |
| 118 | 125 | ||
| 119 | if (expected && !obj) { | 126 | if (expected && !obj) { |
| 120 | pr_warn("Test failed: Could not find key %u\n", key); | 127 | pr_warn("Test failed: Could not find key %u\n", key.id); |
| 121 | return -ENOENT; | 128 | return -ENOENT; |
| 122 | } else if (!expected && obj) { | 129 | } else if (!expected && obj) { |
| 123 | pr_warn("Test failed: Unexpected entry found for key %u\n", | 130 | pr_warn("Test failed: Unexpected entry found for key %u\n", |
| 124 | key); | 131 | key.id); |
| 125 | return -EEXIST; | 132 | return -EEXIST; |
| 126 | } else if (expected && obj) { | 133 | } else if (expected && obj) { |
| 127 | if (obj->value != i) { | 134 | if (obj->value.id != i) { |
| 128 | pr_warn("Test failed: Lookup value mismatch %u!=%u\n", | 135 | pr_warn("Test failed: Lookup value mismatch %u!=%u\n", |
| 129 | obj->value, i); | 136 | obj->value.id, i); |
| 130 | return -EINVAL; | 137 | return -EINVAL; |
| 131 | } | 138 | } |
| 132 | } | 139 | } |
| @@ -195,7 +202,7 @@ static s64 __init test_rhashtable(struct rhashtable *ht) | |||
| 195 | for (i = 0; i < entries; i++) { | 202 | for (i = 0; i < entries; i++) { |
| 196 | struct test_obj *obj = &array[i]; | 203 | struct test_obj *obj = &array[i]; |
| 197 | 204 | ||
| 198 | obj->value = i * 2; | 205 | obj->value.id = i * 2; |
| 199 | err = insert_retry(ht, &obj->node, test_rht_params); | 206 | err = insert_retry(ht, &obj->node, test_rht_params); |
| 200 | if (err > 0) | 207 | if (err > 0) |
| 201 | insert_retries += err; | 208 | insert_retries += err; |
| @@ -216,9 +223,11 @@ static s64 __init test_rhashtable(struct rhashtable *ht) | |||
| 216 | 223 | ||
| 217 | pr_info(" Deleting %d keys\n", entries); | 224 | pr_info(" Deleting %d keys\n", entries); |
| 218 | for (i = 0; i < entries; i++) { | 225 | for (i = 0; i < entries; i++) { |
| 219 | u32 key = i * 2; | 226 | struct test_obj_val key = { |
| 227 | .id = i * 2, | ||
| 228 | }; | ||
| 220 | 229 | ||
| 221 | if (array[i].value != TEST_INSERT_FAIL) { | 230 | if (array[i].value.id != TEST_INSERT_FAIL) { |
| 222 | obj = rhashtable_lookup_fast(ht, &key, test_rht_params); | 231 | obj = rhashtable_lookup_fast(ht, &key, test_rht_params); |
| 223 | BUG_ON(!obj); | 232 | BUG_ON(!obj); |
| 224 | 233 | ||
| @@ -242,18 +251,21 @@ static int thread_lookup_test(struct thread_data *tdata) | |||
| 242 | 251 | ||
| 243 | for (i = 0; i < entries; i++) { | 252 | for (i = 0; i < entries; i++) { |
| 244 | struct test_obj *obj; | 253 | struct test_obj *obj; |
| 245 | int key = (tdata->id << 16) | i; | 254 | struct test_obj_val key = { |
| 255 | .id = i, | ||
| 256 | .tid = tdata->id, | ||
| 257 | }; | ||
| 246 | 258 | ||
| 247 | obj = rhashtable_lookup_fast(&ht, &key, test_rht_params); | 259 | obj = rhashtable_lookup_fast(&ht, &key, test_rht_params); |
| 248 | if (obj && (tdata->objs[i].value == TEST_INSERT_FAIL)) { | 260 | if (obj && (tdata->objs[i].value.id == TEST_INSERT_FAIL)) { |
| 249 | pr_err(" found unexpected object %d\n", key); | 261 | pr_err(" found unexpected object %d-%d\n", key.tid, key.id); |
| 250 | err++; | 262 | err++; |
| 251 | } else if (!obj && (tdata->objs[i].value != TEST_INSERT_FAIL)) { | 263 | } else if (!obj && (tdata->objs[i].value.id != TEST_INSERT_FAIL)) { |
| 252 | pr_err(" object %d not found!\n", key); | 264 | pr_err(" object %d-%d not found!\n", key.tid, key.id); |
| 253 | err++; | 265 | err++; |
| 254 | } else if (obj && (obj->value != key)) { | 266 | } else if (obj && memcmp(&obj->value, &key, sizeof(key))) { |
| 255 | pr_err(" wrong object returned (got %d, expected %d)\n", | 267 | pr_err(" wrong object returned (got %d-%d, expected %d-%d)\n", |
| 256 | obj->value, key); | 268 | obj->value.tid, obj->value.id, key.tid, key.id); |
| 257 | err++; | 269 | err++; |
| 258 | } | 270 | } |
| 259 | 271 | ||
| @@ -272,7 +284,8 @@ static int threadfunc(void *data) | |||
| 272 | pr_err(" thread[%d]: down_interruptible failed\n", tdata->id); | 284 | pr_err(" thread[%d]: down_interruptible failed\n", tdata->id); |
| 273 | 285 | ||
| 274 | for (i = 0; i < entries; i++) { | 286 | for (i = 0; i < entries; i++) { |
| 275 | tdata->objs[i].value = (tdata->id << 16) | i; | 287 | tdata->objs[i].value.id = i; |
| 288 | tdata->objs[i].value.tid = tdata->id; | ||
| 276 | err = insert_retry(&ht, &tdata->objs[i].node, test_rht_params); | 289 | err = insert_retry(&ht, &tdata->objs[i].node, test_rht_params); |
| 277 | if (err > 0) { | 290 | if (err > 0) { |
| 278 | insert_retries += err; | 291 | insert_retries += err; |
| @@ -295,7 +308,7 @@ static int threadfunc(void *data) | |||
| 295 | 308 | ||
| 296 | for (step = 10; step > 0; step--) { | 309 | for (step = 10; step > 0; step--) { |
| 297 | for (i = 0; i < entries; i += step) { | 310 | for (i = 0; i < entries; i += step) { |
| 298 | if (tdata->objs[i].value == TEST_INSERT_FAIL) | 311 | if (tdata->objs[i].value.id == TEST_INSERT_FAIL) |
| 299 | continue; | 312 | continue; |
| 300 | err = rhashtable_remove_fast(&ht, &tdata->objs[i].node, | 313 | err = rhashtable_remove_fast(&ht, &tdata->objs[i].node, |
| 301 | test_rht_params); | 314 | test_rht_params); |
| @@ -304,7 +317,7 @@ static int threadfunc(void *data) | |||
| 304 | tdata->id); | 317 | tdata->id); |
| 305 | goto out; | 318 | goto out; |
| 306 | } | 319 | } |
| 307 | tdata->objs[i].value = TEST_INSERT_FAIL; | 320 | tdata->objs[i].value.id = TEST_INSERT_FAIL; |
| 308 | 321 | ||
| 309 | cond_resched(); | 322 | cond_resched(); |
| 310 | } | 323 | } |
diff --git a/lib/test_uuid.c b/lib/test_uuid.c index 478c049630b5..cd819c397dc7 100644 --- a/lib/test_uuid.c +++ b/lib/test_uuid.c | |||
| @@ -82,7 +82,7 @@ static void __init test_uuid_test(const struct test_uuid_data *data) | |||
| 82 | test_uuid_failed("conversion", false, true, data->uuid, NULL); | 82 | test_uuid_failed("conversion", false, true, data->uuid, NULL); |
| 83 | 83 | ||
| 84 | total_tests++; | 84 | total_tests++; |
| 85 | if (uuid_equal(&data->be, &be)) { | 85 | if (!uuid_equal(&data->be, &be)) { |
| 86 | sprintf(buf, "%pUb", &be); | 86 | sprintf(buf, "%pUb", &be); |
| 87 | test_uuid_failed("cmp", false, true, data->uuid, buf); | 87 | test_uuid_failed("cmp", false, true, data->uuid, buf); |
| 88 | } | 88 | } |
