Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756305AbZKMPJc (ORCPT ); Fri, 13 Nov 2009 10:09:32 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756261AbZKMPJU (ORCPT ); Fri, 13 Nov 2009 10:09:20 -0500 Received: from mtagate2.de.ibm.com ([195.212.17.162]:59734 "EHLO mtagate2.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755887AbZKMPJC (ORCPT ); Fri, 13 Nov 2009 10:09:02 -0500 Message-Id: <20091113150910.350086040@de.ibm.com> User-Agent: quilt/0.48-1 Date: Fri, 13 Nov 2009 16:08:31 +0100 From: Martin Schwidefsky To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Cc: Heiko Carstens , Matthew Wilcox , Martin Schwidefsky Subject: [patch 07/52] [PATCH] Improve code generated by atomic operations. References: <20091113150824.351347652@de.ibm.com> Content-Disposition: inline; filename=106-atomic-volatile.diff Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2641 Lines: 69 From: Martin Schwidefsky Git commit ea435467500612636f8f4fb639ff6e76b2496e4b changed the definition of atomic_t and atomic64_t for s390 by adding the volatile modifier to the counter field. This has an unfortunate side effect with newer versions of the gcc. The typeof operator now picks up the volatile modifier from the expression. This causes the compiler to think that it has to store the two temporary variable old_val and new_val in the __CS_LOOP for the different atomic operations to the stack as the variables are now volatile. Both stores are superfluous. The hack to replace typeof(ptr->counter) with int in __CS_LOOP and and long long in __CSG_LOOP avoids the two stores. A better solution would be to drop the volatile from the counter field of the atomic_t and atomic64_t definition. But that is a touchy subject .. Cc: Matthew Wilcox Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/atomic.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Index: quilt-2.6/arch/s390/include/asm/atomic.h =================================================================== --- quilt-2.6.orig/arch/s390/include/asm/atomic.h 2009-11-13 15:48:32.000000000 +0100 +++ quilt-2.6/arch/s390/include/asm/atomic.h 2009-11-13 16:08:13.000000000 +0100 @@ -21,7 +21,7 @@ #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2) #define __CS_LOOP(ptr, op_val, op_string) ({ \ - typeof(ptr->counter) old_val, new_val; \ + int old_val, new_val; \ asm volatile( \ " l %0,%2\n" \ "0: lr %1,%0\n" \ @@ -38,7 +38,7 @@ #else /* __GNUC__ */ #define __CS_LOOP(ptr, op_val, op_string) ({ \ - typeof(ptr->counter) old_val, new_val; \ + int old_val, new_val; \ asm volatile( \ " l %0,0(%3)\n" \ "0: lr %1,%0\n" \ @@ -143,7 +143,7 @@ #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2) #define __CSG_LOOP(ptr, op_val, op_string) ({ \ - typeof(ptr->counter) old_val, new_val; \ + long long old_val, new_val; \ asm volatile( \ " lg %0,%2\n" \ "0: lgr %1,%0\n" \ @@ -160,7 +160,7 @@ #else /* __GNUC__ */ #define __CSG_LOOP(ptr, op_val, op_string) ({ \ - typeof(ptr->counter) old_val, new_val; \ + long long old_val, new_val; \ asm volatile( \ " lg %0,0(%3)\n" \ "0: lgr %1,%0\n" \ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/