diff options
author | Debayan Ghosh <debayang.qdt@qualcommdatacenter.com> | 2017-12-11 16:28:11 +0000 |
---|---|---|
committer | Debayan Ghosh <debayang.qdt@qualcommdatacenter.com> | 2017-12-11 16:28:11 +0000 |
commit | d2d737e70b46429ef9ed71b99402a9151f3c2e1f (patch) | |
tree | 753c4214af666f79be351fe365020066143d3387 /src/os/unix/ngx_posix_init.c | |
parent | b75f419b2cb9a7ccb92e63e4cee340ca01099c2c (diff) | |
download | nginx-d2d737e70b46429ef9ed71b99402a9151f3c2e1f.tar.gz nginx-d2d737e70b46429ef9ed71b99402a9151f3c2e1f.zip |
Use sysconf to determine cacheline size at runtime.
Determine cacheline size at runtime if supported
using sysconf(_SC_LEVEL1_DCACHE_LINESIZE). In case not supported,
fallback to compile time defaults.
Diffstat (limited to 'src/os/unix/ngx_posix_init.c')
-rw-r--r-- | src/os/unix/ngx_posix_init.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c index 583ea4ff9..7824735d0 100644 --- a/src/os/unix/ngx_posix_init.c +++ b/src/os/unix/ngx_posix_init.c @@ -36,6 +36,9 @@ ngx_os_init(ngx_log_t *log) { ngx_time_t *tp; ngx_uint_t n; +#if (NGX_HAVE_LEVEL1_DCACHE_LINESIZE) + long size; +#endif #if (NGX_HAVE_OS_SPECIFIC_INIT) if (ngx_os_specific_init(log) != NGX_OK) { @@ -62,6 +65,13 @@ ngx_os_init(ngx_log_t *log) ngx_ncpu = 1; } +#if (NGX_HAVE_LEVEL1_DCACHE_LINESIZE) + size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + if (size > 0) { + ngx_cacheline_size = size; + } +#endif + ngx_cpuinfo(); if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { |