libfoedus-core
FOEDUS Core Library
memory_id.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
18 #ifndef FOEDUS_MEMORY_MEMORY_ID_HPP_
19 #define FOEDUS_MEMORY_MEMORY_ID_HPP_
20 
21 #include <numa.h>
22 #include <stdint.h>
23 
25 
31 namespace foedus {
32 namespace memory {
33 
44 typedef uint32_t PagePoolOffset;
45 
50 const uint64_t kHugepageSize = 1 << 21;
51 
59  ScopedNumaPreferred(int numa_node, bool retain_old = false) {
60  // if the machine is not a NUMA machine (1-socket), then avoid calling libnuma functions.
62  if (!numa_enabled_) {
63  numa_node = 0;
64  return;
65  }
66  if (retain_old) {
68  } else {
69  old_value_ = -1;
70  }
71  // in order to run even on a non-numa machine or a machine with fewer sockets,
72  // we allow specifying arbitrary numa_node. we just take rem.
73  numa_node = assorted::mod_numa_node(numa_node);
74  ::numa_set_preferred(numa_node);
75  }
77  if (numa_enabled_) {
79  }
80  }
83 };
84 
85 } // namespace memory
86 } // namespace foedus
87 #endif // FOEDUS_MEMORY_MEMORY_ID_HPP_
ScopedNumaPreferred(int numa_node, bool retain_old=false)
Definition: memory_id.hpp:59
Automatically sets and resets numa_set_preferred().
Definition: memory_id.hpp:58
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
uint32_t PagePoolOffset
Offset in PagePool that compactly represents the page address (unlike 8 bytes pointer).
Definition: memory_id.hpp:44
const uint64_t kHugepageSize
So far 2MB is the only page size available via Transparent Huge Page (THP).
Definition: memory_id.hpp:50
int numa_available(void)
int numa_preferred(void)
int mod_numa_node(int numa_node)
In order to run even on a non-numa machine or a machine with fewer sockets, we allow specifying arbit...
void numa_set_preferred(int node)