From: Ingo Molnar <mingo@kernel.org>
To: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Andi Kleen <andi@firstfloor.org>,
dave@sr71.net, linux-kernel@vger.kernel.org, eranian@google.com,
x86@kernel.org, torvalds@linux-foundation.org,
Vitaly Mayatskikh <v.mayatskih@gmail.com>
Subject: Re: [PATCH 2/2] x86: Only do a single page fault for copy_from_user_nmi
Date: Fri, 3 Oct 2014 06:53:59 +0200 [thread overview]
Message-ID: <20141003045359.GA24281@gmail.com> (raw)
In-Reply-To: <20140929152646.GC1629@tassilo.jf.intel.com>
* Andi Kleen <ak@linux.intel.com> wrote:
> > For now, changing the semantics of the function seems like a
> > sure way to fail in the future though.
>
> I doubt it. Nearly nobody uses the exact return value
> semantics.
>
> (iirc it's mostly write() and some bizarre code in mount)
>
> In fact it's a regular mistake to assume it returns -errno.
>
> > > In theory we could also duplicate the whole copy_*_ path
> > > for cases where the caller doesn't care about the exact
> > > bytes. But that seems overkill for just this issue, and I'm
> > > not sure anyone else cares about how fast this is. The
> > > simpler check works as well for now.
> >
> > So I don't get that code, but why not fix it in general?
> > Taking two faults seems silly.
>
> It's really complicated to reconstruct the exact bytes, as an
> optimized memcpy is very complicated and has a lot of corner
> cases.
>
> I tried it originally when writing the original copy function,
> but failed. That is why people came up later with this
> two-fault scheme.
>
> I think two fault is fine for most cases, just not for NMIs.
Slapping an ugly in_nmi() check into a generic memcpy routine,
especially if it changes semantics, is asking for trouble.
It is a non-starter and I'm NAK-ing it.
There are cleaner ways to solve this problem - PeterZ offered
one, but there are other options as well, such as:
- removing exact-bytes semantics explicitly from almost all
cases and offering a separate (and more expensive, in the
faulting case) memcpy variant for write() and other code that
absolutely must know the number of copied bytes.
- or adding a special no-bytes-copied memcpy variant that the
NMI code could use.
Use one of these or outline that they cannot possibly work.
It might be more work for you, but it gives us a cleaner and more
maintainable kernel. The problem is that you should know this
general principle already, instead you are wasting maintainer
bandwidth via arguing in favor of ugly hacks again and again...
Thanks,
Ingo
next prev parent reply other threads:[~2014-10-03 4:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 23:31 Optimize backtrace code for perf PMI handler Andi Kleen
2014-09-26 23:31 ` [PATCH 1/2] Use faster check for modules in backtrace on 64bit Andi Kleen
2014-09-29 11:42 ` Peter Zijlstra
2014-09-29 15:21 ` Andi Kleen
2014-09-29 20:30 ` Andi Kleen
2014-09-30 8:58 ` Peter Zijlstra
2014-09-30 20:10 ` Andi Kleen
2014-10-02 10:57 ` Peter Zijlstra
2014-10-03 23:20 ` Andi Kleen
2014-09-26 23:31 ` [PATCH 2/2] x86: Only do a single page fault for copy_from_user_nmi Andi Kleen
2014-09-29 11:56 ` Peter Zijlstra
2014-09-29 15:26 ` Andi Kleen
2014-10-03 4:53 ` Ingo Molnar [this message]
2014-10-03 23:25 ` 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=20141003045359.GA24281@gmail.com \
--to=mingo@kernel.org \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=dave@sr71.net \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=v.mayatskih@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).