aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-02-03 13:10:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-02-03 13:10:02 -0500
commitb37a05c083c85c2657dca9bbe1f5d79dccf756d5 (patch)
tree0a9bd376a437484e21a6728ca16f2266a0e3e788 /lib
parentd5bfb96bdad3588961f49a6eff89a625fbaa12bf (diff)
parent12c9d70bd5056b3ae84746fca973c286f48384cc (diff)
Merge branch 'akpm' (patches from Andrew)
Merge fixes from Andrew Morton: "18 fixes" [ The 18 fixes turned into 17 commits, because one of the fixes was a fix for another patch in the series that I just folded in by editing the patch manually - hopefully correctly - Linus ] * emailed patches from Andrew Morton <akpm@linux-foundation.org>: mm: fix memory leak in copy_huge_pmd() drivers/hwspinlock: fix race between radix tree insertion and lookup radix-tree: fix race in gang lookup mm/vmpressure.c: fix subtree pressure detection mm: polish virtual memory accounting mm: warn about VmData over RLIMIT_DATA Documentation: cgroup-v2: add memory.stat::sock description mm: memcontrol: drop superfluous entry in the per-memcg stats array drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration proc: revert /proc/<pid>/maps [stack:TID] annotation numa: fix /proc/<pid>/numa_maps for hugetlbfs on s390 MAINTAINERS: update Seth email ocfs2/cluster: fix memory leak in o2hb_region_release lib/test-string_helpers.c: fix and improve string_get_size() tests thp: limit number of object to scan on deferred_split_scan() thp: change deferred_split_count() to return number of THP in queue thp: make split_queue per-node
Diffstat (limited to 'lib')
-rw-r--r--lib/radix-tree.c12
-rw-r--r--lib/test-string_helpers.c67
2 files changed, 59 insertions, 20 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index fcf5d98574ce..6b79e9026e24 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1019,9 +1019,13 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
1019 return 0; 1019 return 0;
1020 1020
1021 radix_tree_for_each_slot(slot, root, &iter, first_index) { 1021 radix_tree_for_each_slot(slot, root, &iter, first_index) {
1022 results[ret] = indirect_to_ptr(rcu_dereference_raw(*slot)); 1022 results[ret] = rcu_dereference_raw(*slot);
1023 if (!results[ret]) 1023 if (!results[ret])
1024 continue; 1024 continue;
1025 if (radix_tree_is_indirect_ptr(results[ret])) {
1026 slot = radix_tree_iter_retry(&iter);
1027 continue;
1028 }
1025 if (++ret == max_items) 1029 if (++ret == max_items)
1026 break; 1030 break;
1027 } 1031 }
@@ -1098,9 +1102,13 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
1098 return 0; 1102 return 0;
1099 1103
1100 radix_tree_for_each_tagged(slot, root, &iter, first_index, tag) { 1104 radix_tree_for_each_tagged(slot, root, &iter, first_index, tag) {
1101 results[ret] = indirect_to_ptr(rcu_dereference_raw(*slot)); 1105 results[ret] = rcu_dereference_raw(*slot);
1102 if (!results[ret]) 1106 if (!results[ret])
1103 continue; 1107 continue;
1108 if (radix_tree_is_indirect_ptr(results[ret])) {
1109 slot = radix_tree_iter_retry(&iter);
1110 continue;
1111 }
1104 if (++ret == max_items) 1112 if (++ret == max_items)
1105 break; 1113 break;
1106 } 1114 }
diff --git a/lib/test-string_helpers.c b/lib/test-string_helpers.c
index 98866a770770..25b5cbfb7615 100644
--- a/lib/test-string_helpers.c
+++ b/lib/test-string_helpers.c
@@ -327,36 +327,67 @@ out:
327} 327}
328 328
329#define string_get_size_maxbuf 16 329#define string_get_size_maxbuf 16
330#define test_string_get_size_one(size, blk_size, units, exp_result) \ 330#define test_string_get_size_one(size, blk_size, exp_result10, exp_result2) \
331 do { \ 331 do { \
332 BUILD_BUG_ON(sizeof(exp_result) >= string_get_size_maxbuf); \ 332 BUILD_BUG_ON(sizeof(exp_result10) >= string_get_size_maxbuf); \
333 __test_string_get_size((size), (blk_size), (units), \ 333 BUILD_BUG_ON(sizeof(exp_result2) >= string_get_size_maxbuf); \
334 (exp_result)); \ 334 __test_string_get_size((size), (blk_size), (exp_result10), \
335 (exp_result2)); \
335 } while (0) 336 } while (0)
336 337
337 338
338static __init void __test_string_get_size(const u64 size, const u64 blk_size, 339static __init void test_string_get_size_check(const char *units,
339 const enum string_size_units units, 340 const char *exp,
340 const char *exp_result) 341 char *res,
342 const u64 size,
343 const u64 blk_size)
341{ 344{
342 char buf[string_get_size_maxbuf]; 345 if (!memcmp(res, exp, strlen(exp) + 1))
343
344 string_get_size(size, blk_size, units, buf, sizeof(buf));
345 if (!memcmp(buf, exp_result, strlen(exp_result) + 1))
346 return; 346 return;
347 347
348 buf[sizeof(buf) - 1] = '\0'; 348 res[string_get_size_maxbuf - 1] = '\0';
349 pr_warn("Test 'test_string_get_size_one' failed!\n"); 349
350 pr_warn("string_get_size(size = %llu, blk_size = %llu, units = %d\n", 350 pr_warn("Test 'test_string_get_size' failed!\n");
351 pr_warn("string_get_size(size = %llu, blk_size = %llu, units = %s)\n",
351 size, blk_size, units); 352 size, blk_size, units);
352 pr_warn("expected: '%s', got '%s'\n", exp_result, buf); 353 pr_warn("expected: '%s', got '%s'\n", exp, res);
354}
355
356static __init void __test_string_get_size(const u64 size, const u64 blk_size,
357 const char *exp_result10,
358 const char *exp_result2)
359{
360 char buf10[string_get_size_maxbuf];
361 char buf2[string_get_size_maxbuf];
362
363 string_get_size(size, blk_size, STRING_UNITS_10, buf10, sizeof(buf10));
364 string_get_size(size, blk_size, STRING_UNITS_2, buf2, sizeof(buf2));
365
366 test_string_get_size_check("STRING_UNITS_10", exp_result10, buf10,
367 size, blk_size);
368
369 test_string_get_size_check("STRING_UNITS_2", exp_result2, buf2,
370 size, blk_size);
353} 371}
354 372
355static __init void test_string_get_size(void) 373static __init void test_string_get_size(void)
356{ 374{
357 test_string_get_size_one(16384, 512, STRING_UNITS_2, "8.00 MiB"); 375 /* small values */
358 test_string_get_size_one(8192, 4096, STRING_UNITS_10, "32.7 MB"); 376 test_string_get_size_one(0, 512, "0 B", "0 B");
359 test_string_get_size_one(1, 512, STRING_UNITS_10, "512 B"); 377 test_string_get_size_one(1, 512, "512 B", "512 B");
378 test_string_get_size_one(1100, 1, "1.10 kB", "1.07 KiB");
379
380 /* normal values */
381 test_string_get_size_one(16384, 512, "8.39 MB", "8.00 MiB");
382 test_string_get_size_one(500118192, 512, "256 GB", "238 GiB");
383 test_string_get_size_one(8192, 4096, "33.6 MB", "32.0 MiB");
384
385 /* weird block sizes */
386 test_string_get_size_one(3000, 1900, "5.70 MB", "5.44 MiB");
387
388 /* huge values */
389 test_string_get_size_one(U64_MAX, 4096, "75.6 ZB", "64.0 ZiB");
390 test_string_get_size_one(4096, U64_MAX, "75.6 ZB", "64.0 ZiB");
360} 391}
361 392
362static int __init test_string_helpers_init(void) 393static int __init test_string_helpers_init(void)