]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: fd: remove leftovers of the fdcache
authorWilly Tarreau <w@1wt.eu>
Fri, 30 Aug 2019 12:33:11 +0000 (14:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 30 Aug 2019 13:07:25 +0000 (15:07 +0200)
The "cache" entry was still present in the fdtab struct and it was
reported in "show sess". Removing it broke the cache-line alignment
on 64-bit machines which is important for threads, so it was fixed
by adding an attribute(aligned()) when threads are in use. Doing it
only in this case allows 32-bit thread-less platforms to see the
struct fit into 32 bytes.

include/types/fd.h
src/fd.c
src/stream.c

index 53364612b611cacaad8a725c10a70dc3d499ad1e..35d3bc2376c7c4ccab95428f8a0ac1b29679d70c 100644 (file)
@@ -120,7 +120,6 @@ struct fdtab {
        __decl_hathreads(HA_SPINLOCK_T lock);
        unsigned long thread_mask;           /* mask of thread IDs authorized to process the task */
        unsigned long update_mask;           /* mask of thread IDs having an update for fd */
-       struct fdlist_entry cache;           /* Entry in the fdcache */
        struct fdlist_entry update;          /* Entry in the global update list */
        void (*iocb)(int fd);                /* I/O handler */
        void *owner;                         /* the connection or listener associated with this fd, NULL if closed */
@@ -128,7 +127,14 @@ struct fdtab {
        unsigned char ev;                    /* event seen in return of poll() : FD_POLL_* */
        unsigned char linger_risk:1;         /* 1 if we must kill lingering before closing */
        unsigned char cloned:1;              /* 1 if a cloned socket, requires EPOLL_CTL_DEL on close */
-};
+}
+#ifdef USE_THREAD
+/* only align on cache lines when using threads; 32-bit small archs
+ * can put everything in 32-bytes when threads are disabled.
+ */
+__attribute__((aligned(64)))
+#endif
+;
 
 /* less often used information */
 struct fdinfo {
index 620de59799459a81e4c5c458b481eb59b9d683fb..17cf52b2d46ba98e69a44f2280b24a82fa49d623 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -596,7 +596,6 @@ int init_pollers()
        for (p = 0; p < global.maxsock; p++) {
                HA_SPIN_INIT(&fdtab[p].lock);
                /* Mark the fd as out of the fd cache */
-               fdtab[p].cache.next = -3;
                fdtab[p].update.next = -3;
        }
 
index 095565a81d5d098d5f162ca8b129761eeb9298a0..75cacc1dcdf76b2f8d155474064f69d431e9ae84 100644 (file)
@@ -3214,11 +3214,10 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
                                      obj_base_ptr(conn->target));
 
                        chunk_appendf(&trash,
-                                     "      flags=0x%08x fd=%d fd.state=%02x fd.cache=%d updt=%d fd.tmask=0x%lx\n",
+                                     "      flags=0x%08x fd=%d fd.state=%02x updt=%d fd.tmask=0x%lx\n",
                                      conn->flags,
                                      conn->handle.fd,
                                      conn->handle.fd >= 0 ? fdtab[conn->handle.fd].state : 0,
-                                     conn->handle.fd >= 0 ? fdtab[conn->handle.fd].cache.next >= -2 : 0,
                                      conn->handle.fd >= 0 ? !!(fdtab[conn->handle.fd].update_mask & tid_bit) : 0,
                                      conn->handle.fd >= 0 ? fdtab[conn->handle.fd].thread_mask: 0);
 
@@ -3251,11 +3250,10 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
                                      obj_base_ptr(conn->target));
 
                        chunk_appendf(&trash,
-                                     "      flags=0x%08x fd=%d fd.state=%02x fd.cache=%d updt=%d fd.tmask=0x%lx\n",
+                                     "      flags=0x%08x fd=%d fd.state=%02x updt=%d fd.tmask=0x%lx\n",
                                      conn->flags,
                                      conn->handle.fd,
                                      conn->handle.fd >= 0 ? fdtab[conn->handle.fd].state : 0,
-                                     conn->handle.fd >= 0 ? fdtab[conn->handle.fd].cache.next >= -2 : 0,
                                      conn->handle.fd >= 0 ? !!(fdtab[conn->handle.fd].update_mask & tid_bit) : 0,
                                      conn->handle.fd >= 0 ? fdtab[conn->handle.fd].thread_mask: 0);