Welcome! Log In Create A New Profile

Advanced

[nginx] Use sysconf to determine cacheline size at runtime.

Maxim Dounin
December 13, 2017 12:20PM
details: http://hg.nginx.org/nginx/rev/057adb2a9d23
branches:
changeset: 7173:057adb2a9d23
user: Debayan Ghosh <debayang.qdt@qualcommdatacenter.com>
date: Mon Dec 11 16:28:11 2017 +0000
description:
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:

auto/unix | 10 ++++++++++
src/os/unix/ngx_posix_init.c | 10 ++++++++++
2 files changed, 20 insertions(+), 0 deletions(-)

diffs (47 lines):

diff --git a/auto/unix b/auto/unix
--- a/auto/unix
+++ b/auto/unix
@@ -964,6 +964,16 @@ ngx_feature_test="sysconf(_SC_NPROCESSOR
. auto/feature


+ngx_feature="sysconf(_SC_LEVEL1_DCACHE_LINESIZE)"
+ngx_feature_name="NGX_HAVE_LEVEL1_DCACHE_LINESIZE"
+ngx_feature_run=no
+ngx_feature_incs=
+ngx_feature_path=
+ngx_feature_libs=
+ngx_feature_test="sysconf(_SC_LEVEL1_DCACHE_LINESIZE)"
+. auto/feature
+
+
ngx_feature="openat(), fstatat()"
ngx_feature_name="NGX_HAVE_OPENAT"
ngx_feature_run=no
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
--- 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) {
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Use sysconf to determine cacheline size at runtime.

Maxim Dounin 407 December 13, 2017 12:20PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 185
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready