[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250410140407.GC15280@redhat.com>
Date: Thu, 10 Apr 2025 16:04:08 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Ingo Molnar <mingo@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>, linux-kernel@...r.kernel.org,
Andy Lutomirski <luto@...capital.net>, Dave Hansen <dave@...1.net>,
Brian Gerst <brgerst@...il.com>, Borislav Petkov <bp@...en8.de>,
"H . Peter Anvin" <hpa@...or.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
"Chang S . Bae" <chang.seok.bae@...el.com>,
Andy Lutomirski <luto@...nel.org>,
Fenghua Yu <fenghua.yu@...el.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Uros Bizjak <ubizjak@...il.com>
Subject: Re: [PATCH 4/8] x86/fpu: Remove the thread::fpu pointer
On 04/10, Ingo Molnar wrote:
>
> * Peter Zijlstra <peterz@...radead.org> wrote:
>
> > On Wed, Apr 09, 2025 at 11:11:23PM +0200, Ingo Molnar wrote:
> >
> > > -#define x86_task_fpu(task) ((task)->thread.fpu)
> > > +#define x86_task_fpu(task) ((struct fpu *)((void *)(task) + sizeof(*(task))))
> >
> > Doesn't our FPU state need to be cacheline aligned?
>
> Yeah, and we do have a check for that:
>
> + BUILD_BUG_ON(sizeof(*dst) % SMP_CACHE_BYTES != 0);
>
> And task_struct is allocated cache-aligned, which means when we do this
> in fpu_clone():
>
> + struct fpu *dst_fpu = (void *)dst + sizeof(*dst);
>
> the FPU pointer is guaranteed to be cacheline aligned as well.
>
> 'dst' in that context is the new task_struct.
>
> BTW., Oleg suggested in a previous discussion for us to replace the
> task->thread.fpu pointer with a build-time calculation - but I'm still
> not sure it's a good idea.
To be honest, I forgot everything we discussed before ;)
But I have found this email,
https://lore.kernel.org/all/20240616105550.GA18292@redhat.com/
Perhaps
#define X86_TASK_SIZE \
ALIGN(sizeof(struct task_struct), __alignof__(union fpregs_state))
and
#define x86_task_fpu(task) \
((struct fpu *)((void *)(task) + X86_TASK_SIZE))
plus a bit more similar changes make more sense than
__attribute__ ((aligned (64))) for struct task_struct?
OK, even if yes, we can do this later on top of this series.
I'll try to read it tomorrow.
Oleg.
Powered by blists - more mailing lists