PostgreSQL Source Code
git master
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
c
d
g
h
i
k
l
m
p
r
s
t
Functions
Variables
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
c
d
f
h
i
n
o
p
r
s
t
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
pg_numa.c
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* pg_numa.c
4
* Basic NUMA portability routines
5
*
6
*
7
* Copyright (c) 2025, PostgreSQL Global Development Group
8
*
9
*
10
* IDENTIFICATION
11
* src/port/pg_numa.c
12
*
13
*-------------------------------------------------------------------------
14
*/
15
16
#include "
c.h
"
17
#include <
unistd.h
>
18
19
#include "
port/pg_numa.h
"
20
21
/*
22
* At this point we provide support only for Linux thanks to libnuma, but in
23
* future support for other platforms e.g. Win32 or FreeBSD might be possible
24
* too. For Win32 NUMA APIs see
25
* https://learn.microsoft.com/en-us/windows/win32/procthread/numa-support
26
*/
27
#ifdef USE_LIBNUMA
28
29
#include <numa.h>
30
#include <numaif.h>
31
32
/* libnuma requires initialization as per numa(3) on Linux */
33
int
34
pg_numa_init
(
void
)
35
{
36
int
r = numa_available();
37
38
return
r;
39
}
40
41
/*
42
* We use move_pages(2) syscall here - instead of get_mempolicy(2) - as the
43
* first one allows us to batch and query about many memory pages in one single
44
* giant system call that is way faster.
45
*/
46
int
47
pg_numa_query_pages
(
int
pid,
unsigned
long
count,
void
**pages,
int
*status)
48
{
49
return
numa_move_pages(pid, count, pages, NULL, status, 0);
50
}
51
52
int
53
pg_numa_get_max_node
(
void
)
54
{
55
return
numa_max_node();
56
}
57
58
#else
59
60
/* Empty wrappers */
61
int
62
pg_numa_init
(
void
)
63
{
64
/* We state that NUMA is not available */
65
return
-1;
66
}
67
68
int
69
pg_numa_query_pages
(
int
pid,
unsigned
long
count,
void
**pages,
int
*status)
70
{
71
return
0;
72
}
73
74
int
75
pg_numa_get_max_node
(
void
)
76
{
77
return
0;
78
}
79
80
#endif
c.h
pg_numa_query_pages
int pg_numa_query_pages(int pid, unsigned long count, void **pages, int *status)
Definition:
pg_numa.c:69
pg_numa_init
int pg_numa_init(void)
Definition:
pg_numa.c:62
pg_numa_get_max_node
int pg_numa_get_max_node(void)
Definition:
pg_numa.c:75
pg_numa.h
unistd.h
src
port
pg_numa.c
Generated on Tue Apr 22 2025 00:13:28 for PostgreSQL Source Code by
1.9.4