• P
    clocksource: Provide kernel module to test clocksource watchdog · 1253b9b8
    Paul E. McKenney 提交于
    When the clocksource watchdog marks a clock as unstable, this might
    be due to that clock being unstable or it might be due to delays that
    happen to occur between the reads of the two clocks.  It would be good
    to have a way of testing the clocksource watchdog's ability to
    distinguish between these two causes of clock skew and instability.
    
    Therefore, provide a new clocksource-wdtest module selected by a new
    TEST_CLOCKSOURCE_WATCHDOG Kconfig option.  This module has a single module
    parameter named "holdoff" that provides the number of seconds of delay
    before testing should start, which defaults to zero when built as a module
    and to 10 seconds when built directly into the kernel.  Very large systems
    that boot slowly may need to increase the value of this module parameter.
    
    This module uses hand-crafted clocksource structures to do its testing,
    thus avoiding messing up timing for the rest of the kernel and for user
    applications.  This module first verifies that the ->uncertainty_margin
    field of the clocksource structures are set sanely.  It then tests the
    delay-detection capability of the clocksource watchdog, increasing the
    number of consecutive delays injected, first provoking console messages
    complaining about the delays and finally forcing a clock-skew event.
    Unexpected test results cause at least one WARN_ON_ONCE() console splat.
    If there are no splats, the test has passed.  Finally, it fuzzes the
    value returned from a clocksource to test the clocksource watchdog's
    ability to detect time skew.
    
    This module checks the state of its clocksource after each test, and
    uses WARN_ON_ONCE() to emit a console splat if there are any failures.
    This should enable all types of test frameworks to detect any such
    failures.
    
    This facility is intended for diagnostic use only, and should be avoided
    on production systems.
    Reported-by: NChris Mason <clm@fb.com>
    Suggested-by: NThomas Gleixner <tglx@linutronix.de>
    Signed-off-by: NPaul E. McKenney <paulmck@kernel.org>
    Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
    Tested-by: NFeng Tang <feng.tang@intel.com>
    Link: https://lore.kernel.org/r/20210527190124.440372-5-paulmck@kernel.org
    1253b9b8
Kconfig.debug 85.2 KB