---
name: "getpagesizes"
section: "3"
platform: "linux"
package: "libhugetlbfs-dev"
version: "2.24-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/getpagesizes"
---

# getpagesizes(3)

Get the system supported huge page sizes

## NAME

getpagesizes - Get the system supported huge page sizes

## SYNOPSIS

**#include \<hugetlbfs.h\>**\

int getpagesizes(long pagesizes\[\], int n\_elem);

## DESCRIPTION

The getpagesizes() function returns either the number of system supported page sizes or the sizes  themselves. If **pagesizes** is NULL and **n\_elem** is 0, then the number of pages the system supports is returned. Otherwise, **pagesizes** is filled with at most **n\_elem** page sizes.

## RETURN VALUE

On success, either the number of page sizes supported by the system or the number of page sizes stored in **pagesizes** is returned. On failure, -1 is returned and errno is set appropriately.

## ERRORS

- **EINVAL**

  **n\_elem** is less than zero or **n\_elem** is greater than zero and **pagesizes** is NULL.

Also see [opendir(3)](/opendir/3.md) for other possible values for errno. This error occurs when the sysfs directory exists but cannot be opened.

## NOTES

This call will return all page sizes as reported by the kernel.  Not all of these sizes may be usable by the programmer since mount points may not be available for the huge page sizes.  To test whether a size will be usable by **libhugetlbfs**, hugetlbfs\_find\_path\_for\_size() can be called on a specific size to see if a mount point is configured.

## SEE ALSO

*[oprofile(1)](/oprofile/1.md),* *[opendir(3)](/opendir/3.md),* *[gethugepagesizes(3)](/gethugepagesizes/3.md),* *[libhugetlbfs(7)](/libhugetlbfs/7.md)*

## AUTHORS

libhugetlbfs was written by various people on the libhugetlbfs-devel mailing list.
