diff --git a/configure.in b/configure.in index 8ed09f5..44eff38 100644 --- a/configure.in +++ b/configure.in @@ -19,10 +19,10 @@ m4_pattern_forbid(^PGAC_)dnl to catch undefined macros AC_INIT([PostgreSQL], [9.3devel], [pgsql-bugs@postgresql.org]) -m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.63], [], [m4_fatal([Autoconf version 2.63 is required. -Untested combinations of 'autoconf' and PostgreSQL versions are not -recommended. You can remove the check from 'configure.in' but it is then -your responsibility whether the result works or not.])]) +#m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.63], [], [m4_fatal([Autoconf version 2.63 is required. +#Untested combinations of 'autoconf' and PostgreSQL versions are not +#recommended. You can remove the check from 'configure.in' but it is then +#your responsibility whether the result works or not.])]) AC_COPYRIGHT([Copyright (c) 1996-2012, PostgreSQL Global Development Group]) AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c]) AC_CONFIG_AUX_DIR(config) @@ -604,6 +604,17 @@ PGAC_ARG_BOOL(with, gssapi, no, [build with GSSAPI support], AC_MSG_RESULT([$with_gssapi]) # +# NUMA +# +AC_MSG_CHECKING([whether to build with NUMA support]) +PGAC_ARG_BOOL(with, numa, no, [build with NUMA support], +[ + AC_DEFINE(ENABLE_NUMA, 1, [Define to build with NUMA support. (--with-numa)]) +]) +AC_MSG_RESULT([$with_numa]) +AC_SUBST(with_numa) + +# # Kerberos 5 # AC_MSG_CHECKING([whether to build with Kerberos 5 support]) @@ -922,6 +933,15 @@ if test "$with_gssapi" = yes ; then fi fi +if test "$with_numa" = yes ; then + if test "$PORTNAME" != "win32"; then + AC_SEARCH_LIBS(set_mempolicy, [numa], [], + [AC_MSG_ERROR([could not find function 'set_mempolicy' required for NUMA])]) + else + LIBS="$LIBS -lnuma" + fi +fi + if test "$with_krb5" = yes ; then if test "$PORTNAME" != "win32"; then AC_SEARCH_LIBS(com_err, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken' com_err 'com_err -lssl -lcrypto'], [], diff --git a/src/backend/postmaster/fork_process.c b/src/backend/postmaster/fork_process.c index 2a415e8..da5ab0c 100644 --- a/src/backend/postmaster/fork_process.c +++ b/src/backend/postmaster/fork_process.c @@ -18,6 +18,10 @@ #include #include +#ifdef ENABLE_NUMA +#include +#endif + #ifndef WIN32 /* * Wrapper for fork(). Return values are the same as those for fork(): @@ -124,6 +128,10 @@ fork_process(void) } } #endif /* LINUX_OOM_ADJ */ + +#ifdef ENABLE_NUMA + set_mempolicy(MPOL_DEFAULT, NULL, 0); +#endif } return result; diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index bbf725d..f2a2e1e 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -91,6 +91,10 @@ #include #endif +#ifdef ENABLE_NUMA +#include +#endif + #include "access/transam.h" #include "access/xlog.h" #include "bootstrap/bootstrap.h" @@ -492,6 +496,19 @@ int postmaster_alive_fds[2] = {-1, -1}; HANDLE PostmasterHandle; #endif +#ifdef ENABLE_NUMA +static void +NumaInterleave(void) +{ + int mode; + unsigned long nodemask[64]; + + if (0 == get_mempolicy(&mode, nodemask, sizeof(nodemask)*8, 0, 0)) { + set_mempolicy(MPOL_INTERLEAVE, nodemask, sizeof(nodemask)*8); + } +} +#endif + /* * Postmaster main entry point */ @@ -515,6 +532,13 @@ PostmasterMain(int argc, char *argv[]) */ umask(S_IRWXG | S_IRWXO); +#ifdef ENABLE_NUMA + /* + * interleave shared memory + */ + NumaInterleave(); +#endif + /* * Fire up essential subsystems: memory management */