From patchwork Fri Apr 1 11:04:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 604713 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qbzC55zs9z9t3b for ; Fri, 1 Apr 2016 22:08:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759014AbcDALIS (ORCPT ); Fri, 1 Apr 2016 07:08:18 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35098 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758618AbcDALFM (ORCPT ); Fri, 1 Apr 2016 07:05:12 -0400 Received: by mail-wm0-f65.google.com with SMTP id 139so3699206wmn.2; Fri, 01 Apr 2016 04:05:10 -0700 (PDT) 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=/t2JSK8v0AcPodN82ULGU7J0gqFNEcQb+mDGLyLmpeo=; b=UaQul7wCP3w9tSccOEzna9JACdzukmfA0ZtF+F6WCxPIQc9iCbFqKCKtGBnNevLzH8 v5Uup8TJsk/spN9K+LPNLU6DdRpPSCRcyXIv8h53Tk9qbIwmORh7gF54BP0v1hQ/T6Pg gEqVL39qrAMaZs1hAfmjbSLqHvJKf+rXTpS/+rWWFZGzUO4ZXHbgciRS1JAF/vZW0YwT 68Wy6AGamPOCMqmU4amoVgfnXgU7oo2RkerHjIia60J67xbF6TKZZv8AY7a8wRRzUUP9 1+0BxLVWty6zWvrFtwQtWXuybbSLOroYneJmtvOWAEPjtbgx47JGta9uWHY04Wr9jPTR WPEA== X-Gm-Message-State: AD7BkJIGwIrWqT7w60laocZoJHsVCjiwLMYw//I5MZgamBd1Gxf52LsRWkG2HjoMNfquNw== X-Received: by 10.28.23.75 with SMTP id 72mr3271004wmx.50.1459508709932; Fri, 01 Apr 2016 04:05:09 -0700 (PDT) Received: from tiehlicka.suse.cz (nat1.scz.suse.com. [213.151.88.250]) by smtp.gmail.com with ESMTPSA id ys9sm13434670wjc.35.2016.04.01.04.05.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 04:05:09 -0700 (PDT) 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: [PATCH 04/11] alpha, rwsem: provide __down_write_killable Date: Fri, 1 Apr 2016 13:04:48 +0200 Message-Id: <1459508695-14915-5-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1459508695-14915-1-git-send-email-mhocko@kernel.org> References: <1459508695-14915-1-git-send-email-mhocko@kernel.org> Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org 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 */