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
65 Historically, this system call was available on all MIPS UNIX variants
66 including RISC/os, IRIX, Ultrix, NetBSD, OpenBSD, and FreeBSD
67 (and also on some non-UNIX MIPS operating systems), so that
68 the existence of this call in MIPS operating systems is a de-facto
72 should not be used in programs intended to be portable.
73 On Linux, this call first appeared on the MIPS architecture,
74 but nowadays, Linux provides a
76 system call on some other architectures, but with different arguments.
78 .SS Architecture-specific variants
79 glibc provides a wrapper for this system call,
80 with the prototype shown in SYNOPSIS,
81 for the following architectures:
82 ARC, CSKY, MIPS, and NIOS2.
84 On some other architectures,
85 Linux provides this system call, with different arguments:
89 .BI "int cacheflush(unsigned long " addr ", int " scope ", int " cache ,
90 .BI " unsigned long " len );
95 .BI "int cacheflush(unsigned long " addr ", unsigned long " len ", int " op );
100 .BI "int cacheflush(unsigned int " start ", unsigned int " end ", int " cache );
103 On the above architectures,
104 glibc does not provide a wrapper for this system call; call it using
107 Unless you need the finer grained control that this system call provides,
108 you probably want to use the GCC built-in function
109 .BR __builtin___clear_cache (),
110 which provides a portable interface
111 across platforms supported by GCC and compatible compilers:
115 .BI "void __builtin___clear_cache(void *" begin ", void *" end );
119 On platforms that don't require instruction cache flushes,
120 .BR __builtin___clear_cache ()
124 On some GCC-compatible compilers,
125 the prototype for this built-in function uses
131 Linux kernels older than Linux 2.6.11 ignore the
135 arguments, making this function fairly expensive.
136 Therefore, the whole cache is always flushed.
138 This function always behaves as if
140 has been passed for the
142 argument and does not do any error checking on the