From: Paolo Bonzini <pbonzini@redhat.com>
To: speck@linutronix.de
Subject: [MODERATED] Re: eager FPU backport for 2.6.32
Date: Tue, 31 Jul 2018 10:15:52 +0200 [thread overview]
Message-ID: <8a9a93cd-f3a9-fb03-cd10-d3c72ee12129@redhat.com> (raw)
In-Reply-To: <nycvar.YFH.7.76.1807310932160.997@cbobk.fhfr.pm>
[-- Attachment #1: Type: text/plain, Size: 5521 bytes --]
On 31/07/2018 09:35, speck for Jiri Kosina wrote:
>
>> For the lucky souls who have to backport eager FPU support to 2.6.32,
>> and at the risk of being larted by Thomas :) here is my current list of
>> FPU patches on top of 2.6.32. I tried to include also those that were
>> already in RHEL before I started the backport.
> Hi Paolo,
>
> have have quite divergent eager FPU switching backports to 3.0 and 4.4
> (where 4.4 is basically cherry-picked fixes from upstream, while 3.0 is
> mostly a divergent minimalistic implementation), and for *both* codestream
> we're receiving reports of Oracle database segfaulting in a way that looks
> like register / memory corruption. We're not seeing any errors / reports
> with any other userspace excercising FPU.
>
> Have you guys at RH by chance received any such reports after switching
> older kernels to eager FPU switching?
No, but we had bugs with signals with the patch list I sent earlier,
so here is a list of extra patches that we added on top of that list.
a9241ea5fd709fc935dade130f4e3b2612bbe9e3
x86/fpu: Don't reset thread.fpu_counter
1a2a7f4ec8e3a7ac582dac4d01fcc7e8acd3bb30
x86/fpu: Don't do __thread_fpu_end() if use_eager_fpu()
9b6dba9e0798325dab427b9d60c61630ccc39b28
x86: Merge simd_math_error() into math_error()
08a744c6bfded3d5fa66f94263f81773226113d1
x86/fpu: Change math_error() to use unlazy_fpu(), kill (now) unused save_init_fpu()
731bd6a93a6e9172094a2322bd0ee964bb1f4d63
x86, fpu: Check tsk_used_math() in kernel_fpu_end() for eager FPU
14e153ef75eecae8fd0738ffb42120f4962a00cd
x86, fpu: Introduce per-cpu in_kernel_fpu state
33a3ebdc077fd85f1bf4d4586eea579b297461ae
x86, fpu: Don't abuse has_fpu in __kernel_fpu_begin/end()
4b2e762e2e53c721458a83d547b222178bb72a34
x86/fpu: Always allow FPU in interrupt if use_eager_fpu()
e7f180dcd8ab48f18b20d7e8a7e9b39192bdf8e0
x86/fpu: Change xstateregs_get()/set() to use ->xsave.i387 rather than ->fxsave
1d23c4518b1f3a03c278f23333149245c178d2a6
x86/fpu: Factor out memset(xstate, 0) in fpu_finit() paths
fb14b4eadf73500d3b2104f031472a268562c047
x86/fpu: Document user_fpu_begin()
8f4d81863ba4e8dfee93bd50840f1099a296251f
x86/fpu: Introduce restore_init_xstate()
f893959b0898bd876673adbeb6798bdf25c034d7
x86/fpu: Don't abuse drop_init_fpu() in flush_thread()
d2d0ac9a4644e00120bb9b7427a512a99d2cacc5
x86/fpu: Fold __drop_fpu() into its sole user
7575637ab293861a799f3bbafe0d8c597389f4e9
x86, fpu: Fix math_state_restore() race with kernel_fpu_begin()
b85e67d1483c72b77d1bdc265aa8ba91590794c1
x86/fpu: Rename drop_init_fpu() to fpu_reset_state()
c88d47480d300eaad80c213d50c9bf6077fc49bc
x86/fpu: Always restore_xinit_state() when use_eager_cpu()
ab6b52947545a5355154f64f449f97af9d05845f
x86/fpu: Fix 32-bit signal frame handling
18ecb3bfa5a9f6fffbb3eeb4369f0b9463438ec0
x86/fpu: Load xsave pointer *after* initialization
c447e76b4cabb49ddae8e49c5758f031f35d55fb (more or less redone from scratch)
kvm/fpu: Enable eager restore kvm FPU for MPX
A reproducer is after my sig. It does 10,000 iterations, but really
it almost always fails within the first 3-4, and if it doesn't it fails
within the first 100.
Also note that I didn't backport fully lazy FPU because it scared
the hell out of me. :)
Paolo
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
void set(unsigned long long v)
{
asm("movsd %[v], %%XMM0"
:
: [v] "m" (v)
:
);
}
unsigned long long get(void)
{
unsigned long long v;
asm("movsd %%XMM0, %[check]"
:
: [check] "m" (v)
:
);
return v;
}
volatile int signal_cnt = 0;
void sigcld(int s, siginfo_t *si, void *ctx)
{
ucontext_t *uc = ctx;
mcontext_t *mc = &uc->uc_mcontext;
fpregset_t fpr = mc->fpregs;
//printf("in signal handler, saved xmm0 is %llx %llx\n", fpr->_xmm[0].element[0], fpr->_xmm[0].element[1]);
signal_cnt++;
}
void try(int j)
{
int i, status;
int rounds = 100;
for (i = 0; i < rounds; i++) {
unsigned long long correct = i + 0x5713AFDB2639ECA0ULL;
unsigned long long actual;
signal_cnt = 0;
set(correct);
if (fork() == 0) {
exit(0);
}
actual = get();
int x = signal_cnt;
if (correct != actual) {
printf("xmm0 is different for %d, %d: %llx (expected %llx) signal_cnt=%d\n",
j, i, actual, correct, signal_cnt);
exit(1);
}
}
for (i = 0; i < rounds; i++) {
wait(&status);
}
}
int main(void)
{
int i;
setvbuf(stdout, NULL, _IONBF, 0);
struct sigaction sigact = { .sa_sigaction = sigcld, .sa_flags = SA_SIGINFO };
sigaction(SIGCLD, &sigact, NULL);
for (i = 0; i < 10000; i++) {
if ((i % 10) == 0) putchar (((i / 10) % 10) + '0');
try(i);
if ((i % 100) == 99) printf(" %d\n", i+1);
}
return 0;
}
prev parent reply other threads:[~2018-07-31 8:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-11 8:33 [MODERATED] eager FPU backport for 2.6.32 Paolo Bonzini
2018-06-11 15:18 ` [MODERATED] " Linus Torvalds
2018-06-11 15:44 ` Peter Zijlstra
2018-06-11 15:51 ` Paolo Bonzini
2018-06-11 16:33 ` Jiri Kosina
2018-06-11 15:51 ` Josh Poimboeuf
2018-06-11 15:59 ` Linus Torvalds
2018-06-11 16:18 ` Paolo Bonzini
2018-07-31 7:35 ` Jiri Kosina
2018-07-31 8:15 ` Paolo Bonzini [this message]
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=8a9a93cd-f3a9-fb03-cd10-d3c72ee12129@redhat.com \
--to=pbonzini@redhat.com \
--cc=speck@linutronix.de \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).