Commit add33a0
committed
feat(M8): enable FF_ZC_SEND with FSTACK_ZC_MAGIC sentinel protocol (Phase-2 P1b)
Phase-2 third milestone: enable lib/Makefile FF_ZC_SEND=1 in addition
to M6 (NETGRAPH+IPFW) and M7 (PAGE_ARRAY). FF_USE_PAGE_ARRAY remains
off — combined PA+ZC build is M9 separate scope.
Beyond enabling the macro, this change also fixes a pre-existing
13.0-baseline bug in the F-Stack zero-copy fast path: the predicate
in m_uiotombuf (uipc_mbuf.c) used to be just (UIO_SYSSPACE && UIO_WRITE)
which matched every ff_write/ff_writev call (lib/ff_syscall_wrapper.c
sets uio_segflg = UIO_SYSSPACE unconditionally). On heavy load this
would either silently corrupt response payload (the kernel handed
a bare char buffer to tcp_output as if it were a mbuf chain) or
trigger a GPF in m_demote when m->m_next happened to deref into
unmapped memory. Both helloworld_zc AND the plain helloworld
crashed under 100x curl on the M7 build.
Code changes (8 source files, +85/-4):
- freebsd/sys/mbuf.h: define FSTACK_ZC_MAGIC sentinel
(0xF8AC2C00F8AC2C00) under #ifdef FSTACK_ZC_SEND.
- freebsd/kern/uipc_mbuf.c: tighten m_uiotombuf ZC fast-path
predicate to require uio_offset == FSTACK_ZC_MAGIC. Plain ff_write
callers now bypass the fast path and run the regular m_getm2 +
uiomove copy loop.
- freebsd/kern/sys_generic.c: dofilewrite preserves auio->uio_offset
if it already carries FSTACK_ZC_MAGIC. Without this, the sentinel
set by ff_zc_send would be overwritten with -1 before reaching
m_uiotombuf. include sys/mbuf.h for the macro.
- lib/Makefile: uncomment FF_ZC_SEND=1.
- lib/ff_syscall_wrapper.c: new public API ff_zc_send(fd, mbuf, len)
which sets auio.uio_offset = FSTACK_ZC_MAGIC. Plain ff_write/
ff_writev now explicitly set uio_offset = 0 so they never
accidentally trigger the fast path. include sys/mbuf.h.
- lib/ff_api.h: declare ff_zc_send + comment block on the
uio_offset sentinel contract.
- lib/ff_api.symlist: export ff_zc_send (libfstack.a is built with
--localize-symbols + --globalize-symbols=ff_api.symlist; without
this entry the new function would remain a local symbol and
fail link against helloworld_zc).
- example/Makefile: add -DFSTACK_ZC_SEND when compiling
helloworld_zc so main_zc.c picks the ZC branch.
- example/main_zc.c: line 215 ff_write -> ff_zc_send (with extern
declaration at top); the comment names the previous bug.
Verification (production build, debug printfs removed):
- G1 lib make clean && make: exit=0, 0 errors, 57 warnings (=
M6/M7 baseline). libfstack.a 6.55 MB.
- G1 example make: 3 binaries (helloworld 29.02M, _epoll 29.02M,
_zc 29.03M). nm libfstack.a shows 'T ff_zc_send' (global).
- G2 helloworld_zc primary: ALIVE 12s+ smoke, ipfw2 + tcp_bbr
+ dpdk if registered cleanly, 0 SIGSEGV.
- G3.2 single curl from f-stack-client: HTTP/1.1 200 OK +
Content-Length: 438 + body = real HTML
(<!DOCTYPE html><html><head><title>Welcome to F-Stack!</title>...).
- G3.3 100x short conn ZC build: ok=100/100.
- G3.3 100x short conn baseline (helloworld): ok=100/100 — the M8
fix simultaneously cured the regression that the over-broad
fast-path predicate caused in non-ZC builds (M7's 100x test had
GPF'd).
- G4 1000 short conn observation (OQ-2 default downgrade): ZC
6.768s vs baseline 6.884s — parity (bottleneck is ssh round-trip).
Full perf baseline deferred to M9.
- G6 lint: 0 errors.
Bounce ledger: 1 formal bounce, gate(G2/G3)->code, resolved within
the same milestone (3 RCA iterations folded into a single bounce
because each was a refinement of the original 'ZC fast-path
mis-fires' diagnosis, not a new symptom). No escalation.
Documentation:
- docs/freebsd_13_to_15_upgrade_spec/zh_cn/phase2-M8-spec.md
(NEW, includes RCA section §7).
- docs/freebsd_13_to_15_upgrade_spec/zh_cn/phase2-M8-execution-log.md
(NEW, full evidence + design contract diagram + bounce ledger
+ follow-ups F1-F3).
- docs/01-LAYER1-ARCHITECTURE.md + zh_cn mirror: M8 anchor sentence.
- docs/F-Stack_Knowledge_Base_Summary.md + zh_cn: scope tag amended.
Compliance: 0 direct rm/kill/chmod calls used. All process
terminations, file deletions, and DPDK runtime cleanup routed
through /data/workspace/{rm_tmp_file,kill_process,chmod_modify}.sh.
Process liveness checked via [ -d /proc/$PID ] (not kill -0).
Local commit only; not pushed.1 parent cba3d88 commit add33a0
15 files changed
Lines changed: 537 additions & 7 deletions
File tree
- docs
- freebsd_13_to_15_upgrade_spec/zh_cn
- zh_cn
- example
- freebsd
- kern
- sys
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 190 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
0 commit comments