Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

torture: Add get_torture_init_jiffies() for test-start time

This commit adds a get_torture_init_jiffies() function that returns the
value of the jiffies counter at the start of the test, that is, at the
point where torture_init_begin() was invoked.

This will be used to enable torture-test holdoffs for tests implemented
using per-CPU kthreads, which are created and deleted by CPU-hotplug
operations, and thus (unlike normal kthreads) don't automatically know
when the test started.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>

authored by

Paul E. McKenney and committed by
Boqun Feng
623b5280 2014c95a

+13
+1
include/linux/torture.h
··· 104 104 /* Initialization and cleanup. */ 105 105 bool torture_init_begin(char *ttype, int v); 106 106 void torture_init_end(void); 107 + unsigned long get_torture_init_jiffies(void); 107 108 bool torture_cleanup_begin(void); 108 109 void torture_cleanup_end(void); 109 110 bool torture_must_stop(void);
+12
kernel/torture.c
··· 792 792 stutter_task = NULL; 793 793 } 794 794 795 + static unsigned long torture_init_jiffies; 796 + 795 797 static void 796 798 torture_print_module_parms(void) 797 799 { ··· 823 821 torture_type = ttype; 824 822 verbose = v; 825 823 fullstop = FULLSTOP_DONTSTOP; 824 + WRITE_ONCE(torture_init_jiffies, jiffies); // Lockless reads. 826 825 torture_print_module_parms(); 827 826 return true; 828 827 } ··· 838 835 register_reboot_notifier(&torture_shutdown_nb); 839 836 } 840 837 EXPORT_SYMBOL_GPL(torture_init_end); 838 + 839 + /* 840 + * Get the torture_init_begin()-time value of the jiffies counter. 841 + */ 842 + unsigned long get_torture_init_jiffies(void) 843 + { 844 + return READ_ONCE(torture_init_jiffies); 845 + } 846 + EXPORT_SYMBOL_GPL(get_torture_init_jiffies); 841 847 842 848 /* 843 849 * Clean up torture module. Please note that this is -not- invoked via