[cfe-users] RFC v2: Re: cacheflush.2

Alejandro Colomar (man-pages) via cfe-users cfe-users at lists.llvm.org
Thu Dec 10 12:56:51 PST 2020

Hi all,


       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 more
       portable interface:

           void __builtin___clear_cache(void *begin, void *end);

If you like it, I'll send the patch.

BTW, I'll also have a look and document the different prototypes for



On 12/10/20 8:20 PM, Heinrich Schuchardt wrote:
> On 12/10/20 7:17 PM, Dave Martin wrote:
>> On Wed, Dec 09, 2020 at 07:34:09PM +0100, Alejandro Colomar
>> (man-pages) wrote:
>>> Hi Heinrich & Michael,
>>> What about the following?:
>>> [
>>>         GCC provides a similar function, which may be useful on  archi‐
>>>         tectures that lack this system call:
>>>             void __builtin___clear_cache(void *begin, void *end);
>>> ]
>>> Cheers,
>>> Alex
>> Maybe we should discourage people from calling the cacheflush syscall?
>> I think that people shouldn't be using the syscall unless they really
>> need the finer grained control it provides, and are prepared to take a
>> hit to portability.
>> (On arches where userspace is allowed to do cache flushing directly,
>> __builtin___clear_cache() should transparently do the right thing, with
>> no syscall overhead -- if not, that's probably a bug in the toolchain or
>> compiler support library.)
> What the compiler builtin does depends on the architecture (e.g. nothing
> for x86, cacheflush() for MIPS, a private syscall (0xf0002) on ARM,
> assembly code on ARM64, ...) and on the the operating system (Linux,
> BSD, OS X). For portable code the builtin is really the best choice.
> Best regards
> Heinrich
>> [...]
>> Cheers
>> ---Dave

Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/

More information about the cfe-users mailing list