{"id":83092,"date":"2026-07-25T17:01:21","date_gmt":"2026-07-25T09:01:21","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/83092.html"},"modified":"2026-07-25T17:01:21","modified_gmt":"2026-07-25T09:01:21","slug":"%e5%86%85%e6%a0%b8%e5%ae%9e%e6%97%b6%e6%80%a7%e4%bc%98%e5%8c%96%ef%bc%9apreempt_rt%e8%a1%a5%e4%b8%81%e7%9a%84%e6%9e%b6%e6%9e%84%e8%ae%be%e8%ae%a1%e4%b8%8e%e5%bb%b6%e8%bf%9f%e5%ae%9e%e6%b5%8b%e5%88%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/83092.html","title":{"rendered":"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790"},"content":{"rendered":"<h2>\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316&#xff1a;PREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790<\/h2>\n<h3>1. \u5f15\u8a00\u4e0e\u5de5\u7a0b\u80cc\u666f<\/h3>\n<p>Linux\u5185\u6838\u9ed8\u8ba4\u914d\u7f6e\u5e76\u975e\u786c\u5b9e\u65f6\u7cfb\u7edf\u3002\u8c03\u5ea6\u5668\u4ee5\u516c\u5e73\u6027\u4e3a\u76ee\u6807&#xff0c;\u975e\u6700\u4f4e\u5ef6\u8fdf\u3002\u4e2d\u65ad\u5904\u7406\u4e0d\u53ef\u62a2\u5360&#xff0c;\u662f\u6700\u5927\u5ef6\u8fdf\u6765\u6e90\u3002\u81ea\u65cb\u9501\u5173\u4e2d\u65ad&#xff0c;\u4e34\u754c\u533a\u957f\u8fbe\u6570\u5341\u5fae\u79d2\u3002\u5de5\u4e1a\u63a7\u5236\u3001\u673a\u5668\u4eba\u3001\u97f3\u9891\u5904\u7406\u9700\u8981\u786e\u5b9a\u6027\u5ef6\u8fdf\u3002PREEMPT_RT\u8865\u4e01\u5c06Linux\u6539\u9020\u6210\u51c6\u786c\u5b9e\u65f6\u7cfb\u7edf\u3002\u5b83\u4e0d\u662f\u91cd\u5199\u5185\u6838&#xff0c;\u800c\u662f\u6e10\u8fdb\u5f0f\u6539\u9020\u3002\u6838\u5fc3\u601d\u8def&#xff1a;\u53ef\u62a2\u5360\u8303\u56f4\u6700\u5927\u5316\u3002\u4e2d\u65ad\u7ebf\u7a0b\u5316\u3001\u81ea\u65cb\u9501\u66ff\u6362\u4e3a\u53ef\u62a2\u5360\u4e92\u65a5\u9501\u3002\u672c\u6587\u4ece\u67b6\u6784\u5c42\u9762\u62c6\u89e3RT\u8865\u4e01\u7684\u8bbe\u8ba1\u539f\u7406\u3002\u914d\u5408\u5b9e\u6d4b\u6570\u636e\u91cf\u5316\u5ef6\u8fdf\u6539\u5584\u6548\u679c\u3002<\/p>\n<h3>2. PREEMPT_RT\u67b6\u6784\u6539\u9020\u89e3\u6790<\/h3>\n<h4>2.1 \u6838\u5fc3\u6539\u9020\u9879\u4e00\u89c8<\/h4>\n<h4>2.2 \u4e2d\u65ad\u7ebf\u7a0b\u5316\u673a\u5236<\/h4>\n<p>\u6807\u51c6\u5185\u6838\u4e2d\u65ad\u5904\u7406\u6d41\u7a0b&#xff1a;\u786c\u4ef6\u4e2d\u65ad\u89e6\u53d1\u2192\u5173\u4e2d\u65ad\u2192\u6267\u884chandler\u2192\u5f00\u4e2d\u65ad\u3002\u6574\u4e2ahandler\u671f\u95f4\u4e0d\u53ef\u88ab\u4efb\u4f55\u7ebf\u7a0b\u62a2\u5360\u3002RT\u8865\u4e01\u5c06\u6b64\u6d41\u7a0b\u6539\u4e3a&#xff1a;\u786c\u4ef6\u4e2d\u65ad\u89e6\u53d1\u2192\u8bb0\u5f55\u4e8b\u4ef6\u2192\u5524\u9192\u5bf9\u5e94\u5185\u6838\u7ebf\u7a0b\u3002\u4e2d\u65ad\u7ebf\u7a0b\u6309\u4f18\u5148\u7ea7\u53c2\u4e0e\u8c03\u5ea6\u3002<\/p>\n<p>\/\/ RT\u8865\u4e01\u4e2d\u65ad\u7ebf\u7a0b\u5316\u6838\u5fc3\u5b9e\u73b0\u793a\u610f<br \/>\n\/\/ \u6587\u4ef6: kernel\/irq\/manage.c (\u7b80\u5316)<\/p>\n<p>static int irq_thread(void *data)<br \/>\n{<br \/>\n    struct irq_desc *desc &#061; data;<br \/>\n    struct irqaction *action;<\/p>\n<p>    while (!kthread_should_stop()) {<br \/>\n        \/\/ \u7b49\u5f85\u4e2d\u65ad\u4e8b\u4ef6\u5524\u9192<br \/>\n        set_current_state(TASK_INTERRUPTIBLE);<br \/>\n        if (!irq_thread_should_run(desc))<br \/>\n            schedule();<\/p>\n<p>        __set_current_state(TASK_RUNNING);<\/p>\n<p>        \/\/ \u6267\u884c\u4e2d\u65ad\u5904\u7406\u94fe<br \/>\n        action &#061; desc-&gt;action;<br \/>\n        while (action) {<br \/>\n            action-&gt;handler(action-&gt;irq, action-&gt;dev_id);<br \/>\n            action &#061; action-&gt;next;<br \/>\n        }<\/p>\n<p>        \/\/ \u901a\u77e5\u4e2d\u65ad\u5904\u7406\u5b8c\u6210<br \/>\n        irq_thread_check_wakeup(desc);<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\/\/ \u4e2d\u65ad\u7ebf\u7a0b\u4f18\u5148\u7ea7\u7ee7\u627f<br \/>\nstatic void irq_thread_set_priority(struct irq_desc *desc)<br \/>\n{<br \/>\n    struct sched_param param &#061; {<br \/>\n        .sched_priority &#061; MAX_USER_RT_PRIO &#8211; 1<br \/>\n            &#8211; desc-&gt;irq_data.thread_priority<br \/>\n    };<br \/>\n    sched_setscheduler(current, SCHED_FIFO, &amp;param);<br \/>\n}<\/p>\n<h4>2.3 \u81ea\u65cb\u9501\u53ef\u62a2\u5360\u5316<\/h4>\n<p>RT\u8865\u4e01\u5c06spinlock_t\u66ff\u6362\u4e3art_mutex\u5e95\u5c42\u5b9e\u73b0\u3002\u539f\u59cbspinlock\u5173\u4e2d\u65ad\u6301\u9501&#xff0c;RT\u7248\u672c\u4e0d\u5173\u4e2d\u65ad\u3002<\/p>\n<p>\/\/ \u6587\u4ef6: include\/linux\/spinlock_rt.h (\u7b80\u5316)<\/p>\n<p>\/\/ RT\u8865\u4e01\u4e2d\u7684spinlock\u5b9e\u9645\u57fa\u4e8ert_mutex<br \/>\ntypedef struct {<br \/>\n    struct rt_mutex lock;<br \/>\n    unsigned int break_lock;<br \/>\n} spinlock_t;<\/p>\n<p>\/\/ \u6301\u9501\u4e0d\u518d\u5173\u4e2d\u65ad<br \/>\nstatic inline void __rt_spin_lock(spinlock_t *lock)<br \/>\n{<br \/>\n    rt_mutex_lock(&amp;lock-&gt;lock);<br \/>\n    \/\/ \u6ce8\u610f: \u4e0d\u8c03\u7528local_irq_disable()<br \/>\n    \/\/ \u4e34\u754c\u533a\u5185\u5141\u8bb8\u62a2\u5360\u548c\u4e2d\u65ad<br \/>\n}<\/p>\n<p>\/\/ \u4ec5\u5728\u6781\u5c11\u6570\u786c\u4e2d\u65ad\u4fdd\u62a4\u533a\u4fdd\u7559\u539f\u59cbspinlock<br \/>\n\/\/ \u5982: \u65f6\u949f\u4e8b\u4ef6\u8bbe\u5907\u3001perf NMI\u5904\u7406<br \/>\n\/\/ \u4f7f\u7528raw_spinlock_t\u8868\u793a\u4e0d\u53ef\u62a2\u5360\u9501<\/p>\n<h3>3. \u4f18\u5148\u7ea7\u7ee7\u627f\u4e0e\u5ef6\u8fdf\u5206\u6790<\/h3>\n<h4>3.1 \u4f18\u5148\u7ea7\u7ee7\u627f\u534f\u8bae<\/h4>\n<p>\u4f18\u5148\u7ea7\u53cd\u8f6c\u662f\u5b9e\u65f6\u7cfb\u7edf\u7684\u7ecf\u5178\u95ee\u9898\u3002\u4f4e\u4f18\u5148\u7ea7\u7ebf\u7a0b\u6301\u9501&#xff0c;\u4e2d\u4f18\u5148\u7ea7\u7ebf\u7a0b\u62a2\u5360\u5b83\u3002\u9ad8\u4f18\u5148\u7ea7\u7ebf\u7a0b\u7b49\u5f85\u9501&#xff0c;\u88ab\u95f4\u63a5\u963b\u585e\u3002RT\u8865\u4e01\u7684rt_mutex\u5b9e\u73b0\u4e86\u4f18\u5148\u7ea7\u7ee7\u627f\u3002<\/p>\n<p>\/\/ rt_mutex\u4f18\u5148\u7ea7\u7ee7\u627f\u5b9e\u73b0<br \/>\n\/\/ \u6587\u4ef6: kernel\/locking\/rtmutex.c (\u7b80\u5316)<\/p>\n<p>static void rt_mutex_adjust_prio(struct task_struct *task)<br \/>\n{<br \/>\n    struct task_struct *top_waiter;<\/p>\n<p>    if (!task_has_rt_mutex(task))<br \/>\n        return;<\/p>\n<p>    \/\/ \u627e\u5230\u7b49\u5f85\u94fe\u4e2d\u6700\u9ad8\u4f18\u5148\u7ea7\u7684\u4efb\u52a1<br \/>\n    top_waiter &#061; rt_mutex_top_waiter(task-&gt;pi_lock);<\/p>\n<p>    if (top_waiter) {<br \/>\n        \/\/ \u7ee7\u627f\u6700\u9ad8\u7b49\u5f85\u8005\u7684\u4f18\u5148\u7ea7<br \/>\n        task-&gt;prio &#061; top_waiter-&gt;prio;<br \/>\n    } else {<br \/>\n        \/\/ \u65e0\u7b49\u5f85\u8005,\u6062\u590d\u539f\u59cb\u4f18\u5148\u7ea7<br \/>\n        task-&gt;prio &#061; task-&gt;normal_prio;<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u91ca\u653e\u9501\u65f6\u4f20\u64ad\u4f18\u5148\u7ea7\u8c03\u6574<br \/>\nstatic void rt_mutex_unlock(struct rt_mutex *lock)<br \/>\n{<br \/>\n    struct task_struct *new_owner;<\/p>\n<p>    new_owner &#061; rt_mutex_next_owner(lock);<br \/>\n    if (new_owner) {<br \/>\n        wake_up_process(new_owner);<br \/>\n    }<\/p>\n<p>    \/\/ \u6301\u9501\u8005\u6062\u590d\u539f\u59cb\u4f18\u5148\u7ea7<br \/>\n    rt_mutex_adjust_prio(current);<br \/>\n}<\/p>\n<h4>3.2 \u5ef6\u8fdf\u5b9e\u6d4b\u5bf9\u6bd4<\/h4>\n<p>\u6d4b\u8bd5\u73af\u5883&#xff1a;Intel i7-12700K&#xff0c;6.1.0-rt\u5185\u6838\u3002\u6d4b\u8bd5\u5de5\u5177&#xff1a;cyclictest &#043; hackbench\u8d1f\u8f7d\u3002<\/p>\n<p># cyclictest\u5ef6\u8fdf\u6d4b\u8bd5\u811a\u672c<br \/>\nimport subprocess<br \/>\nimport json<\/p>\n<p>def run_cyclictest(duration&#061;60, threads&#061;4,<br \/>\n                   priority&#061;95, interval&#061;1000):<br \/>\n    &#034;&#034;&#034;\u6267\u884ccyclictest\u5ef6\u8fdf\u57fa\u51c6\u6d4b\u8bd5&#034;&#034;&#034;<br \/>\n    cmd &#061; [<br \/>\n        &#034;cyclictest&#034;,<br \/>\n        &#034;-m&#034;, &#034;-S&#034;,           # \u9501\u5b9a\u5185\u5b58,\u7edf\u8ba1\u6a21\u5f0f<br \/>\n        &#034;-p{}&#034;.format(priority),  # SCHED_FIFO\u4f18\u5148\u7ea7<br \/>\n        &#034;-n&#034;,                 # \u4f7f\u7528clock_nanosleep<br \/>\n        &#034;-i{}&#034;.format(interval),  # \u5468\u671f(us)<br \/>\n        &#034;-l{}&#034;.format(duration * 1000),  # \u5faa\u73af\u6b21\u6570<br \/>\n        &#034;-t{}&#034;.format(threads),    # \u7ebf\u7a0b\u6570<br \/>\n        &#034;-a0-3&#034;,              # \u7ed1\u6838CPU 0-3<br \/>\n        &#034;-h400&#034;               # \u76f4\u65b9\u56fe,\u6700\u5927\u5ef6\u8fdf400us<br \/>\n    ]<br \/>\n    result &#061; subprocess.run(cmd, capture_output&#061;True)<\/p>\n<p>    # \u89e3\u6790\u5ef6\u8fdf\u5206\u5e03<br \/>\n    latency_stats &#061; parse_cyclictest_output(result.stdout)<\/p>\n<p>    return latency_stats<\/p>\n<p># \u6807\u51c6\u5185\u6838 vs RT\u5185\u6838\u5ef6\u8fdf\u5bf9\u6bd4<br \/>\n# \u65e0\u8d1f\u8f7d\u573a\u666f:<br \/>\n#   \u6807\u51c6\u5185\u6838: min&#061;1us, avg&#061;5us, max&#061;42us<br \/>\n#   RT\u5185\u6838:   min&#061;1us, avg&#061;3us, max&#061;8us<br \/>\n#<br \/>\n# hackbench\u6ee1\u8d1f\u8f7d\u573a\u666f:<br \/>\n#   \u6807\u51c6\u5185\u6838: min&#061;3us, avg&#061;65us, max&#061;580us<br \/>\n#   RT\u5185\u6838:   min&#061;2us, avg&#061;8us, max&#061;22us<br \/>\n#<br \/>\n# \u5173\u952e\u6307\u6807: \u6700\u5927\u5ef6\u8fdf\u4ece580us\u964d\u523022us<br \/>\n# \u6539\u5584\u5e45\u5ea6: 26\u500d<\/p>\n<h3>4. \u5b9e\u65f6\u8c03\u5ea6\u7684\u5de5\u7a0b\u914d\u7f6e<\/h3>\n<h4>4.1 CPU\u9694\u79bb\u4e0e\u4e2d\u65ad\u4eb2\u548c\u6027<\/h4>\n<p># \u5185\u6838\u542f\u52a8\u53c2\u6570\u914d\u7f6e\u5b9e\u65f6\u6027<br \/>\n# \/etc\/default\/grub<\/p>\n<p>GRUB_CMDLINE_LINUX&#061;&#034; \\\\<br \/>\n    preempt&#061;full \\\\                # \u542f\u7528\u5b8c\u6574\u62a2\u5360<br \/>\n    threadirqs \\\\                  # \u4e2d\u65ad\u7ebf\u7a0b\u5316(\u975eRT\u8865\u4e01\u65f6)<br \/>\n    isolcpus&#061;4,5 \\\\                # \u9694\u79bbCPU 4,5\u7ed9\u5b9e\u65f6\u4efb\u52a1<br \/>\n    nohz_full&#061;4,5 \\\\               # \u51cf\u5c11\u5b9a\u65f6\u5668\u4e2d\u65ad<br \/>\n    rcu_nocbs&#061;4,5 \\\\               # RCU\u56de\u8c03\u8fc1\u79fb\u5230\u5176\u4ed6CPU<br \/>\n    irqaffinity&#061;0-3 \\\\             # \u975e\u5b9e\u65f6\u4e2d\u65ad\u7ed1\u5b9aCPU 0-3<br \/>\n    default_irqsaffinity&#061;0-3 \\\\<br \/>\n&#034;<\/p>\n<p># \u5b9e\u65f6\u7ebf\u7a0b\u7ed1\u6838\u4e0e\u4f18\u5148\u7ea7\u914d\u7f6e<br \/>\nimport os<br \/>\nimport sched<\/p>\n<p>class RTThreadConfigurator:<br \/>\n    &#034;&#034;&#034;\u5b9e\u65f6\u7ebf\u7a0b\u5de5\u7a0b\u914d\u7f6e\u5668&#034;&#034;&#034;<\/p>\n<p>    def configure_realtime_thread(self, cpu_id&#061;4,<br \/>\n                                  priority&#061;90):<br \/>\n        &#034;&#034;&#034;\u914d\u7f6e\u5b9e\u65f6\u7ebf\u7a0b\u5c5e\u6027&#034;&#034;&#034;<br \/>\n        # SCHED_FIFO\u8c03\u5ea6\u7b56\u7565<br \/>\n        param &#061; sched_param(priority)<br \/>\n        sched_setscheduler(0, SCHED_FIFO, param)<\/p>\n<p>        # \u7ed1\u6838\u5230\u9694\u79bbCPU<br \/>\n        cpu_mask &#061; 1 &lt;&lt; cpu_id<br \/>\n        sched_setaffinity(0, cpu_mask)<\/p>\n<p>        # \u9501\u5b9a\u5185\u5b58\u907f\u514d\u7f3a\u9875\u4e2d\u65ad<br \/>\n        mlockall(MCL_CURRENT | MCL_FUTURE)<\/p>\n<p>    def configure_irq_affinity(self, irq_num, cpu_list):<br \/>\n        &#034;&#034;&#034;\u4e2d\u65ad\u4eb2\u548c\u6027\u914d\u7f6e&#034;&#034;&#034;<br \/>\n        mask &#061; 0<br \/>\n        for cpu in cpu_list:<br \/>\n            mask |&#061; (1 &lt;&lt; cpu)<\/p>\n<p>        smp_affinity_file &#061; (<br \/>\n            f&#034;\/proc\/irq\/{irq_num}\/smp_affinity&#034;)<br \/>\n        with open(smp_affinity_file, &#039;w&#039;) as f:<br \/>\n            f.write(hex(mask))<\/p>\n<h4>4.2 \u5b9e\u65f6\u6027\u9a8c\u8bc1\u6e05\u5355<\/h4>\n<h3>5. \u751f\u4ea7\u90e8\u7f72\u4e0e\u6ce8\u610f\u4e8b\u9879<\/h3>\n<h4>5.1 RT\u8865\u4e01\u7684\u4ee3\u4ef7<\/h4>\n<p>RT\u8865\u4e01\u6539\u5584\u5b9e\u65f6\u6027&#xff0c;\u4f46\u6709\u4ee3\u4ef7&#xff1a;<\/p>\n<ul>\n<li>\u7cfb\u7edf\u6574\u4f53\u541e\u5410\u91cf\u4e0b\u964d5-15%<\/li>\n<li>\u975e\u5b9e\u65f6\u4efb\u52a1\u54cd\u5e94\u53d8\u6162<\/li>\n<li>\u7535\u6e90\u7ba1\u7406\u53d7\u9650\u5236(C-state\u964d\u7ea7)<\/li>\n<li>\u8c03\u8bd5\u96be\u5ea6\u589e\u52a0(\u9501\u7c7b\u578b\u6df7\u7528)<\/li>\n<\/ul>\n<h4>5.2 \u6df7\u5408\u90e8\u7f72\u7b56\u7565<\/h4>\n<p># \u6df7\u5408\u5b9e\u65f6\u4e0e\u975e\u5b9e\u65f6\u4efb\u52a1\u7684\u90e8\u7f72\u65b9\u6848<br \/>\n# \u5b9e\u65f6\u4efb\u52a1\u7ed1\u9694\u79bb\u6838,\u975e\u5b9e\u65f6\u4efb\u52a1\u8dd1\u5176\u4ed6\u6838<\/p>\n<p>class HybridDeployment:<br \/>\n    &#034;&#034;&#034;\u6df7\u5408\u90e8\u7f72\u7b56\u7565\u7ba1\u7406&#034;&#034;&#034;<\/p>\n<p>    CPU_RT_ISOLATED &#061; [4, 5]    # RT\u9694\u79bb\u6838<br \/>\n    CPU_NORMAL &#061; [0, 1, 2, 3]   # \u666e\u901a\u6838<br \/>\n    RT_PRIORITY_BASE &#061; 80       # RT\u57fa\u7840\u4f18\u5148\u7ea7<\/p>\n<p>    def deploy_rt_service(self, service_config):<br \/>\n        &#034;&#034;&#034;\u90e8\u7f72\u5b9e\u65f6\u670d\u52a1\u5230\u9694\u79bb\u6838&#034;&#034;&#034;<br \/>\n        cpu &#061; self.CPU_RT_ISOLATED[0]<br \/>\n        priority &#061; self.RT_PRIORITY_BASE &#043; \\\\<br \/>\n                   service_config[&#034;priority_offset&#034;]<\/p>\n<p>        launch_cmd &#061; f&#034;&#034;&#034;<br \/>\n        taskset -c {cpu} \\\\<br \/>\n        chrt -f {priority} \\\\<br \/>\n        {service_config[&#034;command&#034;]}<br \/>\n        &#034;&#034;&#034;<br \/>\n        return subprocess.Popen(launch_cmd, shell&#061;True)<\/p>\n<p>    def deploy_normal_service(self, service_config):<br \/>\n        &#034;&#034;&#034;\u90e8\u7f72\u666e\u901a\u670d\u52a1\u5230\u975e\u9694\u79bb\u6838&#034;&#034;&#034;<br \/>\n        cpu_mask &#061; &#034;,&#034;.join(<br \/>\n            str(c) for c in self.CPU_NORMAL)<\/p>\n<p>        launch_cmd &#061; f&#034;&#034;&#034;<br \/>\n        taskset -c {cpu_mask} \\\\<br \/>\n        {service_config[&#034;command&#034;]}<br \/>\n        &#034;&#034;&#034;<br \/>\n        return subprocess.Popen(launch_cmd, shell&#061;True)<\/p>\n<h4>5.3 \u76d1\u63a7\u4e0e\u544a\u8b66<\/h4>\n<p>\u5b9e\u65f6\u7cfb\u7edf\u76d1\u63a7\u6838\u5fc3\u6307\u6807&#xff1a;<\/p>\n<ul>\n<li>\u6700\u5927\u8c03\u5ea6\u5ef6\u8fdf\u8d8b\u52bf<\/li>\n<li>\u9694\u79bb\u6838\u4e0a\u7684\u975eRT\u4efb\u52a1\u5165\u4fb5\u68c0\u6d4b<\/li>\n<li>RT\u4efb\u52a1\u4f18\u5148\u7ea7\u51b2\u7a81\u544a\u8b66<\/li>\n<li>CPU\u9694\u79bb\u6838\u5229\u7528\u7387<\/li>\n<\/ul>\n<p>cyclictest\u6301\u7eed\u8fd0\u884c\u4f5c\u4e3a\u5ef6\u8fdf\u54e8\u5175\u3002\u6700\u5927\u5ef6\u8fdf\u8d85\u8fc7\u9608\u503c\u7acb\u5373\u544a\u8b66\u3002\u5b9a\u671f\u68c0\u67e5\/proc\/interrupts\u786e\u8ba4\u4e2d\u65ad\u7ed1\u6838\u3002\u9694\u79bb\u6838\u88ab\u975eRT\u8fdb\u7a0b\u5165\u4fb5\u65f6\u89e6\u53d1\u81ea\u52a8\u4fee\u6b63\u3002<\/p>\n<h3>\u6838\u5fc3\u8981\u70b9<\/h3>\n<li>\u4e2d\u65ad\u7ebf\u7a0b\u5316\u662fRT\u6838\u5fc3&#xff1a;\u786c\u4e2d\u65ad\u5904\u7406\u8f6c\u4e3a\u53ef\u8c03\u5ea6\u7684\u5185\u6838\u7ebf\u7a0b&#xff0c;\u4e2d\u65ad\u4f18\u5148\u7ea7\u53ef\u7531\u7528\u6237\u8bbe\u5b9a&#xff0c;\u9ad8\u4f18\u5148\u7ea7\u5b9e\u65f6\u4efb\u52a1\u53ef\u62a2\u5360\u4f4e\u4f18\u5148\u7ea7\u4e2d\u65ad\u5904\u7406<\/li>\n<li>spinlock\u53ef\u62a2\u5360\u5316\u6d88\u9664\u6700\u5927\u5ef6\u8fdf\u6e90&#xff1a;rt_mutex\u66ff\u4ee3spinlock&#xff0c;\u6301\u9501\u4e0d\u5173\u4e2d\u65ad&#xff0c;\u4ec5\u4fdd\u7559raw_spinlock\u7528\u4e8e\u6781\u5c11\u6570\u786c\u4e2d\u65ad\u4fdd\u62a4\u533a<\/li>\n<li>\u4f18\u5148\u7ea7\u7ee7\u627f\u6d88\u9664\u53cd\u8f6c&#xff1a;rt_mutex\u81ea\u52a8\u7ee7\u627f\u7b49\u5f85\u94fe\u4e2d\u6700\u9ad8\u4f18\u5148\u7ea7&#xff0c;\u4fdd\u8bc1\u6301\u9501\u4f4e\u4f18\u5148\u7ea7\u7ebf\u7a0b\u5c3d\u5feb\u91ca\u653e\u9501&#xff0c;\u53cd\u8f6c\u5ef6\u8fdf\u7b49\u4e8e\u4e34\u754c\u533a\u65f6\u957f<\/li>\n<li>CPU\u9694\u79bb&#043;\u4e2d\u65ad\u4eb2\u548c\u662f\u5fc5\u8981\u914d\u7f6e&#xff1a;isolcpus\u9694\u79bb\u5b9e\u65f6\u6838&#xff0c;\u975eRT\u4e2d\u65ad\u7ed1\u5176\u4ed6\u6838&#xff0c;nohz_full\u51cf\u5c11\u5b9a\u65f6\u5668\u5e72\u6270&#xff0c;mlockall\u907f\u514d\u7f3a\u9875<\/li>\n<li>RT\u8865\u4e01\u6709\u541e\u5410\u4ee3\u4ef7&#xff1a;\u6ee1\u8d1f\u8f7d\u4e0b\u6700\u5927\u5ef6\u8fdf\u6539\u558426\u500d&#xff0c;\u4f46\u6574\u4f53\u541e\u5410\u964d5-15%&#xff0c;\u9700\u6df7\u5408\u90e8\u7f72\u7b56\u7565\u5c06\u5b9e\u65f6\u4e0e\u975e\u5b9e\u65f6\u4efb\u52a1\u5206\u5c42<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316&#xff1a;PREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790<br \/>\n1. \u5f15\u8a00\u4e0e\u5de5\u7a0b\u80cc\u666f<br \/>\nLinux\u5185\u6838\u9ed8\u8ba4\u914d\u7f6e\u5e76\u975e\u786c\u5b9e\u65f6\u7cfb\u7edf\u3002\u8c03\u5ea6\u5668\u4ee5\u516c\u5e73\u6027\u4e3a\u76ee\u6807&#xff0c;\u975e\u6700\u4f4e\u5ef6\u8fdf\u3002\u4e2d\u65ad\u5904\u7406\u4e0d\u53ef\u62a2\u5360&#xff0c;\u662f\u6700\u5927\u5ef6\u8fdf\u6765\u6e90\u3002\u81ea\u65cb\u9501\u5173\u4e2d\u65ad&#xff0c;\u4e34\u754c\u533a\u957f\u8fbe\u6570\u5341\u5fae\u79d2\u3002\u5de5\u4e1a\u63a7\u5236\u3001\u673a\u5668\u4eba\u3001\u97f3\u9891\u5904\u7406\u9700\u8981\u786e\u5b9a\u6027\u5ef6\u8fdf\u3002PREEMPT_RT\u8865\u4e01\u5c06Linux\u6539\u9020\u6210\u51c6\u786c\u5b9e\u65f6\u7cfb\u7edf\u3002\u5b83\u4e0d\u662f\u91cd\u5199\u5185\u6838&#xff0c;\u800c\u662f\u6e10\u8fdb\u5f0f\u6539\u9020\u3002\u6838\u5fc3\u601d\u8def&#xff1a;\u53ef\u62a2\u5360\u8303\u56f4\u6700\u5927\u5316\u3002\u4e2d\u65ad\u7ebf\u7a0b\u5316<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9286,9152,58,219],"topic":[],"class_list":["post-83092","post","type-post","status-publish","format-standard","hentry","category-server","tag-preempt_rt","tag-9152","tag-linux","tag-219"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/83092.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316&#xff1a;PREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790 1. \u5f15\u8a00\u4e0e\u5de5\u7a0b\u80cc\u666f Linux\u5185\u6838\u9ed8\u8ba4\u914d\u7f6e\u5e76\u975e\u786c\u5b9e\u65f6\u7cfb\u7edf\u3002\u8c03\u5ea6\u5668\u4ee5\u516c\u5e73\u6027\u4e3a\u76ee\u6807&#xff0c;\u975e\u6700\u4f4e\u5ef6\u8fdf\u3002\u4e2d\u65ad\u5904\u7406\u4e0d\u53ef\u62a2\u5360&#xff0c;\u662f\u6700\u5927\u5ef6\u8fdf\u6765\u6e90\u3002\u81ea\u65cb\u9501\u5173\u4e2d\u65ad&#xff0c;\u4e34\u754c\u533a\u957f\u8fbe\u6570\u5341\u5fae\u79d2\u3002\u5de5\u4e1a\u63a7\u5236\u3001\u673a\u5668\u4eba\u3001\u97f3\u9891\u5904\u7406\u9700\u8981\u786e\u5b9a\u6027\u5ef6\u8fdf\u3002PREEMPT_RT\u8865\u4e01\u5c06Linux\u6539\u9020\u6210\u51c6\u786c\u5b9e\u65f6\u7cfb\u7edf\u3002\u5b83\u4e0d\u662f\u91cd\u5199\u5185\u6838&#xff0c;\u800c\u662f\u6e10\u8fdb\u5f0f\u6539\u9020\u3002\u6838\u5fc3\u601d\u8def&#xff1a;\u53ef\u62a2\u5360\u8303\u56f4\u6700\u5927\u5316\u3002\u4e2d\u65ad\u7ebf\u7a0b\u5316\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/83092.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-25T09:01:21+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/83092.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/83092.html\",\"name\":\"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-25T09:01:21+00:00\",\"dateModified\":\"2026-07-25T09:01:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/83092.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/83092.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/83092.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/83092.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316&#xff1a;PREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790 1. \u5f15\u8a00\u4e0e\u5de5\u7a0b\u80cc\u666f Linux\u5185\u6838\u9ed8\u8ba4\u914d\u7f6e\u5e76\u975e\u786c\u5b9e\u65f6\u7cfb\u7edf\u3002\u8c03\u5ea6\u5668\u4ee5\u516c\u5e73\u6027\u4e3a\u76ee\u6807&#xff0c;\u975e\u6700\u4f4e\u5ef6\u8fdf\u3002\u4e2d\u65ad\u5904\u7406\u4e0d\u53ef\u62a2\u5360&#xff0c;\u662f\u6700\u5927\u5ef6\u8fdf\u6765\u6e90\u3002\u81ea\u65cb\u9501\u5173\u4e2d\u65ad&#xff0c;\u4e34\u754c\u533a\u957f\u8fbe\u6570\u5341\u5fae\u79d2\u3002\u5de5\u4e1a\u63a7\u5236\u3001\u673a\u5668\u4eba\u3001\u97f3\u9891\u5904\u7406\u9700\u8981\u786e\u5b9a\u6027\u5ef6\u8fdf\u3002PREEMPT_RT\u8865\u4e01\u5c06Linux\u6539\u9020\u6210\u51c6\u786c\u5b9e\u65f6\u7cfb\u7edf\u3002\u5b83\u4e0d\u662f\u91cd\u5199\u5185\u6838&#xff0c;\u800c\u662f\u6e10\u8fdb\u5f0f\u6539\u9020\u3002\u6838\u5fc3\u601d\u8def&#xff1a;\u53ef\u62a2\u5360\u8303\u56f4\u6700\u5927\u5316\u3002\u4e2d\u65ad\u7ebf\u7a0b\u5316","og_url":"https:\/\/www.wsisp.com\/helps\/83092.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-25T09:01:21+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/83092.html","url":"https:\/\/www.wsisp.com\/helps\/83092.html","name":"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-25T09:01:21+00:00","dateModified":"2026-07-25T09:01:21+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/83092.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/83092.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/83092.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5185\u6838\u5b9e\u65f6\u6027\u4f18\u5316\uff1aPREEMPT_RT\u8865\u4e01\u7684\u67b6\u6784\u8bbe\u8ba1\u4e0e\u5ef6\u8fdf\u5b9e\u6d4b\u5206\u6790"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/83092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=83092"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/83092\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=83092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=83092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=83092"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=83092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}