为什么在此Linux补丁中应该用raw_spinlock替换spinlock?

时间:2019-05-24 02:28:14

标签: c linux linux-kernel spinlock

我正在尝试了解此Linux提交(提交ID 830eec24673a982bff4df85ba4d17e4a6ff201a7)。它将自旋锁转换为raw_spinlock。但是我不清楚为什么自旋锁会唤醒被阻塞的空闲任务,但在这里失败了。以及为什么raw_spinlock可以解决此问题。

我已经阅读了Linux代码,发现spin_lock只是raw_spin_lock的包装。 spinlock_t是raw_spinlock_t的包装。看来它们没有显着差异。我还了解到,它们在抢占方面可能有所不同,但是我不确定这与此补丁程序有关。

@@ -32,7 +32,7 @@ static void write_pen_release(int val)
    sync_cache_w(&pen_release);
 }

-static DEFINE_SPINLOCK(boot_lock);
+static DEFINE_RAW_SPINLOCK(boot_lock);

 void versatile_secondary_init(unsigned int cpu)
 {
@@ -45,8 +45,8 @@ void versatile_secondary_init(unsigned int cpu)
    /*
     * Synchronise with the boot thread.
     */
-   spin_lock(&boot_lock);
-   spin_unlock(&boot_lock);
+   raw_spin_lock(&boot_lock);
+   raw_spin_unlock(&boot_lock);
 }

 int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)
@@ -57,7 +57,7 @@ int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)
     * Set synchronisation state between this boot processor
     * and the secondary one
     */
-   spin_lock(&boot_lock);
+   raw_spin_lock(&boot_lock);

    /*
     * This is really belt and braces; we hold unintended secondary
@@ -87,7 +87,7 @@ int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)
     * now the secondary core is starting up let it run its
     * calibrations, then wait for it to finish
     */
-   spin_unlock(&boot_lock);
+   raw_spin_unlock(&boot_lock);

    return pen_release != -1 ? -ENOSYS : 0;
 }

0 个答案:

没有答案