From c208a54ab2aede84402d38758f855789b1a836d1 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 17 Jun 2020 19:58:37 +0200 Subject: [PATCH] DOC: fd: make it clear that some fields ordering must absolutely be respected fd_set_running() and fd_takeover() may both use a double-word CAS on the (running_mask, thread_mask) couple and as such they expect the fields to be exactly arranged like this. It's critical not to reorder them, so add a comment to avoid such a potential mistake later. --- include/haproxy/fd-t.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/haproxy/fd-t.h b/include/haproxy/fd-t.h index 1bffb26c4..5e17b6fe0 100644 --- a/include/haproxy/fd-t.h +++ b/include/haproxy/fd-t.h @@ -116,6 +116,10 @@ struct fdlist { /* info about one given fd. Note: only align on cache lines when using threads; * 32-bit small archs can put everything in 32-bytes when threads are disabled. + * + * NOTE: DO NOT REORDER THIS STRUCT AT ALL! Some code parts rely on exact field + * ordering, for example fd_takeover() and fd_set_running() want running_mask + * immediately followed by thread_mask to perform a double-word-CAS on them. */ struct fdtab { unsigned long running_mask; /* mask of thread IDs currently using the fd */