Blame man/memkind_default.3

Packit 345191
.\"
Packit 345191
.\" Copyright (C) 2014 - 2019 Intel Corporation.
Packit 345191
.\" All rights reserved.
Packit 345191
.\"
Packit 345191
.\" Redistribution and use in source and binary forms, with or without
Packit 345191
.\" modification, are permitted provided that the following conditions are met:
Packit 345191
.\" 1. Redistributions of source code must retain the above copyright notice(s),
Packit 345191
.\"    this list of conditions and the following disclaimer.
Packit 345191
.\" 2. Redistributions in binary form must reproduce the above copyright notice(s),
Packit 345191
.\"    this list of conditions and the following disclaimer in the documentation
Packit 345191
.\"    and/or other materials provided with the distribution.
Packit 345191
.\"
Packit 345191
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
Packit 345191
.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
Packit 345191
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
Packit 345191
.\" EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit 345191
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 345191
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Packit 345191
.\" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Packit 345191
.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
Packit 345191
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
Packit 345191
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 345191
.\"
Packit 345191
.TH "MEMKIND_DEFAULT" 3 "2015-04-21" "Intel Corporation" "MEMKIND_DEFAULT" \" -*- nroff -*-
Packit 345191
.SH "NAME"
Packit 345191
memkind_default \- default implementations for memkind operations.
Packit 345191
.br
Packit 345191
.BR Note:
Packit 345191
This is EXPERIMENTAL API. The functionality and the header file itself can be changed (including non-backward compatible changes), or removed.
Packit 345191
.SH "SYNOPSIS"
Packit 345191
.sp
Packit 345191
.BI "int memkind_default_create(struct memkind " "*kind" ", struct memkind_ops " "*ops" ", const char " "*name" );
Packit 345191
.br
Packit 345191
.BI "int memkind_default_destroy(struct memkind " "*kind" );
Packit 345191
.br
Packit 345191
.BI "void *memkind_default_malloc(struct memkind " "*kind" ", size_t " "size" );
Packit 345191
.br
Packit 345191
.BI "void *memkind_default_calloc(struct memkind " "*kind" ", size_t " "num" ", size_t " "size" );
Packit 345191
.br
Packit 345191
.BI "int memkind_default_posix_memalign(struct memkind " "*kind" ", void " "**memptr" ", size_t " "alignment" ", size_t " "size" );
Packit 345191
.br
Packit 345191
.BI "void *memkind_default_realloc(struct memkind " "*kind" ", void " "*ptr" ", size_t " "size" );
Packit 345191
.br
Packit 345191
.BI "void memkind_default_free(struct memkind " "*kind" ", void " "*ptr" );
Packit 345191
.br
Packit 345191
.BI "void *memkind_default_mmap(struct memkind " "*kind" ", void " "*addr" ", size_t " "size" );
Packit 345191
.br
Packit 345191
.BI "int memkind_default_mbind(struct memkind " "*kind" ", void " "*ptr" ", size_t " "len" );
Packit 345191
.br
Packit 345191
.BI "int memkind_default_get_mmap_flags(struct memkind " "*kind" ", int " "*flags" );
Packit 345191
.br
Packit 345191
.BI "int memkind_default_get_mbind_mode(struct memkind " "*kind" ", int " "*mode" );
Packit 345191
.br
Packit 345191
.BI "size_t memkind_default_malloc_usable_size(struct memkind " "*kind" ", void " "*ptr" );
Packit 345191
.br
Packit 345191
.BI "int memkind_preferred_get_mbind_mode(struct memkind " "*kind" ", int " "*mode" );
Packit 345191
.br
Packit 345191
.BI "int memkind_interleave_get_mbind_mode(struct memkind " "*kind" ", int " "*mode" );
Packit 345191
.br
Packit 345191
.BI "int memkind_nohugepage_madvise(struct memkind " "*kind" ", void " "*addr" ", size_t " "size" );
Packit 345191
.br
Packit 345191
.BI "int memkind_posix_check_alignment(struct memkind " "*kind" ", size_t " "alignment" );
Packit 345191
.br
Packit 345191
.BI "int memkind_default_get_mbind_nodemask(struct memkind " "*kind" ", unsigned long " "*nodemask" ", unsigned long " "maxnode" );
Packit 345191
.br
Packit 345191
.BI "void memkind_default_init_once(void);"
Packit 345191
.br
Packit 345191
.BI "bool size_out_of_bounds(size_t " "size" );
Packit 345191
.br
Packit 345191
.SH DESCRIPTION
Packit 345191
.PP
Packit 345191
Default implementations for memkind operations which include a several
Packit 345191
useful methods that are not part of the
Packit 345191
.B MEMKIND_DEFAULT
Packit 345191
kind which is a fall through to the jemalloc implementation.
Packit 345191
.PP
Packit 345191
.BR memkind_default_create ()
Packit 345191
implements the required start up for every kind. If a kind does not
Packit 345191
point to this function directly for its
Packit 345191
.BR ops.create ()
Packit 345191
operation, then the function that it points to must call
Packit 345191
.BR memkind_default_create ()
Packit 345191
at its start.
Packit 345191
.PP
Packit 345191
.BR memkind_default_destroy ()
Packit 345191
implements the required shutdown for every kind. If a kind does not
Packit 345191
point to this function directly for its
Packit 345191
.BR ops.destroy ()
Packit 345191
operation, then the function that it points to must call
Packit 345191
.BR memkind_default_destroy ()
Packit 345191
at its end.
Packit 345191
.PP
Packit 345191
.BR memkind_default_malloc ()
Packit 345191
is a direct call through the jemalloc's
Packit 345191
.BR malloc ().
Packit 345191
.PP
Packit 345191
.BR memkind_default_calloc ()
Packit 345191
is a direct call through the jemalloc's
Packit 345191
.BR calloc ().
Packit 345191
.PP
Packit 345191
.BR memkind_default_posix_memalign ()
Packit 345191
is a direct call through the jemalloc's
Packit 345191
.BR posix_memalign ().
Packit 345191
.PP
Packit 345191
.BR memkind_default_realloc ()
Packit 345191
is a direct call through the jemalloc's
Packit 345191
.BR realloc ().
Packit 345191
.PP
Packit 345191
.BR memkind_default_free ()
Packit 345191
is a direct call through the jemalloc's
Packit 345191
.BR free ().
Packit 345191
Note that this method can be called on any pointer returned by a
Packit 345191
jemalloc allocation, and in particular, all of the arena
Packit 345191
allocations described in
Packit 345191
.BR memkind_arena (3)
Packit 345191
can use this function for freeing.
Packit 345191
.PP
Packit 345191
.BR memkind_default_mmap ()
Packit 345191
This calls the ops->get_mmap_flags()
Packit 345191
operations for the kind, or falls back on the default implementations
Packit 345191
if the function pointers are
Packit 345191
.IR "NULL" .
Packit 345191
The results of these calls are
Packit 345191
passed to the
Packit 345191
.BR mmap (2)
Packit 345191
call to allocate pages from the operating system.  The
Packit 345191
.I addr
Packit 345191
is the hint passed through to
Packit 345191
.BR mmap (2)
Packit 345191
and
Packit 345191
.I size
Packit 345191
is the size of the buffer to be allocated.  The return value is the
Packit 345191
allocated buffer or
Packit 345191
.B MAP_FAILED
Packit 345191
in the case of an error.
Packit 345191
.PP
Packit 345191
.BR memkind_default_mbind ()
Packit 345191
makes calls the kind's
Packit 345191
.BR ops.get_mbind_nodemask ()
Packit 345191
and
Packit 345191
.BR ops.get_mbind_mode ()
Packit 345191
operations to gather inputs and then calls the
Packit 345191
.BR mbind (2)
Packit 345191
system call using the results along with and user input
Packit 345191
.I ptr
Packit 345191
and
Packit 345191
.IR len .
Packit 345191
.PP
Packit 345191
.BR memkind_default_get_mmap_flags ()
Packit 345191
sets
Packit 345191
.I flags
Packit 345191
to
Packit 345191
.BR "MAP_PRIVATE | MAP_ANONYMOUS" .
Packit 345191
See
Packit 345191
.BR mmap (2)
Packit 345191
for more information about these flags.
Packit 345191
.PP
Packit 345191
.BR memkind_default_get_mbind_mode ()
Packit 345191
sets
Packit 345191
.I mode
Packit 345191
to
Packit 345191
.BR MPOL_BIND .
Packit 345191
See
Packit 345191
.BR mbind (2)
Packit 345191
for more information about this flag.
Packit 345191
.PP
Packit 345191
.BR memkind_default_malloc_usable_size ()
Packit 345191
is a direct call through the jemalloc's
Packit 345191
.BR malloc_usable_size ().
Packit 345191
.PP
Packit 345191
.BR memkind_preferred_get_mbind_mode ()
Packit 345191
sets
Packit 345191
.I mode
Packit 345191
to
Packit 345191
.BR MPOL_PREFERRED .
Packit 345191
See
Packit 345191
.BR mbind (2)
Packit 345191
for more information about this flag.
Packit 345191
.PP
Packit 345191
.BR memkind_interleave_get_mbind_mode ()
Packit 345191
sets
Packit 345191
.I mode
Packit 345191
to
Packit 345191
.BR MPOL_INTERLEAVE .
Packit 345191
See
Packit 345191
.BR mbind (2)
Packit 345191
for more information about this flag.
Packit 345191
.PP
Packit 345191
.BR memkind_nohugepage_madvise ()
Packit 345191
calls
Packit 345191
.BR madvise (2)
Packit 345191
with the
Packit 345191
.B MADV_NOHUGEPAGE
Packit 345191
advice.
Packit 345191
See
Packit 345191
.BR madvise (2)
Packit 345191
for more information about this option.
Packit 345191
.PP
Packit 345191
.BR memkind_posix_check_alignment ()
Packit 345191
can be used to check the alignment value for
Packit 345191
.BR memkind_posix_memalign ()
Packit 345191
to ensure that is abides by the POSIX requirements:
Packit 345191
alignment must be a power of 2 at least as large as
Packit 345191
.IR "sizeof(void*)" .
Packit 345191
.PP
Packit 345191
.BR memkind_default_get_mbind_nodemask ()
Packit 345191
wraps jemalloc's
Packit 345191
.BR copy_bitmask_to_bitmask .
Packit 345191
This function copies body of the bitmask structure into passed pointer.
Packit 345191
.PP
Packit 345191
.BR memkind_default_init_once ()
Packit 345191
initializes heap manager.
Packit 345191
.PP
Packit 345191
.BR size_out_of_bounds ()
Packit 345191
returns true if given size is out of bounds, otherwise will return false.
Packit 345191
.SH "COPYRIGHT"
Packit 345191
Copyright (C) 2014 - 2019 Intel Corporation. All rights reserved.
Packit 345191
.SH "SEE ALSO"
Packit 345191
.BR memkind (3),
Packit 345191
.BR memkind_arena (3),
Packit 345191
.BR memkind_hbw (3),
Packit 345191
.BR memkind_hugetlb (3),
Packit 345191
.BR memkind_pmem (3),
Packit 345191
.BR jemalloc (3),
Packit 345191
.BR mbind (2),
Packit 345191
.BR mmap (2)