From: Rich Felker <dalias@libc.org>
To: Michael Karcher <michael.karcher@fu-berlin.de>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Linux-sh list <linux-sh@vger.kernel.org>,
Yoshinori Sato <ysato@users.sourceforge.jp>,
Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sh: Implement __get_user_u64() required for 64-bit get_user()
Date: Mon, 01 Jun 2020 20:50:29 +0000 [thread overview]
Message-ID: <20200601205029.GW1079@brightrain.aerifal.cx> (raw)
In-Reply-To: <50235.92.201.26.143.1591043169.webmail@webmail.zedat.fu-berlin.de>
On Mon, Jun 01, 2020 at 10:26:09PM +0200, Michael Karcher wrote:
> Rich Felker schrieb:
> >> >> Can I propose a different solution? For archs where there isn't
> >> >> actually any 64-bit load or store instruction, does it make sense to
> >> >> be writing asm just to do two 32-bit loads/stores, especially when
> >> >> this code is not in a hot path?
> >> > Yes, that's an option, too.
> >> That's the solution that Michael Karcher suggested to me as an
> >> alternative when I talked to him off-list.
>
> There is a functional argument agains using get_user_32 twice, which I
> overlooked in my private reply to Adrian. If any of the loads fail, we do
> not only want err to be set to -EFAULT (which will happen), but we also
> want a 64-bit zero as result. If one 32-bit read faults, but the other one
> works, we would get -EFAULT together with 32 valid data bits, and 32 zero
> bits.
Indeed, if you do it that way you want to check the return value and
set the value to 0 if either faults.
BTW I'm not sure what's supposed to happen on write if half faults
after the other half already succeeded... Either a C approach or an
asm approach has to consider that.
> > I don't have an objection to doing it the way you've proposed, but I
> > don't think there's any performance distinction or issue with the two
> > invocations.
>
> Assuming we don't need two exception table entries (put_user_64 currently
> uses only one, maybe it's wrong), using put_user_32 twice creates an extra
> unneeded exception table entry, which will "bloat" the exception table.
> That table is most likely accessed by a binary search algorithm, so the
> performance loss is marginal, though. Also a bigger table size is
> cache-unfriendly. (Again, this is likely marginal again, as binary search
> is already extremely cache-unfriendly).
>
> A similar argument can be made for the exception handler. Even if we need
> two entries in the exception table, so the first paragraph does not apply,
> the two entries in the exception table can share the same exception
> handler (clear the whole 64-bit destination to zero, set -EFAULT, jump
> past both load instructions), so that part of (admittedly cold) kernel
> code can get some instructios shorter.
Indeed. I don't think it's a significant difference but if kernel
folks do that's fine. In cases like this my personal preference is to
err on the side of less arch-specific asm.
Rich
next prev parent reply other threads:[~2020-06-01 20:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 17:45 [RESEND] sh: Implement __get_user_u64() required for 64-bit get_user() John Paul Adrian Glaubitz
2020-05-29 17:45 ` [PATCH] " John Paul Adrian Glaubitz
2020-05-31 9:52 ` Geert Uytterhoeven
2020-05-31 9:54 ` John Paul Adrian Glaubitz
2020-05-31 9:59 ` John Paul Adrian Glaubitz
2020-05-31 10:43 ` Geert Uytterhoeven
2020-05-31 10:52 ` John Paul Adrian Glaubitz
2020-06-01 3:03 ` Rich Felker
2020-06-01 9:02 ` Geert Uytterhoeven
2020-06-01 9:13 ` John Paul Adrian Glaubitz
2020-06-01 16:57 ` Rich Felker
2020-06-01 20:26 ` Michael Karcher
2020-06-01 20:50 ` Rich Felker [this message]
2020-06-02 10:19 ` Michael Karcher
-- strict thread matches above, loose matches on Subject: below --
2020-06-11 7:58 [PATCH v3] " John Paul Adrian Glaubitz
2020-06-11 7:58 ` [PATCH] " John Paul Adrian Glaubitz
2020-06-27 15:26 ` Yoshinori Sato
2020-05-29 17:34 John Paul Adrian Glaubitz
2020-05-29 17:34 ` [PATCH] sh: Implement __get_user_u64() required for 64-bit get_user() John Paul Adrian Glaubitz
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=20200601205029.GW1079@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=geert@linux-m68k.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=kernel@mkarcher.dialup.fu-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=michael.karcher@fu-berlin.de \
--cc=ysato@users.sourceforge.jp \
/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).