Add hard thread limit

The hard thread limit is now defined in maxscale/limits.h.
If the specified number of threads is larger than that, it will
be adjusted down. The size of the GWBITMASK is now also defined
using that number, so there will always be enough bits for
representing all threads.
This commit is contained in:
Johan Wikman 2016-08-18 12:55:45 +03:00
parent 6028bf8f6c
commit acb19c083d
3 changed files with 38 additions and 3 deletions

View File

@ -75,6 +75,7 @@
#include <dbusers.h>
#include <gw.h>
#include <maxscale/alloc.h>
#include <maxscale/limits.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
@ -895,8 +896,8 @@ handle_global_item(const char *name, const char *value)
int processor_count = get_processor_count();
if (thrcount > processor_count)
{
MXS_WARNING("Number of threads set to %d which is greater than"
" the number of processors available: %d",
MXS_WARNING("Number of threads set to %d, which is greater than "
"the number of processors available: %d",
thrcount, processor_count);
}
}
@ -906,6 +907,14 @@ handle_global_item(const char *name, const char *value)
return 0;
}
}
if (gateway.n_threads > MXS_MAX_THREADS)
{
MXS_WARNING("Number of threads set to %d, which is greater than the "
"hard maximum of %d. Number of threads adjusted down "
"accordingly.", gateway.n_threads, MXS_MAX_THREADS);
gateway.n_threads = MXS_MAX_THREADS;
}
}
else if (strcmp(name, "non_blocking_polls") == 0)
{

View File

@ -12,7 +12,9 @@
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <spinlock.h>
#include <maxscale/limits.h>
/**
* @file gwbitmask.h An implementation of an arbitrarily long bitmask
@ -28,7 +30,7 @@
*/
/* This number MUST an be exact multiple of 8 */
#define MXS_BITMASK_LENGTH 256 /**< Number of bits in the bitmask */
#define MXS_BITMASK_LENGTH (MXS_MAX_THREADS + 1) /**< Number of bits in the bitmask */
#define MXS_BITMASK_SIZE (MXS_BITMASK_LENGTH / 8) /**< Number of bytes in the bitmask */

View File

@ -0,0 +1,24 @@
#ifndef _MAXSCALE_LIMITS_H
#define _MAXSCALE_LIMITS_H
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
// This file defines hard limits of MaxScale.
// Thread information is stored in a bitmask whose size must be a
// multiple of 8. The bitmask is indexed using the thread id that start
// from 1. Hence, the hard maximum number of threads must be a
// multiple of 8 minus 1.
#define MXS_MAX_THREADS 255
#endif