2 * Copyright 2012 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef FOLLY_IO_HUGEPAGES_H_
18 #define FOLLY_IO_HUGEPAGES_H_
21 #include <sys/types.h>
29 #include "folly/Range.h"
34 * Vector of (huge_page_size, mount_point), sorted by huge_page_size.
35 * mount_point might be empty if no hugetlbfs file system is mounted for
38 typedef std::vector<std::pair<size_t, std::string>> HugePageSizeVec;
41 * Class to interface with Linux huge pages (hugetlbfs).
48 * Get list of supported huge page sizes and their mount points, if
49 * hugetlbfs file systems are mounted for those sizes.
51 const HugePageSizeVec& sizes() const { return sizes_; }
54 * Create a file on a huge page filesystem containing a copy of the data
55 * from data. If multiple huge page sizes are allowed, we
56 * pick the smallest huge page size available, unless you request one
57 * explicitly with the hugePageSize argument.
59 * We return a struct File structure containing the full path and size
60 * (rounded up to a multiple of the huge page size)
67 ByteRange data, StringPiece baseName, size_t hugePageSize = 0,
68 mode_t mode = 0644) const;
71 HugePageSizeVec sizes_;
76 #endif /* FOLLY_IO_HUGEPAGES_H_ */