CreateAnonymousSegment.diff
text/x-patch
Filename: CreateAnonymousSegment.diff
Type: text/x-patch
Part: 0
Message:
Re: Adding basic NUMA awareness
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 6019bee334d..e5c4752d9f6 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -30,6 +30,7 @@ #include "miscadmin.h" #include "port/pg_bitutils.h" +#include "port/pg_numa.h" #include "portability/mem.h" #include "storage/dsm.h" #include "storage/fd.h" @@ -609,7 +610,8 @@ CreateAnonymousSegment(Size *size) * * XXX Probably not needed without that, but also costs nothing. */ - numa_set_membind(numa_all_nodes_ptr); + if ((numa_flags & NUMA_BUFFERS) != 0) + numa_set_membind(numa_all_nodes_ptr); #ifndef MAP_HUGETLB /* PGSharedMemoryCreate should have dealt with this case */ @@ -681,7 +683,8 @@ CreateAnonymousSegment(Size *size) } /* undo the earlier num_set_membind() call. */ - numa_set_localalloc(); + if ((numa_flags & NUMA_BUFFERS) != 0) + numa_set_localalloc(); /* * Before touching the memory, set the allocation policy, so that @@ -693,7 +696,8 @@ CreateAnonymousSegment(Size *size) * XXX Probably not needed with MAP_POPULATE, in which case the policy * was already set by num_set_membind() earlier. But doesn't hurt. */ - numa_interleave_memory(ptr, allocsize, numa_all_nodes_ptr); + if ((numa_flags & NUMA_BUFFERS) != 0) + numa_interleave_memory(ptr, allocsize, numa_all_nodes_ptr); *size = allocsize; return ptr;