From: Rob Gardner <rob.gardner@oracle.com>
To: sparclinux@vger.kernel.org
Subject: Re: [PATCH 1/2] sparc64: Ensure perf can access user stacks
Date: Sat, 26 Dec 2015 05:02:43 +0000 [thread overview]
Message-ID: <567E1F73.6000406@oracle.com> (raw)
In-Reply-To: <1450844167-7327-1-git-send-email-rob.gardner@oracle.com>
On 12/25/2015 09:25 PM, David Miller wrote:
> From: Rob Gardner <rob.gardner@oracle.com>
> Date: Thu, 24 Dec 2015 10:39:05 -0700
>
>> Sorry I should have noted this in the log message, but we
>> intentionally did not use get_fs() and set_fs() there because they are
>> not safe to use in a "nested" interrupt context. n.b. get_fs() is not
>> guaranteed to report a value consistent with %asi while we're
>> executing the perf interrupt handler, because it may have interrupted
>> kernel code where %asi is inconsistent with the thread_info current_ds
>> value. This is common, e.g. right in NGmemcpy.
> Is that a real problem?
>
> The return from trap will restore the %asi register properly from
> the %tstate register.
>
It's not a problem for the context that was interrupted since as you
say, %asi will be restored properly. But in the perf interrupt context
it seems a little messy to me because get_fs() can (and will) return a
value inconsistent with %asi, so at the end of perf_callchain_user()
when set_fs() is done, it will not truly restore %asi to what it was
when the function began. So up until the return from trap, %asi contains
an unintended value. I didn't track down all possibilities to see if
anything bad might happen, but it just seemed wrong to leave things in
that state.
Also, in the code we submitted, there was an optimization in which %asi
is read, and then only set to ASI_AIUS if necessary. This drastically
reduces the number of writes to the %asi register since most of the time
%asi will contain ASI_AIUS. This seems like a reasonable optimization,
since this function may be called thousands of times per second on every
cpu. But this doesn't work at all using get_fs() since it is
inconsistent with %asi, and that is why we went with the inline
assembler to read and write %asi directly.
Merry Christmas.
Rob
next prev parent reply other threads:[~2015-12-26 5:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-23 4:16 [PATCH 1/2] sparc64: Ensure perf can access user stacks Rob Gardner
2015-12-23 5:45 ` David Miller
2015-12-24 16:43 ` David Miller
2015-12-24 17:39 ` Rob Gardner
2015-12-26 4:25 ` David Miller
2015-12-26 5:02 ` Rob Gardner [this message]
2015-12-26 6:27 ` David Miller
2015-12-26 22:25 ` Rob Gardner
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=567E1F73.6000406@oracle.com \
--to=rob.gardner@oracle.com \
--cc=sparclinux@vger.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.