From patchwork Thu Apr 7 15:12:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 8774081 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 8DA719F36E for ; Thu, 7 Apr 2016 15:28:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6EAB20251 for ; Thu, 7 Apr 2016 15:28:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C37A32020F for ; Thu, 7 Apr 2016 15:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756508AbcDGP21 (ORCPT ); Thu, 7 Apr 2016 11:28:27 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35362 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751964AbcDGP2Y (ORCPT ); Thu, 7 Apr 2016 11:28:24 -0400 Received: by mail-wm0-f67.google.com with SMTP id a140so22296781wma.2; Thu, 07 Apr 2016 08:28:23 -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=NY7IXGvaU5qftTknQBtsgk3EIZ7m2smVGG7Ogx79Y1Y=; b=aIih8KxUUy7rV/VldJR9W9oFOnPEMrlEuADzMT7x9xPCX4Z2ZVBhKM4yOwxhlwSE2S rxdY4zpyIjo8GxNICu6Y+uXWKE4TRHg9w7Ms8eIvYeQFyQ6e//28qpCYhBOf7UtcviIR o797v5y2D1BBMhlBWtGtZ0WcsaTWCZd3DOd5DRbNjxKZByz26SNGFIaPYfWOidQD0AUB ZG2kVhPRFzBJLgnHsrOz/YZro9dTal5x1WP/5R02hZyTzAsoLg6sv+AC+heUMo3YqwQE fO983cg8K7mGbylPlCqplWRl94WF82lUv+gAD32317ELpJVIhLMRlp6JuPpQt7KC7Xq2 7EoQ== X-Gm-Message-State: AD7BkJI3BnOSXI/k5JU0lx1AhEYaZQOMgS6/8xzwh44f20jSteLsakvAjnvR/BiIkf2uVw== X-Received: by 10.28.138.193 with SMTP id m184mr16490927wmd.100.1460041969764; Thu, 07 Apr 2016 08:12:49 -0700 (PDT) Received: from tiehlicka.suse.cz (nat1.scz.suse.com. [213.151.88.250]) by smtp.gmail.com with ESMTPSA id ks5sm8995472wjb.13.2016.04.07.08.12.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Apr 2016 08:12:49 -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 08/11] ia64, rwsem: provide __down_write_killable Date: Thu, 7 Apr 2016 17:12:28 +0200 Message-Id: <1460041951-22347-9-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1460041951-22347-1-git-send-email-mhocko@kernel.org> References: <1460041951-22347-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/ia64/include/asm/rwsem.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/ia64/include/asm/rwsem.h b/arch/ia64/include/asm/rwsem.h index 3027e7516d85..5e78cb40d9df 100644 --- a/arch/ia64/include/asm/rwsem.h +++ b/arch/ia64/include/asm/rwsem.h @@ -49,8 +49,8 @@ __down_read (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) { long old, new; @@ -59,10 +59,26 @@ __down_write (struct rw_semaphore *sem) new = old + RWSEM_ACTIVE_WRITE_BIAS; } while (cmpxchg_acq(&sem->count, old, new) != old); - 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; +} + /* * unlock after reading */