Re: How do I flush/invalidate the CPU instruction cache?

From: Neil Horman (nhorman_at_redhat.com)
Date: 09/15/03


Date: Mon, 15 Sep 2003 07:24:44 -0400

jeff wrote:
> Neil Horman wrote:
>
>> turbo wrote:
>>
>>> I have a dual processor, x86 computer running redhat 9 linux.
>>> I am working with a friend, on a compiler/interpreter environment
>>> that can dynamically generate machine code to be executed.
>>> In order to make the newly generated code work in the system,
>>> it is necessary to flush the instruction cache.
>>>
>>> On Microsoft windows, you just call
>>>
>>> FlushInstructionCache(GetCurrentProcess(), NULL, 0);
>>>
>>> I have searched, and I can't find a way to do it.
>>> I was able to find some old docs to do it on mips based linux.
>>>
>>> Any ideas?
>>>
>>> Thanks,
>>> Jeff
>>>
>>
>> There are some routines defined in the linux kernel for cache
>> flushing, but under X86 they are defined to compile to nothing. I'm
>> sure you've heard this before, but unless the CPU has some sort of
>> problem, user space applications really should not need to flush the
>> cache. This is not to say it can't be done, but if you want to, it
>> means you will have to implement a flush routine in kernel space (this
>> will of course be arch specific), export it in some way to user space
>> and call it from there. The need to flush the cache also clearly
>> means you can say goodbye to easy portability. Perhaps you can expand
>> on why you need to flush the cache, and some people can propose some
>> more portable workaround/other solutions for your problem?
>>
>> HTH
>> Neil
>
>
> As I said, this is for a interactive language that is mostly compiled
> and has the ability to dynamically compile to machine code,
> new program source that is integrated into the existing program, and
> continue executing.
>
> Imaine an interactive basic interpreter, that already is executing a big
> program, and you type in a new procedure, and say to the language
> "compile and run".
>
> This happens to be for a large, mature language called ICL (a strongly
> typed garbage collected language designed for building large complex
> systems), invented at Caltech as part of a doctoral thesis in the late
> 1970's or so, that has around 1 millions lines of code written for it.
> It was developed for the dec-20, ported to the vax, then the dec alpha,
> and currently runs under windows. I am porting it to x86 Gnu/Linux. It
> was used as the backend of the first e-commerce application, mosis.org,
> where I happened to work from 1985-1995.
>
> Jeff Deifik
>
And what specific problem are you running into that you believe will be
solved by flushing the cache?
Neil

-- 
/***************************************************
  *Neil Horman
  *Software Engineer
  *Red Hat, Inc.
  *nhorman@redhat.com
  ***************************************************/


Relevant Pages

  • Re: How do I flush/invalidate the CPU instruction cache?
    ... >> There are some routines defined in the linux kernel for cache ... >> means you will have to implement a flush routine in kernel space (this ... this is for a interactive language that is mostly compiled ... *Neil Horman ...
    (comp.os.linux.questions)
  • Re: How do I flush/invalidate the CPU instruction cache?
    ... >> There are some routines defined in the linux kernel for cache ... >> means you will have to implement a flush routine in kernel space (this ... this is for a interactive language that is mostly compiled ... I am porting it to x86 Gnu/Linux. ...
    (comp.os.linux.development.system)
  • Re: Programmers unpaid overtime.
    ... The cache solution's execution time formula is a function of the total ... The campaign is part of what I consider the deprivation of language by ... You can't, in other words, document, and management wonders why ... >> complexity with a few benchmarks. ...
    (comp.programming)
  • flush cache range proposal (was Re: ide errors in 7-rc1-mm1 and later)
    ... If bit 0 is set to one, the mandatory FLUSH CACHE and FLUSH CACHE EXT ... commands support the RANGE bit, and user-supplied LBA ... and sector count specifying the limits of the cache flush. ...
    (Linux-Kernel)
  • Re: Should Cache be on the MV Family Tree?
    ... >> Will the Cache' product have functional DataBASIC or multivalue query ... the query language at a directory of XML documents? ... I took a look at the web site and see MultiValue BASIC as the ...
    (comp.databases.pick)