posix_fadvise(2) System Calls Manual posix_fadvise(2) posix_fadvise - Standard C library (libc, -lc) #include int posix_fadvise(int fd, off_t offset, off_t size, int advice); glibc (. feature_test_macros(7)): posix_fadvise(): _POSIX_C_SOURCE >= 200112L posix_fadvise() , . advice ( ) , offset, len ( , len 0) , fd. advice ; . advice: POSIX_FADV_NORMAL , . , . POSIX_FADV_SEQUENTIAL ( ). POSIX_FADV_RANDOM . POSIX_FADV_NOREUSE . Before Linux 2.6.18, POSIX_FADV_NOREUSE had the same semantics as POSIX_FADV_WILLNEED. This was probably a bug; from Linux 2.6.18 until Linux 6.2 this flag was a no-op. Since Linux 6.3, POSIX_FADV_NOREUSE signals that the kernel page replacement algorithm can ignore access to mapped page cache marked by this flag. This is useful, for example, while streaming large files. POSIX_FADV_WILLNEED . POSIX_FADV_WILLNEED . ( , , , ). POSIX_FADV_DONTNEED . POSIX_FADV_DONTNEED , . , , . , . Requests to discard partial pages are ignored. It is preferable to preserve needed data than discard unneeded data. If the application requires that data be considered for discarding, then offset and size must be page-aligned. (dirty) , . . , fsync(2) fdatasync(2). 0. . EBADF fd . EINVAL advice. ESPIPE The specified file descriptor refers to a pipe or FIFO. (ESPIPE is the error specified by POSIX, but before Linux 2.6.16, Linux returned EINVAL in this case.) Under Linux, POSIX_FADV_NORMAL sets the readahead window to the default size for the backing device; POSIX_FADV_SEQUENTIAL doubles this size, and POSIX_FADV_RANDOM disables file readahead entirely. POSIX_FADV_NOREUSE does not modify the readahead window size. These changes affect the entire file, not just the specified region (but other open file handles to the same file are unaffected). C C posix_fadvise(). fadvise64() ( -- fadvise64_64()); , len size_t, -- loff_t. , , 64- ( syscall(2)). posix_fadvise() fd offset. , posix_fadvise(). , Linux 2.6.14, ARM : long arm_fadvise64_64(int fd, int advice, loff_t offset, loff_t size); , , , , glibc posix_fadvise(), . POSIX.1-2008. POSIX.1-2001. Kernel support first appeared in Linux 2.5.60; the underlying system call is called fadvise64(). Library support has been provided since glibc 2.2, via the wrapper function posix_fadvise(). Linux 3.18 , , CONFIG_ADVISE_SYSCALLS. The type of the size argument was changed from size_t to off_t in POSIX.1-2001 TC1. /proc/sys/vm/drop_caches, proc(5). , : , mmap(2) mincore(2) . Before Linux 2.6.6, if size was specified as 0, then this was interpreted literally as "zero bytes", rather than as meaning "all bytes through to the end of the file". fincore(1), mincore(2), readahead(2), sync_file_range(2), posix_fallocate(3), posix_madvise(3) () Alexey, Azamat Hackimov , kogamatranslator49 , Darima Kogan , Max Is , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux man-pages 6.12 20 2024 . posix_fadvise(2)