From: "H. Peter Anvin" <hpa@zytor.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Andi Kleen <ak@linux.intel.com>, Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] Add a text_poke syscall
Date: Wed, 20 Nov 2013 08:42:03 -0800 [thread overview]
Message-ID: <528CE65B.6020300@zytor.com> (raw)
In-Reply-To: <20131119184959.GE29695@two.firstfloor.org>
On 11/19/2013 10:49 AM, Andi Kleen wrote:
>
> We already have all the code. Why not just use it?
>
We're talking user space here, which has different requirement (COW,
memory protection, ...) which means it is not really the same code. You
can't take a page fault while patching the kernel.
> Note I'm not adding any new mechanism, just exporting the existing one.
> So the usual "do things in user space" arguments do not really
> apply here.
>
> Also this is subtle enough that there is definitely benefit from
> having only a single canonical code that does it.
>
> If we ever need any new errata workarounds for this they could be also
> all done in a single central place.
>
>>
>> All we really need in the kernel is the IPI broadcasts - the rest can be
>> done in user space, including intercepting SIGTRAP. For userspace it is
>> probably the best to just put a thread to sleep until the patching is
>> done, which can be done with a futex.
>
> I'm not sure that's worth it. IPIs are reasonably fast (a few 1000s cycles).
> Sleeping likely only becomes beneficial with much longer delays, like
> ms. But if the IPIs start taking ms we have much more problems.
I'm referring to if some thread actually stumbles over INT 3, which is
indeed not very long for one patch site (as long as you don't end up
with page faults.) However, for tracing, you may want to do tens of
thousands of patches, and you really want to batch them.
>> One advantage with doing this in userspace is that the kernel doesn't
>> have to be responsible avoiding holding a thread due to a slightly
>> different SIGTRAP -- it will all come out after the signal handler is
>> restored, anyway.
>
> It's just some spinning, not a new task state. I don't think any
> task states make sense here.
I'd rather spin in user space, though.
-hpa
next prev parent reply other threads:[~2013-11-20 16:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-19 0:27 [PATCH] Add a text_poke syscall Andi Kleen
2013-11-19 2:32 ` Andy Lutomirski
2013-11-19 20:16 ` Andi Kleen
2013-11-21 10:02 ` Jiri Kosina
2013-11-19 5:23 ` H. Peter Anvin
2013-11-19 18:49 ` Andi Kleen
2013-11-20 16:42 ` H. Peter Anvin [this message]
2013-11-20 17:25 ` Andi Kleen
2013-11-20 18:30 ` H. Peter Anvin
2013-11-20 21:00 ` H. Peter Anvin
2013-11-21 12:49 ` Steven Rostedt
2013-11-19 6:49 ` Ingo Molnar
2013-11-19 19:10 ` Andi Kleen
2013-11-21 13:07 ` Steven Rostedt
2013-11-22 3:26 ` Andi Kleen
2013-11-21 18:26 ` Oleg Nesterov
2013-11-22 3:29 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=528CE65B.6020300@zytor.com \
--to=hpa@zytor.com \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.