Skip to content

Commit 623b528

Browse files
paulmckrcufbq
authored andcommitted
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 <[email protected]> Signed-off-by: Boqun Feng <[email protected]>
1 parent 2014c95 commit 623b528

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/linux/torture.h

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ int torture_stutter_init(int s, int sgap);
104104
/* Initialization and cleanup. */
105105
bool torture_init_begin(char *ttype, int v);
106106
void torture_init_end(void);
107+
unsigned long get_torture_init_jiffies(void);
107108
bool torture_cleanup_begin(void);
108109
void torture_cleanup_end(void);
109110
bool torture_must_stop(void);

kernel/torture.c

+12
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ static void torture_stutter_cleanup(void)
792792
stutter_task = NULL;
793793
}
794794

795+
static unsigned long torture_init_jiffies;
796+
795797
static void
796798
torture_print_module_parms(void)
797799
{
@@ -821,6 +823,7 @@ bool torture_init_begin(char *ttype, int v)
821823
torture_type = ttype;
822824
verbose = v;
823825
fullstop = FULLSTOP_DONTSTOP;
826+
WRITE_ONCE(torture_init_jiffies, jiffies); // Lockless reads.
824827
torture_print_module_parms();
825828
return true;
826829
}
@@ -836,6 +839,15 @@ void torture_init_end(void)
836839
}
837840
EXPORT_SYMBOL_GPL(torture_init_end);
838841

842+
/*
843+
* Get the torture_init_begin()-time value of the jiffies counter.
844+
*/
845+
unsigned long get_torture_init_jiffies(void)
846+
{
847+
return READ_ONCE(torture_init_jiffies);
848+
}
849+
EXPORT_SYMBOL_GPL(get_torture_init_jiffies);
850+
839851
/*
840852
* Clean up torture module. Please note that this is -not- invoked via
841853
* the usual module_exit() mechanism, but rather by an explicit call from

0 commit comments

Comments
 (0)