mlock in cache

Florian Weimer fweimer@redhat.com
Fri Aug 2 15:21:00 GMT 2013


On 08/02/2013 05:03 PM, Christos wrote:
> On 08/02/2013 03:27 PM, Andrew Haley wrote:
>> __builtin_prefetch() is what you need. However, there's no way you'll
>> be able to lock anything in L1: it'll be evicted very shortly
>> afterwards. Andrew.
>
> Sorry for that, but from what I see __builtin_prefetch() just fetches in
> advance the related pages but it does not guarantee that thy won't be
> thrown out of the cache. I want to know if there is some way to prefetch
> and lock some memory unit in cache. I'm pretty sure that there should be
> a way for this to be done in assembly, but I don't know for C or some
> gcc built-in

Most CPUs just do not support this.

Some hardware transaction memory implementations perform cache line 
locking as an implementation detail.


-- 
Florian Weimer / Red Hat Product Security Team



More information about the Gcc-help mailing list