aboutsummaryrefslogtreecommitdiff
path: root/src/include/port/pg_numa.h
blob: 7e990d9f776ec7e420c8561d641399fc8a31a178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*-------------------------------------------------------------------------
 *
 * pg_numa.h
 *	  Basic NUMA portability routines
 *
 *
 * Copyright (c) 2025, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
 * 	src/include/port/pg_numa.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef PG_NUMA_H
#define PG_NUMA_H

#include "fmgr.h"

extern PGDLLIMPORT int pg_numa_init(void);
extern PGDLLIMPORT int pg_numa_query_pages(int pid, unsigned long count, void **pages, int *status);
extern PGDLLIMPORT int pg_numa_get_max_node(void);
extern PGDLLIMPORT Size pg_numa_get_pagesize(void);

#ifdef USE_LIBNUMA

/*
 * This is required on Linux, before pg_numa_query_pages() as we
 * need to page-fault before move_pages(2) syscall returns valid results.
 */
#define pg_numa_touch_mem_if_required(ro_volatile_var, ptr) \
	ro_volatile_var = *(volatile uint64 *) ptr

#else

#define pg_numa_touch_mem_if_required(ro_volatile_var, ptr) \
	do {} while(0)

#endif

#endif							/* PG_NUMA_H */