Skip to content

Commit 26e1ac4

Browse files
author
fengbojiang
committed
docs: sync three-layer architecture docs and knowledge graph with primary_slim
Add primary_slim switch and kni_inject_rp cross-process race fix to Layer1 (multi-process diagram + KNI section), Layer2 (config struct + config example), Layer3 (stale line count removed), Knowledge Base Summary (v1.8), and Knowledge Graph Wiki (section 2B delta entry).
1 parent 0ed0db3 commit 26e1ac4

7 files changed

Lines changed: 38 additions & 7 deletions

‎docs/F-Stack_Architecture_Layer1_System_Overview.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ F-Stack (User-space)
713713
**KNI and virtio Selection**:
714714
715715
- In the current version, KNI functionality is retained, but the underlying implementation has switched from the `rte_kni.ko` kernel module to `virtio_user` (see lib/Makefile:34), no longer depending on the kernel KNI module
716+
- When `primary_slim=1`, KNI processing is handled by the primary process (virtio_user vdev can only be created/operated by primary); KNI RX packets are forwarded to the owner secondary's TX queue via `kni_inject_rp` shared ring to avoid cross-process TX queue race (see `docs/issue_1078/zh_cn/13-kni-slim-regression.md`)
716717
717718
---
718719

‎docs/F-Stack_Knowledge_Base_Summary.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,11 @@ Performance Optimization:
663663
### 8.1 Version Information
664664

665665
```
666-
Knowledge base version: 1.7 (adds issue #1076 mbuf water-level backpressure + issue #1078 primary_slim control-plane-only switch, 2026-08-10; on top of 1.6 native-mt SMP-aware pcpu/SMR slot isolation + global uma_crit_lock removal + MTU/jumbo-frame support; on top of 1.5 R10 ff_readv/ff_writev/ff_ioctl/ff_dup/ff_dup2 kernel-fd routing + select/poll documented limits, 2026-06-18; on top of 1.4 R9 ff_kqueue/ff_kevent coexistence + IPv6 IPV6_V6ONLY sync)
666+
Knowledge base version: 1.8 (adds issue #1078 post-implementation fixes: KNI inject ring for cross-process TX queue race + KNI stat consistency + exit cleanup analysis, 2026-08-11; on top of 1.7 mbuf water-level backpressure + primary_slim control-plane-only switch; on top of 1.6 native-mt SMP-aware pcpu/SMR slot isolation + global uma_crit_lock removal + MTU/jumbo-frame support; on top of 1.5 R10 ff_readv/ff_writev/ff_ioctl/ff_dup/ff_dup2 kernel-fd routing + select/poll documented limits, 2026-06-18; on top of 1.4 R9 ff_kqueue/ff_kevent coexistence + IPv6 IPV6_V6ONLY sync)
667667
F-Stack version: v1.26 (branch feature/1.26)
668668
FreeBSD port base: 15.0 (was 13.0 in v1.25)
669669
DPDK version: 24.11.6 LTS (upgraded from 23.11.5 LTS on 2026-06-09)
670-
Generation date: 2026-03-20 (last sync 2026-08-10)
670+
Generation date: 2026-03-20 (last sync 2026-08-11)
671671
Update cycle: Per F-Stack version updates (recommended every 6-12 months)
672672
```
673673

‎docs/zh_cn/F-Stack_Architecture_Layer1_System_Overview.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,9 @@ F-Stack 部署:
487487
│ ├─ DPDK EAL 初始化 │
488488
│ ├─ 创建共享 hugepage/mempool │
489489
│ ├─ 启动所有从进程 │
490-
│ └─ 监听来自工具的 IPC 消息 │
490+
│ ├─ 监听来自工具的 IPC 消息 │
491+
│ └─ primary_slim=1 时: 不分配 rx/tx 队列, │
492+
│ 仅控制面 (NIC init / KNI init / IPC / 扩堆) │
491493
│ │
492494
│ 从进程 1 - CPU 1 从进程 2 - CPU 2 │
493495
│ ┌──────────────────┐ ┌──────────────────┐
@@ -697,6 +699,7 @@ F-Stack (用户态)
697699
**KNI 和 virtio 选择**:
698700
699701
- 当前版本 KNI 功能保留,但底层实现已从 `rte_kni.ko` 内核模块切换为 `virtio_user`(见 lib/Makefile:34),不再依赖内核 KNI 模块
702+
- `primary_slim=1` 模式下 KNI 由 primary 进程处理(virtio_user vdev 只能由 primary 创建和操作);KNI RX 包通过 `kni_inject_rp` 共享 ring 转发给 owner secondary 的 TX queue,避免跨进程 TX queue 竞态(详见 `docs/issue_1078/zh_cn/13-kni-slim-regression.md`)
700703
701704
---
702705

‎docs/zh_cn/F-Stack_Architecture_Layer2_Interface_Specification.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ struct ff_config {
351351
/* TX burst queue drain nodelay dalay time */
352352
unsigned pkt_tx_delay;
353353
354+
/* primary_slim: primary holds no rx/tx queue, control-plane only */
355+
int primary_slim;
356+
unsigned primary_slim_idle_sleep; /* default 1000us */
357+
354358
/* list of proc-lcore */
355359
uint16_t *proc_lcore;
356360
@@ -378,6 +382,7 @@ struct ff_config {
378382
char *method;
379383
char *tcp_port;
380384
char *udp_port;
385+
int owner_proc_id; // primary_slim=1 时 KNI runtime owner secondary proc_id
381386
} kni;
382387
383388
struct {
@@ -590,6 +595,10 @@ symmetric_rss = 0 # 双向 RSS 对称性
590595
idle_sleep = 0 # 空闲时 sleep (微秒)
591596
pkt_tx_delay = 100 # 包发送延迟 (关闭立即发)
592597
enable_kni = 1 # 启用虚拟网卡
598+
# primary_slim=1: primary 不分配 rx/tx 队列,仅控制面
599+
# primary_slim=0 (默认): primary 也参与数据面
600+
primary_slim = 0
601+
primary_slim_idle_sleep = 1000 # primary_slim=1 时空闲 sleep (微秒)
593602
594603
[port0]
595604
# 网卡 0 的配置

‎docs/zh_cn/F-Stack_Architecture_Layer3_Function_Index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ int ff_setsockopt_wrapper(int s, int level, int optname,
822822
- **Error Code 映射**:Linux errno → FreeBSD errno
823823
- **Address Family 映射**:AF_INET6: 10 (Linux) ↔ 28 (FreeBSD)
824824
825-
### 3.2 ff_dpdk_if.c (2907 行) - NIC 驱动层
825+
### 3.2 ff_dpdk_if.c - NIC 驱动层
826826
827827
**全局变量**(影响性能的关键状态):
828828

‎docs/zh_cn/F-Stack_Knowledge_Base_Summary.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,11 @@ F-Stack 相关:
659659
### 8.1 版本信息
660660

661661
```
662-
知识库版本: 1.5(新增 R10:ff_readv/ff_writev/ff_ioctl/ff_dup/ff_dup2 内核 fd 路由 + select/poll 文档限制,2026-06-18;基于 1.4 R9 ff_kqueue/ff_kevent 共存 + IPv6 IPV6_V6ONLY 同步)
662+
知识库版本: 1.8(新增 issue #1078 post-implementation 修复:KNI inject ring 消除跨进程 TX queue 竞态 + KNI 统计一致性 + 退出清理分析,2026-08-11;基于 1.7 mbuf 水位背压 + primary_slim 主进程瘦身开关;基于 1.6 native-mt SMP-aware pcpu/SMR slot 隔离 + 全局 uma_crit_lock 移除 + MTU/巨帧支持;基于 1.5 R10 ff_readv/ff_writev/ff_ioctl/ff_dup/ff_dup2 内核 fd 路由 + select/poll 文档限制)
663663
F-Stack 版本: v1.26(分支 feature/1.26)
664664
FreeBSD 移植基线: 15.0(v1.25 时为 13.0)
665665
DPDK 版本: 24.11.6 LTS(2026-06-09 自 23.11.5 LTS 升级)
666-
生成日期: 2026-03-20(最近同步 2026-06-18)
666+
生成日期: 2026-03-20(最近同步 2026-08-11)
667667
更新周期: 按 F-Stack 版本更新 (建议每 6-12 个月)
668668
```
669669

‎docs/zh_cn/KNOWLEDGE_GRAPH_WIKI.md‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
## 2A. 索引后代码 delta:`FF_KERNEL_COEXIST` 内核栈共存
4545

46-
> **人工补录(尚未重索引)**:上方图谱索引于 commit `208b0c4`(2026-06-08)。此后 `feature/1.26` 分支落地了 **`FF_KERNEL_COEXIST` 自动双栈共存** 特性(commits `ba148589d` → `55a84f313`),**R9** 增量(kqueue/kevent 共存 + IPv6 `IPV6_V6ONLY`),以及 **R10** 增量(`ff_readv`/`ff_writev`/`ff_ioctl` 内核 fd 路由 + `ff_dup`/`ff_dup2`)。在下次 `npx gitnexus analyze` 之前,以下表面以当前源码为准人工记录。
46+
> **人工补录(尚未重索引)**:上方图谱索引于 commit `208b0c4`(2026-06-08)。此后 `feature/1.26` 分支落地了 **`FF_KERNEL_COEXIST` 自动双栈共存** 特性(commits `ba148589d` → `55a84f313`),**R9** 增量(kqueue/kevent 共存 + IPv6 `IPV6_V6ONLY`),**R10** 增量(`ff_readv`/`ff_writev`/`ff_ioctl` 内核 fd 路由 + `ff_dup`/`ff_dup2`),以及 **issue #1078 primary_slim 主进程瘦身特性**(commits `1c28aaa2d` → `f7961b083` → `f23f1a464` → `f250ad1ea`)。在下次 `npx gitnexus analyze` 之前,以下表面以当前源码为准人工记录。
4747
4848
该特性让单进程从同一个事件循环里(`ff_epoll_wait`,自 R9 起也支持 `ff_kqueue`/`ff_kevent`),同时通过 F-Stack 用户态栈(经 DPDK 网卡)与宿主 Linux 内核栈(经 loopback / 管理网卡)对外服务。**默认关闭**(编译期宏 + 运行期 `kernel_coexist` 开关双门控);关闭时默认 / `SOCK_FSTACK` 路径逐字节不变。
4949

@@ -61,6 +61,24 @@
6161

6262
可追溯:`docs/kernel_event_support_spec/` 与 `docs/kernel_event_support_spec/zh_cn/`(00-10),含 R8 review-gate 日志、R9 计划 `plan-r9-kqueue-coexist-ipv6.md` 与 R10 计划 `plan-r10-readv-writev-ioctl-coexist.md`。
6363

64+
## 2B. 索引后代码 delta:issue #1078 `primary_slim` 主进程瘦身
65+
66+
> **人工补录(尚未重索引)**:issue #1078 在 `feature/1.26` 分支落地(commits `1c28aaa2d` → `f7961b083` → `f23f1a464` → `f250ad1ea` → `da99a766f`)。
67+
68+
`primary_slim=1` 让 primary 不分配 rx/tx 队列,仅承担控制面职责(NIC 初始化、KNI 初始化、IPC 服务端、扩堆代理)。配套 `owner_proc_id` 指定 KNI runtime owner secondary。KNI 由 primary 执行(virtio_user vdev 只能由 primary 创建/操作),KNI RX 包通过 `kni_inject_rp` 共享 ring 转发给 owner secondary 的 TX queue,消除跨进程 TX queue 竞态。
69+
70+
| 维度 | 源码位置 |
71+
|------|----------|
72+
| 配置开关(默认关) | `lib/ff_config.c`:`[dpdk] primary_slim=0/1` + `primary_slim_idle_sleep`(默认 1000us);`[kni] owner_proc_id` |
73+
| 配置结构体 | `lib/ff_config.h`:`struct ff_config.dpdk.primary_slim` + `primary_slim_idle_sleep` + `kni.owner_proc_id` |
74+
| early return | `lib/ff_dpdk_if.c:541-546`:`primary_slim && PRIMARY && nb_rx_queue==0` 时 `return 0` 跳过数据面初始化 |
75+
| main_loop KNI 门控 | `lib/ff_dpdk_if.c:2905-2940`:`primary_slim` 时 primary 执行 `ff_kni_process`;owner secondary 执行 `ff_kni_inject_process` |
76+
| KNI inject ring | `lib/ff_dpdk_kni.c`:`kni_inject_rp[]` 全局数组 + `ff_kni_alloc` 中 create/lookup + `kni_process_rx` redirect + `ff_kni_inject_process` dequeue/tx_burst |
77+
| API | `lib/ff_dpdk_if.h`:`ff_is_slim_primary()` 返回 `primary_slim && RTE_PROC_PRIMARY` |
78+
| 退出清理 | `lib/ff_dpdk_if.c:3004-3026`:`ff_dpdk_run()` 在 `primary_slim+PRIMARY` 时跳过 `rte_eal_cleanup()`(详见 `docs/issue_1078/zh_cn/14-primary-slim-exit-cleanup-analysis.md`) |
79+
80+
可追溯:`docs/issue_1078/zh_cn/`(00-15),含可行性调研、PoC 实验、正式实现、post-implementation 修复(KNI 回归 + 跨进程 TX queue 竞态)、退出清理分析、结项报告。
81+
6482
---
6583

6684
## 3. 目录结构

0 commit comments

Comments
 (0)