Re: [RFC][PATCH] x86: make text_poke() atomic

Masami Hiramatsu
2009-03-03T00:06:55Z

Ingo Molnar wrote:
> * Masami Hiramatsu <mhiramat@redhat.com> wrote:
>
>> Ingo Molnar wrote:
>>>>> So perhaps another approach to (re-)consider would be to go back
>>>>> to atomic fixmaps here. It spends 3 slots but that's no big
>>>>> deal.
>>>> Oh, it's a good idea! fixmaps must make it simpler.
>>>>
>>>>> In exchange it will be conceptually simpler, and will also scale
>>>>> much better than a global spinlock. What do you think?
>>>> I think even if I use fixmaps, we have to use a spinlock to protect
>>>> the fixmap area from other threads...
>>> that's why i suggested to use an atomic-kmap, not a fixmap.
>> Even if the mapping is atomic, text_poke() has to protect pte
>> from other text_poke()s while changing code.
>> AFAIK, atomic-kmap itself doesn't ensure that, does it?
>
> Well, but text_poke() is not a serializing API to begin with.
> It's normally used in code patching sequences when we 'know'
> that there cannot be similar parallel activities. The kprobes
> usage of text_poke() looks unsafe - and that needs to be fixed.

Oh, kprobes already prohibited parallel arming/disarming
by using kprobe_mutex. :-)

> So indeed a new global lock is needed there.
>
> It's fixable and we'll fixit, but text_poke() is really more
> complex than i'd like it to be.
>
> stop_machine_run() is essentially instantaneous in practice and
> obviously serializing so it warrants a second look at least.
> Have you tried to use it in kprobes?

No, but it seems that cost high for incremental use(registration)
of kprobes...

Thank you,

>
> Ingo

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com