From patchwork Wed Apr 13 12:49:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 8822231 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 438DFC0553 for ; Wed, 13 Apr 2016 12:50:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 46C3F2025B for ; Wed, 13 Apr 2016 12:50:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE97D20375 for ; Wed, 13 Apr 2016 12:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760405AbcDMMt4 (ORCPT ); Wed, 13 Apr 2016 08:49:56 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33652 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760367AbcDMMtx (ORCPT ); Wed, 13 Apr 2016 08:49:53 -0400 Received: by mail-wm0-f65.google.com with SMTP id y144so13661971wmd.0; Wed, 13 Apr 2016 05:49:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=YOWoBdAeU38WmZ0O5bTaTHDevdfZ685cZ2UIk2f3VJM=; b=V9u4ZHJm83iWZ9SPNGMny0bsyeliGsgvSKnddIfp08qP42JEH0nBczwZ43kOnWcHl1 /+IG8SJ77v0Em0eeI4z0ei6bn7rQkWqQgPEXyRrcMKorgoz0NLN9PvCUyvI3gZOpfgVN VdgU0HBdJJ9v7ArCq1bigNI/1Dy45E/SF3rfR8/9gCTQxDD2cbm0PpuytJ0gFIH9BeMv wZfKlOMSYkJpS26FlGo2BGFZu0fcS56vvcgPOlPFoG6VIr/9c6mYvUMq83tS8NPQqc7+ 0o1lze/pfTbSFUmfbjOjKo898JN+OwWZrbJvJ1EZw9JTSrs36WVJgFrhyg+P+l2tXqrs Z+cw== X-Gm-Message-State: AOPr4FVOUMiZQKYAfHNr0bIURMZAS1MlaSGNlF8oX3vsn/lKoVDpf9tDNiB486j0D27eew== X-Received: by 10.194.166.228 with SMTP id zj4mr9071355wjb.99.1460551785320; Wed, 13 Apr 2016 05:49:45 -0700 (PDT) Received: from localhost (nat1.scz.suse.com. [213.151.88.250]) by smtp.gmail.com with ESMTPSA id kq9sm38532850wjc.26.2016.04.13.05.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Apr 2016 05:49:44 -0700 (PDT) Date: Wed, 13 Apr 2016 14:49:43 +0200 From: Michal Hocko To: Ingo Molnar Cc: LKML , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , "David S. Miller" , Tony Luck , Andrew Morton , Chris Zankel , Max Filippov , x86@kernel.org, linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org, Josh Poimboeuf Subject: Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Message-ID: <20160413124943.GH14351@dhcp22.suse.cz> References: <1460041951-22347-1-git-send-email-mhocko@kernel.org> <1460041951-22347-11-git-send-email-mhocko@kernel.org> <20160413090829.GB29579@gmail.com> <20160413091625.GF14351@dhcp22.suse.cz> <20160413091943.GA17858@gmail.com> <20160413102731.GA29896@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160413102731.GA29896@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed 13-04-16 12:27:31, Ingo Molnar wrote: > > * Ingo Molnar wrote: > > > I'm testing your patches today, if they are otherwise OK [...] > > got this build failure: > > ./arch/x86/include/asm/rwsem.h:106:2: error: ‘asm’ operand has impossible constraints Hmm, I have no idea why 64b didn't have problem with the asm but 32b complains. Anyway, the following makes both happy. I have checked the generated code for 64b and it hasn't changed after the patch. 32b also seems to be generating a proper code. My gcc asm()-foo is rather weak so I would feel better if somebody double checked after me. --- From d23f4e6994670bf2c5d864f2190f21022b4499b2 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Wed, 13 Apr 2016 14:21:25 +0200 Subject: [PATCH] x86: __down_read_trylock fix 32b build failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ingo has noticed the following compilation error with CONFIG_X86_32=y ./arch/x86/include/asm/rwsem.h:106:2: error: ‘asm’ operand has impossible constraints The reason seems to be that 32b doesn't like ret being input and output argument sharing the same register with sem which is only the input. Fix this by making ret output only and use %3 (aka sem) for xadd. ret initialization is not needed now because this is done implicitly by the asm even for the fast path as both sem and ret share the same register. Reported-by: Ingo Molnar Signed-off-by: Michal Hocko --- arch/x86/include/asm/rwsem.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h index d759c5f70f49..453744c1d347 100644 --- a/arch/x86/include/asm/rwsem.h +++ b/arch/x86/include/asm/rwsem.h @@ -102,9 +102,9 @@ static inline int __down_read_trylock(struct rw_semaphore *sem) #define ____down_write(sem, slow_path) \ ({ \ long tmp; \ - struct rw_semaphore* ret = sem; \ + struct rw_semaphore* ret; \ asm volatile("# beginning down_write\n\t" \ - LOCK_PREFIX " xadd %1,(%2)\n\t" \ + LOCK_PREFIX " xadd %1,(%3)\n\t" \ /* adds 0xffff0001, returns the old value */ \ " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t" \ /* was the active mask 0 before? */\ @@ -112,7 +112,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem) " call " slow_path "\n" \ "1:\n" \ "# ending down_write" \ - : "+m" (sem->count), "=d" (tmp), "+a" (ret) \ + : "+m" (sem->count), "=d" (tmp), "=a" (ret) \ : "a" (sem), "1" (RWSEM_ACTIVE_WRITE_BIAS) \ : "memory", "cc"); \ ret; \