函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:kernel\locking\locktorture.c Create Date:2022-07-27 10:54:42
首页 Copyright©Brick

650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
/*
 * Lock torture reader kthread.  Repeatedly acquires and releases
 * the reader lock.
 */
static int lock_torture_reader(void *arg)
{
    struct lock_stress_stats *lrsp = arg;
    static DEFINE_TORTURE_RANDOM(rand);
 
    VERBOSE_TOROUT_STRING("lock_torture_reader task started");
    set_user_nice(current, MAX_NICE);
 
    do {
        if ((torture_random(&rand) & 0xfffff) == 0)
            schedule_timeout_uninterruptible(1);
 
        cxt.cur_ops->readlock();
        lock_is_read_held = 1;
        if (WARN_ON_ONCE(lock_is_write_held))
            lrsp->n_lock_fail++; /* rare, but... */
 
        lrsp->n_lock_acquired++;
        cxt.cur_ops->read_delay(&rand);
        lock_is_read_held = 0;
        cxt.cur_ops->readunlock();
 
        stutter_wait("lock_torture_reader");
    } while (!torture_must_stop());
    torture_kthread_stopping("lock_torture_reader");
    return 0;
}