Mercurial > hg > nginx
comparison src/os/unix/ngx_posix_init.c @ 7173:057adb2a9d23
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.
author | Debayan Ghosh <debayang.qdt@qualcommdatacenter.com> |
---|---|
date | Mon, 11 Dec 2017 16:28:11 +0000 |
parents | 56fc55e32f23 |
children |
comparison
equal
deleted
inserted
replaced
7172:e4c21e417277 | 7173:057adb2a9d23 |
---|---|
34 ngx_int_t | 34 ngx_int_t |
35 ngx_os_init(ngx_log_t *log) | 35 ngx_os_init(ngx_log_t *log) |
36 { | 36 { |
37 ngx_time_t *tp; | 37 ngx_time_t *tp; |
38 ngx_uint_t n; | 38 ngx_uint_t n; |
39 #if (NGX_HAVE_LEVEL1_DCACHE_LINESIZE) | |
40 long size; | |
41 #endif | |
39 | 42 |
40 #if (NGX_HAVE_OS_SPECIFIC_INIT) | 43 #if (NGX_HAVE_OS_SPECIFIC_INIT) |
41 if (ngx_os_specific_init(log) != NGX_OK) { | 44 if (ngx_os_specific_init(log) != NGX_OK) { |
42 return NGX_ERROR; | 45 return NGX_ERROR; |
43 } | 46 } |
59 #endif | 62 #endif |
60 | 63 |
61 if (ngx_ncpu < 1) { | 64 if (ngx_ncpu < 1) { |
62 ngx_ncpu = 1; | 65 ngx_ncpu = 1; |
63 } | 66 } |
67 | |
68 #if (NGX_HAVE_LEVEL1_DCACHE_LINESIZE) | |
69 size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); | |
70 if (size > 0) { | |
71 ngx_cacheline_size = size; | |
72 } | |
73 #endif | |
64 | 74 |
65 ngx_cpuinfo(); | 75 ngx_cpuinfo(); |
66 | 76 |
67 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { | 77 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { |
68 ngx_log_error(NGX_LOG_ALERT, log, errno, | 78 ngx_log_error(NGX_LOG_ALERT, log, errno, |