diff options
author | Alexey Salmin <alexey.salmin@gmail.com> | 2022-02-10 16:49:37 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:37 +0300 |
commit | 3c5b1607b38f637d2f3313791ed25c2e080d2647 (patch) | |
tree | 99be7b96e7c66612fbca94331100ef3b5fedcb88 /util/system/mincore.h | |
parent | de89752358147d7b25ef59a85b431bb564068a49 (diff) | |
download | ydb-3c5b1607b38f637d2f3313791ed25c2e080d2647.tar.gz |
Restoring authorship annotation for Alexey Salmin <alexey.salmin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/system/mincore.h')
-rw-r--r-- | util/system/mincore.h | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/util/system/mincore.h b/util/system/mincore.h index 0f5d8b78c7..1fc3f7d69c 100644 --- a/util/system/mincore.h +++ b/util/system/mincore.h @@ -1,38 +1,38 @@ -#pragma once - -#include "defaults.h" -/** - * Fills a vector that indicates whether pages of the calling process's virtual memory are resident in RAM. Each byte - * in the vector contains the status of a single page. The page size can be obtained via the NSystemInfo::GetPageSize() - * function. Use the IsPageInCore function to interpret the page status byte. - * - * Can be overly pessimistic: - * - Assumes nothing is in RAM on platforms other than Linux - * - Recent Linux kernels (4.21 and some backports) may return zeroes if the process doesn't have writing permissions - * for the given file. See CVE-2019-5489. - * - * @param[in] addr starting address of the memory range to be examined - * @param[in] len length (bytes) of the memory range to be examined - * @param[out] vec vector of bytes to store statuses of memory pages - * @param[in] vecLen length (bytes) of the vec, should be large enough to hold the requested pages count - * @throws yexception if there was a system error or if the vecLen is too small - * - * @note this is only a snapshot, results may be stale by the time they're used - * @see man 2 mincore - */ -void InCoreMemory(const void* addr, size_t len, unsigned char* vec, size_t vecLen); - -/** - * Takes as an argument an element of the vector previously filled by InCoreMemory. - * - * @param[in] byte corresponding to the status of a single page - * - * @returns true if this page was resident in memory at the time out the InCoreMemory execution - */ -inline bool IsPageInCore(unsigned char s) { - /* From mincore(2): On return, the least significant bit of each byte will be set if the corresponding page is - * currently resident in memory, and be clear otherwise. (The settings of the other bits in each byte are - * undefined; these bits are reserved for possible later use.) - */ - return s & 1; -} +#pragma once + +#include "defaults.h" +/** + * Fills a vector that indicates whether pages of the calling process's virtual memory are resident in RAM. Each byte + * in the vector contains the status of a single page. The page size can be obtained via the NSystemInfo::GetPageSize() + * function. Use the IsPageInCore function to interpret the page status byte. + * + * Can be overly pessimistic: + * - Assumes nothing is in RAM on platforms other than Linux + * - Recent Linux kernels (4.21 and some backports) may return zeroes if the process doesn't have writing permissions + * for the given file. See CVE-2019-5489. + * + * @param[in] addr starting address of the memory range to be examined + * @param[in] len length (bytes) of the memory range to be examined + * @param[out] vec vector of bytes to store statuses of memory pages + * @param[in] vecLen length (bytes) of the vec, should be large enough to hold the requested pages count + * @throws yexception if there was a system error or if the vecLen is too small + * + * @note this is only a snapshot, results may be stale by the time they're used + * @see man 2 mincore + */ +void InCoreMemory(const void* addr, size_t len, unsigned char* vec, size_t vecLen); + +/** + * Takes as an argument an element of the vector previously filled by InCoreMemory. + * + * @param[in] byte corresponding to the status of a single page + * + * @returns true if this page was resident in memory at the time out the InCoreMemory execution + */ +inline bool IsPageInCore(unsigned char s) { + /* From mincore(2): On return, the least significant bit of each byte will be set if the corresponding page is + * currently resident in memory, and be clear otherwise. (The settings of the other bits in each byte are + * undefined; these bits are reserved for possible later use.) + */ + return s & 1; +} |