Update Linux kernel to current glibc soft-fp

Message ID mg89bp$dht$1@ger.gmane.org
State Not applicable
Headers

Commit Message

Stefan Liebler April 10, 2015, 10:40 a.m. UTC
  On 04/02/2015 07:44 PM, Joseph Myers wrote:
> On Thu, 26 Mar 2015, Stefan Liebler wrote:
>
>> According to "error: lvalue required as left operand of assignment":
>> Why did you write back r in include/math-emu/op-common.h:
>> #define _FP_FROM_INT(fs, wc, X, r, rsize, rtype):
>> 	  if ((X##_s = ((r) < 0)))
>> 	    (r) = -(rtype) (r);
>> 	  _FP_FROM_INT_ur = (rtype) (r);
>
> Because the _FP_FROM_INT interface requires an argument of the correct
> signedness, but needs to work internally on an unsigned value, so starts
> by negating a signed argument.
>
>> @@ -435,11 +436,12 @@ void s390_adjust_jiffies(void)
>>   		 * by the cpu capability number. Yes, that means a floating
>>   		 * point division .. math-emu here we come :-)
>>   		 */
>> -		FP_UNPACK_SP(SA, &fmil);
>> -		if ((info->capability >> 23) == 0)
>> -			FP_FROM_INT_S(SB, (long) info->capability, 64, long);
>> -		else
>> -			FP_UNPACK_SP(SB, &info->capability);
>> +		FP_UNPACK_SEMIRAW_SP(SA, &fmil);
>> +		if ((info->capability >> 23) == 0) {
>> +			unsigned long r = info->capability;
>> +			FP_FROM_INT_S(SB, r, 64, unsigned long);
>> +		} else
>> +			FP_UNPACK_SEMIRAW_SP(SB, &info->capability);
>>   		FP_DIV_S(SR, SA, SB);
>>   		FP_TO_INT_S(capability, SR, 32, 0);
>
> Division uses cooked inputs and outputs.  FP_TO_INT uses raw inputs.
> FP_FROM_INT uses raw outputs.
>
> So for unpacking SA you should continue to use FP_UNPACK_SP, as the result
> goes straight into division.  For unpacking SB, it seems appropriate to
> use FP_UNPACK_RAW_SP.  Then, after either unpacking or FP_FROM_INT_S, you
> have a raw value in SB, and can use _FP_UNPACK_CANONICAL to produce a
> cooked value from it that can be used as an input to the division.
>
> As for the integer argument to FP_FROM_INT_S, the existing code treats it
> as signed long, so the same semantics would be preserved by making the
> temporary variable of that type (however, you still need to pass "unsigned
> long" as the last argument to FP_FROM_INT_S, as it expects the type name
> passed to be the name of an unsigned type).
>
Thanks for this information.

I applied your patch from 23.03.2015 to linux-next without the removed 
file arch/s390/math-emu/math.c, adjusted s390_adjust_jiffies() method in 
arch/s390/kernel/sysinfo.c (see attached patch) and build and booted the 
new kernel.
The value "bogomips per cpu" in /proc/cpuinfo is equal to this value 
without these patches.

Bye Stefan
  

Patch

diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
index 99babea..f963474 100644
--- a/arch/s390/kernel/sysinfo.c
+++ b/arch/s390/kernel/sysinfo.c
@@ -418,6 +418,7 @@  void s390_adjust_jiffies(void)
 	FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR);
 	FP_DECL_EX;
 	unsigned int capability;
+	int mode = 0;
 
 	info = (void *) get_zeroed_page(GFP_KERNEL);
 	if (!info)
@@ -436,11 +437,15 @@  void s390_adjust_jiffies(void)
 		 * point division .. math-emu here we come :-)
 		 */
 		FP_UNPACK_SP(SA, &fmil);
-		if ((info->capability >> 23) == 0)
-			FP_FROM_INT_S(SB, (long) info->capability, 64, long);
+		if ((info->capability >> 23) == 0) {
+			long r = info->capability;
+			FP_FROM_INT_S(SB, r, 64, unsigned long);
+		}
 		else
-			FP_UNPACK_SP(SB, &info->capability);
+			FP_UNPACK_RAW_SP(SB, &info->capability);
+		_FP_UNPACK_CANONICAL(S, 1, SB);
 		FP_DIV_S(SR, SA, SB);
+		_FP_PACK_CANONICAL(S, 1, SR);
 		FP_TO_INT_S(capability, SR, 32, 0);
 	} else
 		/*