From patchwork Fri Apr 1 11:04:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 8722801 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 24C3E9F39A for ; Fri, 1 Apr 2016 11:07:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 453E3201FA for ; Fri, 1 Apr 2016 11:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A6312012D for ; Fri, 1 Apr 2016 11:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759211AbcDALHc (ORCPT ); Fri, 1 Apr 2016 07:07:32 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36765 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758813AbcDALFO (ORCPT ); Fri, 1 Apr 2016 07:05:14 -0400 Received: by mail-wm0-f67.google.com with SMTP id 20so3686042wmh.3; Fri, 01 Apr 2016 04:05:12 -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=DL40CyJhA0wWBq77bQIJh7ranJROBXELPlOG0DkZI2w=; b=hBKJSJvOOE/fgF+srHT0QZNuTMltWr88lCszvn6bmQaI5tnPT/GIY41qcVgM+EQi/a IY6erL5GlgrFrdvidrqTe4/krr9OHfrHhhwFFagRFRLRJVr76QmHHjwdDzDCrhjYgPtb Nh80Wyd8w0o3/6PBN6SNM3j/01gSGAZXgeMTyqt+SMtktbCyciQJjJWqGaDIy9Msa908 Oodf8N/z7uruVLgrQjY5v2wm3quCdEqBNbc+AAuduRX/v4dANNJP153mN/UleWQx5e9p XbajRDBz/nChF9v9XKcBQ9ATCn49VguN13QxkWtBT8Xyb4z8Fq0i6mnFlUr0w87xOCen QazA== X-Gm-Message-State: AD7BkJLN8i+U6P21D0wPy1d2sm9fMcWDV1uhBwc2sHQqZDLaB7yIqwweXCVWtmD7zx2i1Q== X-Received: by 10.28.36.85 with SMTP id k82mr3042573wmk.65.1459508711992; Fri, 01 Apr 2016 04:05:11 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 04:05:11 -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 06/11] s390, rwsem: provide __down_write_killable Date: Fri, 1 Apr 2016 13:04:50 +0200 Message-Id: <1459508695-14915-7-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: 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=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/s390/include/asm/rwsem.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/rwsem.h b/arch/s390/include/asm/rwsem.h index 8e52e72f3efc..8e7b2b7e10f3 100644 --- a/arch/s390/include/asm/rwsem.h +++ b/arch/s390/include/asm/rwsem.h @@ -90,7 +90,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem) /* * lock for writing */ -static inline void __down_write(struct rw_semaphore *sem) +static inline long ___down_write(struct rw_semaphore *sem) { signed long old, new, tmp; @@ -104,10 +104,25 @@ static inline void __down_write(struct rw_semaphore *sem) : "=&d" (old), "=&d" (new), "=Q" (sem->count) : "Q" (sem->count), "m" (tmp) : "cc", "memory"); - if (old != 0) + + return old; +} + +static inline void __down_write(struct rw_semaphore *sem) +{ + if (___down_write(sem)) rwsem_down_write_failed(sem); } +static inline int __down_write_killable(struct rw_semaphore *sem) +{ + if (___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 */