From patchwork Tue Feb 2 20:19:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 8195441 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 7DA23BEEE5 for ; Tue, 2 Feb 2016 20:22:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A475B202BE for ; Tue, 2 Feb 2016 20:22:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BDD94202B8 for ; Tue, 2 Feb 2016 20:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965747AbcBBUUj (ORCPT ); Tue, 2 Feb 2016 15:20:39 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33034 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933491AbcBBUTo (ORCPT ); Tue, 2 Feb 2016 15:19:44 -0500 Received: by mail-wm0-f67.google.com with SMTP id r129so4062133wmr.0; Tue, 02 Feb 2016 12:19:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G77HllpQMpK1AvGuHhgpz2taAocOJRu434TzJbi7cio=; b=VmrSzLrgmqThUerG99SPyK0vMzg5K7vtUAhk+Jq0o+6+UAoJrHS8O9TOgEJ5t4YQ7U eK32l3fnzNNpHniZuum6MTgFJWCu2sYe6KA1laKer+KWwVRFYwOBSNwPVuEZ2q95/Cke Xla0SygoyXus5Bl8nUUjPRZvGPA7lZfeh7KhHSOW2OrRocW6QqcPJGCKiQ/eZBjVcvtf fMslkPIOpFFKoQX+R45ZN+PqY3DTjkeXydBIuMgVYRuCpUSKtkXqOUkZeCgSGZHAFfrL BLSAEffotZk4fJPK/4hagSHAmXnmCFvi+IoUuZtROQmm4vfBRCqnGhvfMn1Q5RIz1K9n 4Lfw== X-Gm-Message-State: AG10YOSz3V+OB+PrLkajQFoEBPgywTiPzu6nGtgNFuLzfW54p7jlDA4b45oYfF94ko0viw== X-Received: by 10.28.227.6 with SMTP id a6mr19501815wmh.68.1454444382758; Tue, 02 Feb 2016 12:19:42 -0800 (PST) Received: from tiehlicka.suse.cz (ip-86-49-65-8.net.upcbroadband.cz. [86.49.65.8]) by smtp.gmail.com with ESMTPSA id l7sm3099511wjx.14.2016.02.02.12.19.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Feb 2016 12:19:42 -0800 (PST) From: Michal Hocko To: LKML Cc: 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, Michal Hocko Subject: [RFC 04/12] alpha, rwsem: provide __down_write_killable Date: Tue, 2 Feb 2016 21:19:21 +0100 Message-Id: <1454444369-2146-5-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454444369-2146-1-git-send-email-mhocko@kernel.org> References: <1454444369-2146-1-git-send-email-mhocko@kernel.org> 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.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Michal Hocko Introduce ___down_write for the fast path and reuse it for __down_write resp. __down_write_killable each using the respective generic slow path (rwsem_down_write_failed resp. rwsem_down_write_failed_killable). Signed-off-by: Michal Hocko --- arch/alpha/include/asm/rwsem.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/alpha/include/asm/rwsem.h b/arch/alpha/include/asm/rwsem.h index a83bbea62c67..0131a7058778 100644 --- a/arch/alpha/include/asm/rwsem.h +++ b/arch/alpha/include/asm/rwsem.h @@ -63,7 +63,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem) return res >= 0 ? 1 : 0; } -static inline void __down_write(struct rw_semaphore *sem) +static inline long ___down_write(struct rw_semaphore *sem) { long oldcount; #ifndef CONFIG_SMP @@ -83,10 +83,24 @@ static inline void __down_write(struct rw_semaphore *sem) :"=&r" (oldcount), "=m" (sem->count), "=&r" (temp) :"Ir" (RWSEM_ACTIVE_WRITE_BIAS), "m" (sem->count) : "memory"); #endif - if (unlikely(oldcount)) + return oldcount; +} + +static inline void __down_write(struct rw_semaphore *sem) +{ + if (unlikely(___down_write(sem))) rwsem_down_write_failed(sem); } +static inline int __down_write_killable(struct rw_semaphore *sem) +{ + if (unlikely(___down_write(sem))) + if (IS_ERR(rwsem_down_write_failed_killable(sem))) + return -EINTR; + + return 0; +} + /* * trylock for writing -- returns 1 if successful, 0 if contention */