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
4259 rcuscale.kfree_rcu_test= [KNL]4259 rcuscale.kfree_rcu_test= [KNL]
4260 Set to measure performance of kfree_rcu() flooding.4260 Set to measure performance of kfree_rcu() flooding.
4261 4261
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
4262 rcuscale.kfree_nthreads= [KNL]4274 rcuscale.kfree_nthreads= [KNL]
4263 The number of threads running loops of kfree_rcu().4275 The number of threads running loops of kfree_rcu().
4264 4276
kernel/rcu/rcuscale.c+14−1
@@ -625,6 +625,8 @@ rcu_scale_shutdown(void *arg) · 624 unmodified lines
625torture_param(int, kfree_nthreads, -1, "Number of threads running loops of kfree_rcu().");625torture_param(int, kfree_nthreads, -1, "Number of threads running loops of kfree_rcu().");
626torture_param(int, kfree_alloc_num, 8000, "Number of allocations and frees done in an iteration.");626torture_param(int, kfree_alloc_num, 8000, "Number of allocations and frees done in an iteration.");
627torture_param(int, kfree_loops, 10, "Number of loops doing kfree_alloc_num allocations and frees.");627torture_param(int, kfree_loops, 10, "Number of loops doing kfree_alloc_num allocations and frees.");
628torture_param(bool, kfree_rcu_test_double, false, "Do we run a kfree_rcu() double-argument scale test?");
629torture_param(bool, kfree_rcu_test_single, false, "Do we run a kfree_rcu() single-argument scale test?");
628 630
629static struct task_struct **kfree_reader_tasks;631static struct task_struct **kfree_reader_tasks;
630static int kfree_nrealthreads;632static int kfree_nrealthreads;
@@ -644,10 +646,13 @@ kfree_scale_thread(void *arg) · 13 unmodified lines
644 struct kfree_obj *alloc_ptr;646 struct kfree_obj *alloc_ptr;
645 u64 start_time, end_time;647 u64 start_time, end_time;
646 long long mem_begin, mem_during = 0;648 long long mem_begin, mem_during = 0;
649 bool kfree_rcu_test_both;
650 DEFINE_TORTURE_RANDOM(tr);
647 651
648 VERBOSE_SCALEOUT_STRING("kfree_scale_thread task started");652 VERBOSE_SCALEOUT_STRING("kfree_scale_thread task started");
649 set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));653 set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
650 set_user_nice(current, MAX_NICE);654 set_user_nice(current, MAX_NICE);
655 kfree_rcu_test_both = (kfree_rcu_test_single == kfree_rcu_test_double);
651 656
652 start_time = ktime_get_mono_fast_ns();657 start_time = ktime_get_mono_fast_ns();
653 658
@@ -670,7 +675,15 @@ kfree_scale_thread(void *arg) · 16 unmodified lines
670 if (!alloc_ptr)675 if (!alloc_ptr)
671 return -ENOMEM;676 return -ENOMEM;
672 677
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);
674 }687 }
675 688
676 cond_resched();689 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