1 .\" Written by Ralf Baechle (ralf@waldorf-gmbh.de),
2 .\" Copyright (c) 1994, 1995 Waldorf GMBH
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
6 .TH cacheflush 2 (date) "Linux man-pages (unreleased)"
8 cacheflush \- flush contents of instruction and/or data cache
11 .RI ( libc ", " \-lc )
14 .B #include <sys/cachectl.h>
16 .BI "int cacheflush(void " addr [. nbytes "], int "nbytes ", int "cache );
20 On some architectures,
21 there is no glibc wrapper for this system call; see NOTES.
24 flushes the contents of the indicated cache(s) for the
25 user addresses in the range
28 .IR (addr+nbytes\-1) .
33 Flush the instruction cache.
36 Write back to memory and invalidate the affected valid cache lines.
44 On error, it returns \-1 and sets
46 to indicate the error.
50 Some or all of the address range
66 should not be used in programs intended to be portable.
67 On Linux, this call first appeared on the MIPS architecture,
68 but nowadays, Linux provides a
70 system call on some other architectures, but with different arguments.
71 .SS Architecture-specific variants
72 glibc provides a wrapper for this system call,
73 with the prototype shown in SYNOPSIS,
74 for the following architectures:
75 ARC, CSKY, MIPS, and NIOS2.
77 On some other architectures,
78 Linux provides this system call, with different arguments:
82 .BI "int cacheflush(unsigned long " addr ", int " scope ", int " cache ,
83 .BI " unsigned long " len );
88 .BI "int cacheflush(unsigned long " addr ", unsigned long " len ", int " op );
93 .BI "int cacheflush(unsigned int " start ", unsigned int " end ", int " cache );
96 On the above architectures,
97 glibc does not provide a wrapper for this system call; call it using
100 Unless you need the finer grained control that this system call provides,
101 you probably want to use the GCC built-in function
102 .BR __builtin___clear_cache (),
103 which provides a portable interface
104 across platforms supported by GCC and compatible compilers:
108 .BI "void __builtin___clear_cache(void *" begin ", void *" end );
112 On platforms that don't require instruction cache flushes,
113 .BR __builtin___clear_cache ()
117 On some GCC-compatible compilers,
118 the prototype for this built-in function uses
124 Historically, this system call was available on all MIPS UNIX variants
125 including RISC/os, IRIX, Ultrix, NetBSD, OpenBSD, and FreeBSD
126 (and also on some non-UNIX MIPS operating systems), so that
127 the existence of this call in MIPS operating systems is a de-facto
130 Linux kernels older than Linux 2.6.11 ignore the
134 arguments, making this function fairly expensive.
135 Therefore, the whole cache is always flushed.
137 This function always behaves as if
139 has been passed for the
141 argument and does not do any error checking on the