Skip to content

Commit 0a9112b

Browse files
committed
doc(kb): update knowledge graph wiki, summary and top-level README for adapter/syscall
Update the supporting knowledge-base documents in docs/ and docs/zh_cn/ so they stay aligned with adapter/syscall/README.md and the freshly updated L1/L2 architecture docs. - docs/KNOWLEDGE_GRAPH_WIKI.md and the zh_cn counterpart: Expand Section 5.2 'Adapter Layer' from a four-row mini-table into a more complete file inventory of adapter/syscall/ that covers ff_hook_syscall.c/.h, ff_linux_syscall.c, ff_declare_syscalls.h, ff_socket_ops.c/.h, ff_sysproto.h, ff_so_zone.c, ff_event.c, ff_epoll.c, ff_ring_ops.c/.h and Makefile, and add a short paragraph describing the two-process LD_PRELOAD model and the FF_KERNEL_EVENT / FF_MULTI_SC / FF_USE_RING_IPC switches. - docs/F-Stack_Knowledge_Base_Summary.md and the zh_cn counterpart: Augment the 'LD_PRELOAD integration method' bullet and the 'Application Integration' learning-path entry with concrete keywords (libff_syscall.so, fork, accept4, __recv_chk, epoll polling mode, FF_USE_RING_IPC ring IPC) and a reference to adapter/syscall/README.md. - docs/README.md and the zh_cn counterpart: Tighten the source-tree comment for adapter/ to mention both micro_thread and syscall, and to call out that the syscall subdirectory builds libff_syscall.so for LD_PRELOAD. No structural / TOC changes; only inline updates pointing at adapter/syscall/README.md as the single source of truth. Line endings normalized to LF.
1 parent 00ba29b commit 0a9112b

6 files changed

Lines changed: 42 additions & 14 deletions

File tree

docs/F-Stack_Knowledge_Base_Summary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ Application Development Guidelines
212212
213213
Tools and Integration
214214
→ 11 IPC operations tools
215-
→ LD_PRELOAD integration method
215+
→ LD_PRELOAD integration method (libff_syscall.so: fork / accept4 / __recv_chk / epoll polling / FF_USE_RING_IPC ring IPC)
216216
→ Application integration interfaces
217217
```
218218

@@ -592,7 +592,7 @@ Issue 4: Multi-process synchronization issues
592592
→ Study causes of network packet loss
593593
594594
4. Application Integration
595-
→ Learn LD_PRELOAD mechanism
595+
→ Learn the LD_PRELOAD mechanism (libff_syscall.so in adapter/syscall/, see adapter/syscall/README.md)
596596
→ Study Nginx/Redis integration methods
597597
→ Develop custom integration solutions
598598
```

docs/KNOWLEDGE_GRAPH_WIKI.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,27 @@ f-stack/
240240

241241
### 5.2 Adapter Layer (`adapter/`)
242242

243+
The `adapter/syscall/` directory builds two binaries — `libff_syscall.so` (preloaded
244+
into the user application) and a standalone `fstack` instance — that together
245+
implement the LD_PRELOAD path. Key files:
246+
243247
| File | Responsibility |
244248
|------|---------------|
245-
| `syscall/ff_hook_syscall.c` | LD_PRELOAD system call interception (3254 lines) |
246-
| `syscall/ff_socket_ops.h` / `.c` | Socket operation context and handling |
247-
| `syscall/ff_so_zone.c` | Shared memory zone management |
248-
| `syscall/ff_epoll.c` | Epoll adaptation |
249+
| `syscall/ff_hook_syscall.c` / `.h` | LD_PRELOAD POSIX hooks: `socket/bind/connect/accept/accept4/listen/close/read/write/send*/recv*/__read_chk/__recv_chk/__recvfrom_chk/ioctl/epoll_*/fork` etc., dispatched to ff_* via shared memory |
250+
| `syscall/ff_linux_syscall.c` / `ff_declare_syscalls.h` | Linux-flag to FreeBSD-flag translation (e.g. `LINUX_SOCK_CLOEXEC`, `LINUX_SOCK_NONBLOCK`) and hook declarations |
251+
| `syscall/ff_socket_ops.h` / `.c` | Per-socket operation context (`sc`) and the producer/consumer dispatch logic between the application and the fstack instance |
252+
| `syscall/ff_sysproto.h` | Cross-boundary syscall argument struct definitions |
253+
| `syscall/ff_so_zone.c` | Hugepage shared-memory zone management (semaphore IPC path) |
254+
| `syscall/ff_event.c` / `ff_epoll.c` | Epoll adaptation (incl. polling mode) and event delivery |
255+
| `syscall/ff_ring_ops.c` / `.h` *(FF_USE_RING_IPC)* | Lock-free DPDK SPSC `rte_ring` IPC path; replaces the `ff_so_zone` global lock |
256+
| `syscall/Makefile` | Builds both `libff_syscall.so` and the `fstack` instance binary |
257+
258+
LD_PRELOAD-mode applications run as **two separate processes**: the `fstack`
259+
instance (links libfstack.a + DPDK) plus the user app preloaded with
260+
`libff_syscall.so`. The two communicate over Hugepage shared memory — sem-based by
261+
default, or a lock-free DPDK SPSC ring when `FF_USE_RING_IPC=1` is set. Compile /
262+
runtime switches `FF_KERNEL_EVENT`, `FF_MULTI_SC` and `FF_USE_RING_IPC` further tune
263+
behavior; full details in `adapter/syscall/README.md` and `docs/ld_preload_ring_spec/`.
249264

250265
---
251266

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Total lines: ~5839 lines (based on actual file count)
288288
├── lib/ # Core library (~21K lines)
289289
├── freebsd/ # FreeBSD protocol stack port
290290
├── dpdk/ # DPDK 23.11.5 dependency
291-
├── adapter/ # Middleware adapters, LD_PRELOAD and micro_thread
291+
├── adapter/ # Middleware adapters: micro_thread + syscall (builds libff_syscall.so for LD_PRELOAD)
292292
├── example/ # Application examples (main.c recommended)
293293
├── app/ # Nginx/Redis integration
294294
├── tools/ # Operations tools

docs/zh_cn/F-Stack_Knowledge_Base_Summary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ F-Stack 架构知识库
212212
213213
工具与集成
214214
→ 11 个 IPC 运维工具
215-
→ LD_PRELOAD 集成方式
215+
→ LD_PRELOAD 集成方式(libff_syscall.so:fork / accept4 / __recv_chk / epoll polling / FF_USE_RING_IPC ring IPC)
216216
→ 应用集成接口
217217
```
218218

@@ -592,7 +592,7 @@ net.inet.tcp.functions_default=bbr # BBR 算法 (高延迟网络), freebsd/ra
592592
→ 研究网络丢包原因
593593
594594
4. 应用集成
595-
→ 学习 LD_PRELOAD 机制
595+
→ 学习 LD_PRELOAD 机制(adapter/syscall/ 下的 libff_syscall.so,参见 adapter/syscall/README.md)
596596
→ 研究 Nginx/Redis 集成方式
597597
→ 开发自定义集成方案
598598
```

docs/zh_cn/KNOWLEDGE_GRAPH_WIKI.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,25 @@ f-stack/
240240

241241
### 5.2 适配器层 (`adapter/`)
242242

243+
`adapter/syscall/` 同时构建出 `libff_syscall.so`(被预加载到用户应用进程)与独立的
244+
`fstack` 实例二进制,二者共同实现 LD_PRELOAD 模式。主要文件如下:
245+
243246
| 文件 | 职责 |
244247
|------|------|
245-
| `syscall/ff_hook_syscall.c` | LD_PRELOAD 系统调用劫持(3254 行) |
246-
| `syscall/ff_socket_ops.h` / `.c` | Socket 操作上下文和处理 |
247-
| `syscall/ff_so_zone.c` | 共享内存区域管理 |
248-
| `syscall/ff_epoll.c` | Epoll 适配 |
248+
| `syscall/ff_hook_syscall.c` / `.h` | LD_PRELOAD POSIX hook:`socket/bind/connect/accept/accept4/listen/close/read/write/send*/recv*/__read_chk/__recv_chk/__recvfrom_chk/ioctl/epoll_*/fork` 等,经共享内存转发给 ff_* |
249+
| `syscall/ff_linux_syscall.c` / `ff_declare_syscalls.h` | Linux 标志位到 FreeBSD 标志位的转换(如 `LINUX_SOCK_CLOEXEC``LINUX_SOCK_NONBLOCK`)与 hook 声明 |
250+
| `syscall/ff_socket_ops.h` / `.c` | 单 socket 操作上下文(`sc`)以及应用与 fstack 实例之间的生产/消费派发逻辑 |
251+
| `syscall/ff_sysproto.h` | 跨进程的 syscall 参数结构定义 |
252+
| `syscall/ff_so_zone.c` | Hugepage 共享内存 zone 管理(信号量 IPC 路径) |
253+
| `syscall/ff_event.c` / `ff_epoll.c` | Epoll 适配(含 polling 模式)与事件投递 |
254+
| `syscall/ff_ring_ops.c` / `.h` *(FF_USE_RING_IPC)* | Lock-free DPDK SPSC `rte_ring` IPC 路径,移除 `ff_so_zone` 全局锁 |
255+
| `syscall/Makefile` | 同时编译 `libff_syscall.so``fstack` 实例二进制 |
256+
257+
LD_PRELOAD 模式下应用以 **两个独立进程** 运行:`fstack` 实例(链接 libfstack.a + DPDK)
258+
与预加载 `libff_syscall.so` 的用户应用。二者通过 Hugepage 共享内存通信——默认走信号量
259+
路径,置 `FF_USE_RING_IPC=1` 后切换为 lock-free DPDK SPSC ring 路径。编译/运行期开关
260+
`FF_KERNEL_EVENT``FF_MULTI_SC``FF_USE_RING_IPC` 用于进一步调整行为;完整说明参见
261+
`adapter/syscall/README.md``docs/ld_preload_ring_spec/`
249262

250263
---
251264

docs/zh_cn/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ DPDK 版本: 23.11.5
288288
├── lib/ # 核心库 (~21K 行)
289289
├── freebsd/ # FreeBSD 协议栈移植
290290
├── dpdk/ # DPDK 23.11.5 依赖
291-
├── adapter/ # 中间适配器,LD_PRELOAD和micro_thread
291+
├── adapter/ # 中间适配器:micro_thread + syscall(构建 libff_syscall.so 供 LD_PRELOAD 使用)
292292
├── example/ # 应用示例 (main.c 推荐)
293293
├── app/ # Nginx/Redis 集成
294294
├── tools/ # 运维工具

0 commit comments

Comments
 (0)