linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
To: Johannes Berg <johannes@sipsolutions.net>, linux-um@lists.infradead.org
Cc: richard@nod.at
Subject: Re: [PATCH v7] um: Enable preemption in UML
Date: Thu, 28 Mar 2024 14:40:06 +0000	[thread overview]
Message-ID: <8fadcc0e-2587-4628-bfb9-8794ef01cac3@cambridgegreys.com> (raw)
In-Reply-To: <4ffdc415c692236dc13302b5fc0290316a17b7cc.camel@sipsolutions.net>



On 28/03/2024 09:27, Johannes Berg wrote:
> 
>> @@ -23,7 +23,7 @@ struct thread_info {
>>   	int			preempt_count;  /* 0 => preemptable,
>>   						   <0 => BUG */
>>   	struct thread_info	*real_thread;    /* Points to non-IRQ stack */
>> -	unsigned long aux_fp_regs[FP_SIZE];	/* auxiliary fp_regs to save/restore
>> +	unsigned long aux_fp_regs[FP_SIZE] __aligned(64);	/* auxiliary fp_regs to save/restore
>>   						   them out-of-band */
> 
> nit: that comment looks strange now, maybe pull it up before the member?
> 
>   /* auxiliary ... out-of-band */
>   unsigned long aux_fp_regs[...] __aligned(64);
> 

Ack.

> 
>> +#ifdef CONFIG_64BIT
>> +	if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVEOPT)))
>> +		__builtin_ia32_xsaveopt64(&current_thread_info()->aux_fp_regs, KNOWN_387_FEATURES);
>> +	else {
>> +		if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVE)))
>> +			__builtin_ia32_xsave64(&current_thread_info()->aux_fp_regs, KNOWN_387_FEATURES);
>> +		else
>> +			__builtin_ia32_fxsave64(&current_thread_info()->aux_fp_regs);
>> +	}
> 
> Why not write this as a chain?
> 
> 	if (likely(cpu_has(...))
> 		__builtin_ia32_xsaveopt64(...);
> 	else if (likely(cpu_has(...)))
> 		__builtin_ia32_xave64(...);
> 	else
> 		__builtin_ia32_fxsave64(...);
> 
> 
> and IMHO pulling the "&current_thread_info()->aux_fp_regs" that appears
> on all three of them into a local variable would make that more readable
> too.

Ack.

> 
>> +#else
>> +	if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVEOPT)))
>> +		__builtin_ia32_xsaveopt(&current->aux_fp_regs, KNOWN_387_FEATURES);
>> +	else {
>> +		if (likely(cpu_has(&boot_cpu_data, X86_FEATURE_XSAVE)))
>> +			__builtin_ia32_xsave(&current->aux_fp_regs, KNOWN_387_FEATURES);
>> +		else
>> +			__builtin_ia32_fxsave(&current->aux_fp_regs);
>> +	}
>> +#endif
> 
> And all of the above also applies for 32-bit,

Ack.

> 
>> +void kernel_fpu_end(void)
> 
> and this as well.
> 
> johannes
> 
> 

Will fix, rebase, retest and resubmit.

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


      reply	other threads:[~2024-03-28 14:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28  9:10 [PATCH v7] um: Enable preemption in UML anton.ivanov
2023-09-28  9:12 ` Anton Ivanov
2024-03-28  9:27 ` Johannes Berg
2024-03-28 14:40   ` Anton Ivanov [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=8fadcc0e-2587-4628-bfb9-8794ef01cac3@cambridgegreys.com \
    --to=anton.ivanov@cambridgegreys.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-um@lists.infradead.org \
    --cc=richard@nod.at \
    /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).