History

rcuscale: Add kfree_rcu() single-argument scale test

The single-argument variant of kfree_rcu() is currently not tested by any member of the rcutoture test suite. This commit therefore adds rcuscale code to test it. This testing is controlled by two new boolean module parameters, kfree_rcu_test_single and kfree_rcu_test_double. If one is set and the other not, only the corresponding variant is tested, otherwise both are tested, with the variant to be tested determined randomly on each invocation. Both of these module parameters are initialized to false, so setting either to true will test only that variant.

Uladzislau Rezki (Sony) committed 5 years ago

Commit 686fe1b1 parent ee6ddf52 files · +26 −1Browse files

Unified · Split

2 files
  1. Documentation/admin-guide/kernel-parameters.txt +12 −0
  2. kernel/rcu/rcuscale.c +14 −1
Documentation/admin-guide/kernel-parameters.txt+12−0
@@ -4259,6 +4259,18 @@ · 4258 unmodified lines
42594259 rcuscale.kfree_rcu_test= [KNL]
42604260 Set to measure performance of kfree_rcu() flooding.
42614261
4262+ rcuscale.kfree_rcu_test_double= [KNL]
4263+ Test the double-argument variant of kfree_rcu().
4264+ If this parameter has the same value as
4265+ rcuscale.kfree_rcu_test_single, both the single-
4266+ and double-argument variants are tested.
4267+
4268+ rcuscale.kfree_rcu_test_single= [KNL]
4269+ Test the single-argument variant of kfree_rcu().
4270+ If this parameter has the same value as
4271+ rcuscale.kfree_rcu_test_double, both the single-
4272+ and double-argument variants are tested.
4273+
42624274 rcuscale.kfree_nthreads= [KNL]
42634275 The number of threads running loops of kfree_rcu().
42644276
kernel/rcu/rcuscale.c+14−1
@@ -625,6 +625,8 @@ rcu_scale_shutdown(void *arg) · 624 unmodified lines
625625 torture_param(int, kfree_nthreads, -1, "Number of threads running loops of kfree_rcu().");
626626 torture_param(int, kfree_alloc_num, 8000, "Number of allocations and frees done in an iteration.");
627627 torture_param(int, kfree_loops, 10, "Number of loops doing kfree_alloc_num allocations and frees.");
628+torture_param(bool, kfree_rcu_test_double, false, "Do we run a kfree_rcu() double-argument scale test?");
629+torture_param(bool, kfree_rcu_test_single, false, "Do we run a kfree_rcu() single-argument scale test?");
628630
629631 static struct task_struct **kfree_reader_tasks;
630632 static int kfree_nrealthreads;
@@ -644,10 +646,13 @@ kfree_scale_thread(void *arg) · 13 unmodified lines
644646 struct kfree_obj *alloc_ptr;
645647 u64 start_time, end_time;
646648 long long mem_begin, mem_during = 0;
649+ bool kfree_rcu_test_both;
650+ DEFINE_TORTURE_RANDOM(tr);
647651
648652 VERBOSE_SCALEOUT_STRING("kfree_scale_thread task started");
649653 set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
650654 set_user_nice(current, MAX_NICE);
655+ kfree_rcu_test_both = (kfree_rcu_test_single == kfree_rcu_test_double);
651656
652657 start_time = ktime_get_mono_fast_ns();
653658
@@ -670,7 +675,15 @@ kfree_scale_thread(void *arg) · 16 unmodified lines
670675 if (!alloc_ptr)
671676 return -ENOMEM;
672677
673− kfree_rcu(alloc_ptr, rh);
678+ // By default kfree_rcu_test_single and kfree_rcu_test_double are
679+ // initialized to false. If both have the same value (false or true)
680+ // both are randomly tested, otherwise only the one with value true
681+ // is tested.
682+ if ((kfree_rcu_test_single && !kfree_rcu_test_double) ||
683+ (kfree_rcu_test_both && torture_random(&tr) & 0x800))
684+ kfree_rcu(alloc_ptr);
685+ else
686+ kfree_rcu(alloc_ptr, rh);
674687 }
675688
676689 cond_resched();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t