From: Willy Tarreau Date: Mon, 20 May 2019 16:56:48 +0000 (+0200) Subject: REORG: threads: move the struct thread_info from global.h to hathreads.h X-Git-Tag: v2.0-dev4~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a6e2245f;p=thirdparty%2Fhaproxy.git REORG: threads: move the struct thread_info from global.h to hathreads.h It doesn't make sense to keep this struct thread_info in global.h, it causes difficulties to access its contents from hathreads.h, let's move it to the threads where it ought to have been created. --- diff --git a/include/common/hathreads.h b/include/common/hathreads.h index 2be5915c08..0dbec671d7 100644 --- a/include/common/hathreads.h +++ b/include/common/hathreads.h @@ -49,6 +49,12 @@ enum { all_threads_mask = 1UL }; enum { tid_bit = 1UL }; enum { tid = 0 }; +extern struct thread_info { + /* pad to cache line (64B) */ + char __pad[0]; /* unused except to check remaining room */ + char __end[0] __attribute__((aligned(64))); +} thread_info[MAX_THREADS]; + #define __decl_hathreads(decl) #define __decl_spinlock(lock) #define __decl_aligned_spinlock(lock) @@ -369,6 +375,14 @@ void thread_harmless_till_end(); void thread_isolate(); void thread_release(); +extern struct thread_info { + pthread_t pthread; + clockid_t clock_id; + /* pad to cache line (64B) */ + char __pad[0]; /* unused except to check remaining room */ + char __end[0] __attribute__((aligned(64))); +} thread_info[MAX_THREADS]; + extern THREAD_LOCAL unsigned int tid; /* The thread id */ extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the thread id */ extern volatile unsigned long all_threads_mask; diff --git a/include/types/global.h b/include/types/global.h index 030a553e28..a52b258b0f 100644 --- a/include/types/global.h +++ b/include/types/global.h @@ -243,11 +243,6 @@ extern unsigned int rlim_fd_cur_at_boot; extern unsigned int rlim_fd_max_at_boot; extern int atexit_flag; -extern struct thread_info { - __decl_hathreads(pthread_t pthread); - __decl_hathreads(clockid_t clock_id); -} thread_info[MAX_THREADS]; - /* bit values to go with "warned" above */ #define WARN_BLOCK_DEPRECATED 0x00000001 /* unassigned : 0x00000002 */ diff --git a/src/hathreads.c b/src/hathreads.c index fc17318672..2dbf467e81 100644 --- a/src/hathreads.c +++ b/src/hathreads.c @@ -29,6 +29,7 @@ #include #include +struct thread_info thread_info[MAX_THREADS]; #ifdef USE_THREAD