mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-06 12:20:07 +00:00
MINOR: threads: add a MAX_THREADS define instead of LONGBITS
This one allows not to inflate some structures when threads are disabled. Now struct global is 1.4 kB instead of 33 kB. Should be backported to 1.8 for ease of backporting of upcoming patches.
This commit is contained in:
parent
f4571a027f
commit
421f02e738
@ -30,6 +30,8 @@ extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the threa
|
||||
|
||||
#ifndef USE_THREAD
|
||||
|
||||
#define MAX_THREADS 1
|
||||
|
||||
#define __decl_hathreads(decl)
|
||||
|
||||
#define HA_ATOMIC_CAS(val, old, new) ({((*val) == (*old)) ? (*(val) = (new) , 1) : (*(old) = *(val), 0);})
|
||||
@ -95,6 +97,8 @@ extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the threa
|
||||
#include <pthread.h>
|
||||
#include <import/plock.h>
|
||||
|
||||
#define MAX_THREADS LONGBITS
|
||||
|
||||
#define __decl_hathreads(decl) decl
|
||||
|
||||
/* TODO: thread: For now, we rely on GCC builtins but it could be a good idea to
|
||||
|
@ -168,7 +168,7 @@ struct global {
|
||||
#ifdef USE_CPU_AFFINITY
|
||||
struct {
|
||||
unsigned long proc[LONGBITS]; /* list of CPU masks for the 32/64 first processes */
|
||||
unsigned long thread[LONGBITS][LONGBITS]; /* list of CPU masks for the 32/64 first threads per process */
|
||||
unsigned long thread[LONGBITS][MAX_THREADS]; /* list of CPU masks for the 32/64 first threads per process */
|
||||
} cpu_map;
|
||||
#endif
|
||||
};
|
||||
|
@ -1175,12 +1175,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
}
|
||||
global.nbthread = atol(args[1]);
|
||||
if (global.nbthread < 1 || global.nbthread > LONGBITS) {
|
||||
ha_alert("parsing [%s:%d] : '%s' must be between 1 and %d (was %d).\n",
|
||||
file, linenum, args[0], LONGBITS, global.nbthread);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
#ifndef USE_THREAD
|
||||
if (global.nbthread > 1) {
|
||||
ha_alert("HAProxy is not compiled with threads support, please check build options for USE_THREAD.\n");
|
||||
@ -1189,6 +1183,12 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
if (global.nbthread < 1 || global.nbthread > MAX_THREADS) {
|
||||
ha_alert("parsing [%s:%d] : '%s' must be between 1 and %d (was %d).\n",
|
||||
file, linenum, args[0], MAX_THREADS, global.nbthread);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(args[0], "maxconn")) {
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
@ -1801,7 +1801,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
}
|
||||
|
||||
/* Mapping at the thread level */
|
||||
for (j = 0; j < LONGBITS; j++) {
|
||||
for (j = 0; j < MAX_THREADS; j++) {
|
||||
/* Np mapping for this thread */
|
||||
if (!(thread & (1UL << j)))
|
||||
continue;
|
||||
|
@ -2986,7 +2986,7 @@ int main(int argc, char **argv)
|
||||
if (global.cpu_map.proc[relative_pid-1])
|
||||
global.cpu_map.thread[relative_pid-1][i] &= global.cpu_map.proc[relative_pid-1];
|
||||
|
||||
if (i < LONGBITS && /* only the first 32/64 threads may be pinned */
|
||||
if (i < MAX_THREADS && /* only the first 32/64 threads may be pinned */
|
||||
global.cpu_map.thread[relative_pid-1][i]) {/* only do this if the thread has a THREAD map */
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
cpuset_t cpuset;
|
||||
|
@ -963,7 +963,7 @@ static int bind_parse_process(char **args, int cur_arg, struct proxy *px, struct
|
||||
|
||||
conf->bind_proc |= proc;
|
||||
if (thread) {
|
||||
for (i = 0; i < LONGBITS; i++)
|
||||
for (i = 0; i < MAX_THREADS; i++)
|
||||
if (!proc || (proc & (1UL << i)))
|
||||
conf->bind_thread[i] |= thread;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user