cacheflush(2) System Calls Manual cacheflush(2) cacheflush - / C (libc, -lc) #include int cacheflush(void addr[.nbytes], int nbytes, int cache); : glibc call; . . cacheflush() () addr (addr+nbytes-1). cache : ICACHE . DCACHE . BCACHE (ICACHE|DCACHE). cacheflush() returns 0 on success. On error, it returns -1 and sets errno to indicate the error. EFAULT addr (addr+nbytes-1) . EINVAL cache ICACHE, DCACHE BCACHE ( ). cacheflush() . Linux, MIPS, Linux cacheflush() , . , glibc provides a wrapper for this system call, with the prototype shown in SYNOPSIS, for the following architectures: ARC, CSKY, MIPS, and NIOS2. Linux : M68K: int cacheflush(unsigned long addr, int scope, int cache, unsigned long len); SH: int cacheflush(unsigned long addr, unsigned long len, int op); NDS32: int cacheflush(unsigned int start, unsigned int end, int cache); On the above architectures, glibc does not provide a wrapper for this system call; call it using syscall(2). GCC Unless you need the finer grained control that this system call provides, you probably want to use the GCC built-in function __builtin___clear_cache(), which provides a portable interface across platforms supported by GCC and compatible compilers: void __builtin___clear_cache(void *begin, void *end); , , __builtin___clear_cache() . : GCC- char * void * . , UNIX MIPS RISC/os, IRIX, Ultrix, NetBSD, OpenBSD FreeBSD ( -UNIX MIPS), MIPS -. Linux kernels older than Linux 2.6.11 ignore the addr and nbytes arguments, making this function fairly expensive. Therefore, the whole cache is always flushed. , cache BCACHE, cache. () Azamat Hackimov , Dmitriy S. Seregin , Dmitry Bolkhovskikh , Katrin Kutepova , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 2 2024 . cacheflush(2)