|
Packit |
2d622a |
/*
|
|
Packit |
2d622a |
* libhugetlbfs - Easy use of Linux hugepages
|
|
Packit |
2d622a |
* Copyright (C) 2005-2006 David Gibson & Adam Litke, IBM Corporation.
|
|
Packit |
2d622a |
*
|
|
Packit |
2d622a |
* This library is free software; you can redistribute it and/or
|
|
Packit |
2d622a |
* modify it under the terms of the GNU Lesser General Public License
|
|
Packit |
2d622a |
* as published by the Free Software Foundation; either version 2.1 of
|
|
Packit |
2d622a |
* the License, or (at your option) any later version.
|
|
Packit |
2d622a |
*
|
|
Packit |
2d622a |
* This library is distributed in the hope that it will be useful, but
|
|
Packit |
2d622a |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
2d622a |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
2d622a |
* Lesser General Public License for more details.
|
|
Packit |
2d622a |
*
|
|
Packit |
2d622a |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
2d622a |
* License along with this library; if not, write to the Free Software
|
|
Packit |
2d622a |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
2d622a |
*/
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
/*
|
|
Packit |
2d622a |
* This file should only contain definitions of functions, data types, and
|
|
Packit |
2d622a |
* constants which are part of the published libhugetlfs API. Functions
|
|
Packit |
2d622a |
* exported here must also be listed in version.lds.
|
|
Packit |
2d622a |
*/
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
#ifndef _HUGETLBFS_H
|
|
Packit |
2d622a |
#define _HUGETLBFS_H
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
#define HUGETLBFS_MAGIC 0x958458f6
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
long gethugepagesize(void);
|
|
Packit |
2d622a |
int gethugepagesizes(long pagesizes[], int n_elem);
|
|
Packit |
2d622a |
int getpagesizes(long pagesizes[], int n_elem);
|
|
Packit |
2d622a |
int hugetlbfs_test_path(const char *mount);
|
|
Packit |
2d622a |
const char *hugetlbfs_find_path(void);
|
|
Packit |
2d622a |
const char *hugetlbfs_find_path_for_size(long page_size);
|
|
Packit |
2d622a |
int hugetlbfs_unlinked_fd(void);
|
|
Packit |
2d622a |
int hugetlbfs_unlinked_fd_for_size(long page_size);
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
#define PF_LINUX_HUGETLB 0x100000
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
/*
|
|
Packit |
2d622a |
* Direct hugepage allocation flags and types
|
|
Packit |
2d622a |
*
|
|
Packit |
2d622a |
* GHP_DEFAULT - Use the default hugepage size to back the region
|
|
Packit |
2d622a |
*/
|
|
Packit |
2d622a |
typedef unsigned long ghp_t;
|
|
Packit |
2d622a |
#define GHP_DEFAULT ((ghp_t)0x01UL)
|
|
Packit |
2d622a |
#define GHP_MASK (GHP_DEFAULT)
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
/* Direct alloc functions for hugepages */
|
|
Packit |
2d622a |
void *get_huge_pages(size_t len, ghp_t flags);
|
|
Packit |
2d622a |
void free_huge_pages(void *ptr);
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
/*
|
|
Packit |
2d622a |
* Region alloc flags and types
|
|
Packit |
2d622a |
*
|
|
Packit |
2d622a |
* GHR_DEFAULT - Use a combination of flags deemed to be a sensible default
|
|
Packit |
2d622a |
* by the current implementation of the library
|
|
Packit |
2d622a |
* GHR_FALLBACK - Use the default hugepage size if possible but fallback to
|
|
Packit |
2d622a |
* smaller pages if necessary
|
|
Packit |
2d622a |
* GHR_STRICT - Use hugepages of some size or return NULL
|
|
Packit |
2d622a |
* GHP_COLOR - Use bytes wasted due to alignment to offset the buffer
|
|
Packit |
2d622a |
* by a random cache line. This gives better average
|
|
Packit |
2d622a |
* performance with many buffers
|
|
Packit |
2d622a |
*/
|
|
Packit |
2d622a |
typedef unsigned long ghr_t;
|
|
Packit |
2d622a |
#define GHR_STRICT ((ghr_t)0x10000000U)
|
|
Packit |
2d622a |
#define GHR_FALLBACK ((ghr_t)0x20000000U)
|
|
Packit |
2d622a |
#define GHR_COLOR ((ghr_t)0x40000000U)
|
|
Packit |
2d622a |
#define GHR_DEFAULT (GHR_FALLBACK|GHR_COLOR)
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
#define GHR_MASK (GHR_FALLBACK|GHR_STRICT|GHR_COLOR)
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
/* Allocation functions for regions backed by hugepages */
|
|
Packit |
2d622a |
void *get_hugepage_region(size_t len, ghr_t flags);
|
|
Packit |
2d622a |
void free_hugepage_region(void *ptr);
|
|
Packit |
2d622a |
|
|
Packit |
2d622a |
#endif /* _HUGETLBFS_H */
|