RE: [PATCH] MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +	/* Avoid inadvertently triggering emulation */
> +	if ((value & PR_FP_MODE_FR) && cpu_has_fpu &&
> +	    !(current_cpu_data.fpu_id & MIPS_FPIR_F64))
> +		return -EOPNOTSUPP;
> +	if ((value & PR_FP_MODE_FRE) && !cpu_has_fre)
> +		return -EOPNOTSUPP;

This is perhaps not important immediately but these two cases can
be seen as inconsistent. I.e. FR1 is emulated if there is no FPU
but FRE is not emulated if there is no FPU.

I believe this would be more consistent:

	if ((value & PR_FP_MODE_FRE) && cpu_has_fpu &&
	    !cpu_has_fre)
		return -EOPNOTSUPP;

The kernel then freely emulates any requested mode when there is
no FPU but sticks to only true hardware modes when there is an FPU.

= More detailed discussion =

There has been debate internally at IMG over the issue of FPU emulation
so I think it is appropriate to comment on why emulation is not always
desirable according to the new o32 FP ABI extensions. I'll try to be
brief...

The simple reason is that it is obviously better to use a true hardware
FPU mode whenever possible. Most of the o32 hard-float ABI variants
can execute in multiple hardware modes and the glibc dynamic linker
will probe to find the best supported hardware mode by trying them:

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mips/dl-machine-reject-phdr.h;h=b277450c4d02088acb8f24c74cea6ce04783688f;hb=0bd956720c457ff054325b48f26ac7c91cb060e8#l286

If an FPU exists but an emulated mode is used rather than a
true hardware mode then the code will run slower than necessary.

The second aspect to avoiding emulated modes is that users may
have multiple versions of an object available each with different
ABI extensions. If one fails to load then the next one may succeed
with a true hardware-supported mode.

With all that in mind I suspect we can find a balance (in a later
update) that may be able to balance the desire for emulation against
the desire for using real hardware modes. As it stands there is no
clear-cut answer or spec for this so I am in agreement with the
overall behaviour of this patch, perhaps with the tweak applied.

thanks,
Matthew




[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux