From patchwork Mon Feb 29 12:58: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: 8453481 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 CEA2C9F52D for ; Mon, 29 Feb 2016 12:59:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D14FB202FF for ; Mon, 29 Feb 2016 12:59:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F4153202F2 for ; Mon, 29 Feb 2016 12:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753833AbcB2M7A (ORCPT ); Mon, 29 Feb 2016 07:59:00 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33332 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753054AbcB2M6p (ORCPT ); Mon, 29 Feb 2016 07:58:45 -0500 Received: by mail-wm0-f68.google.com with SMTP id n186so9934455wmn.0; Mon, 29 Feb 2016 04:58: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=S+47XacdoQND8B1SuVBddQo9n+zw2vv6FsgU8/ZNuMs=; b=HnhY7A7QXBbh2p3n8OiXkCUBMGXtbEuLEAIyUz2Nmz1fTQPql/07YabSHN94UnQl5G NteOOQ0x6VHnu7zYvySkeeF4z/8yHWp1QD5fj1uLu5N1N/2zofs4JZRm+ABamObFOSG9 cLq5RH2BHYGKztuiiL55zhFs7WzXcNNohGyzwUVuOdHk+UIqmPW9AW8SO0bUUGkLej7i YeDNvkK2bQVj5S0Ao3vPzsINSTo71ateGg5xIU2ATlP4cW8FYYsVFhBoknNjbHgd2YsW lohrsalmst99bPjE+jyX5qjX+Ncjw9MUejdwr8wTkx6/bIZWRahklkNpMkxUuciBuPjG cEwA== X-Gm-Message-State: AD7BkJK27wwFzAobamoTsGBlwD3fRn8FWnuwlI1cbp3mPdfgrPU91/ZwzZt9y6E6vcDokQ== X-Received: by 10.28.88.15 with SMTP id m15mr11062774wmb.60.1456750722560; Mon, 29 Feb 2016 04:58:42 -0800 (PST) Received: from tiehlicka.suse.cz (bband-dyn69.95-103-50.t-com.sk. [95.103.50.69]) by smtp.gmail.com with ESMTPSA id lh1sm25728400wjb.20.2016.02.29.04.58.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Feb 2016 04:58: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: [PATCH 07/11] sh, rwsem: provide __down_write_killable Date: Mon, 29 Feb 2016 13:58:21 +0100 Message-Id: <1456750705-7141-8-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456750705-7141-1-git-send-email-mhocko@kernel.org> References: <1456750705-7141-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=-6.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 which uses the same fast path as __down_write except it falls back to rwsem_down_write_failed_killable slow path and return -EINTR if killed. Signed-off-by: Michal Hocko --- arch/sh/include/asm/rwsem.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/sh/include/asm/rwsem.h b/arch/sh/include/asm/rwsem.h index f6c951c7a875..8a457b83d2a5 100644 --- a/arch/sh/include/asm/rwsem.h +++ b/arch/sh/include/asm/rwsem.h @@ -54,6 +54,19 @@ static inline void __down_write(struct rw_semaphore *sem) rwsem_down_write_failed(sem); } +static inline int __down_write_killable(struct rw_semaphore *sem) +{ + int tmp; + + tmp = atomic_add_return(RWSEM_ACTIVE_WRITE_BIAS, + (atomic_t *)(&sem->count)); + if (tmp != RWSEM_ACTIVE_WRITE_BIAS) + if (IS_ERR(rwsem_down_write_failed_killable(sem))) + return -EINTR; + + return 0; +} + static inline int __down_write_trylock(struct rw_semaphore *sem) { int tmp;