From patchwork Fri Apr 1 11:04:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 8722741 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 21E80C0553 for ; Fri, 1 Apr 2016 11:07:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 44414202C8 for ; Fri, 1 Apr 2016 11:06:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 663C8201FA for ; Fri, 1 Apr 2016 11:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755367AbcDALGk (ORCPT ); Fri, 1 Apr 2016 07:06:40 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33883 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758895AbcDALFR (ORCPT ); Fri, 1 Apr 2016 07:05:17 -0400 Received: by mail-wm0-f68.google.com with SMTP id p65so3712875wmp.1; Fri, 01 Apr 2016 04:05:16 -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=pH1AzD9ebgmA3K+HTW3GI3z00kIG712N4TrkFqS4/ak=; b=NuLHJuedgMQt3uze3oSXnsVBeiqvqihZ3c6Mtgi0/3uNQ+Duc3JT7th7J0XOJjsAiO Iig/Ku8MMjeBkmEdPPza45LDxLGKAnpCo2PbCqYKHa9JUsIOz98lVkYU2Im97XW6rsQs 9Mf99qvdbAGZnyj4mJHykmWTbF/YfEHepXB9ovtLwCXRfLDnBkSx8EWaiZ1LCk96UM7p Foo7MwZAteXXAwHi507Q5nQWAXbwieC+9Cmo1Y7W4i1Opo/lOdu0nftUS1on+s7g6JhE s1fRL75qJ+27L4QzAhB0AAxReIKeD5BgEF0PFSVQoa9kevXzaB7kYy343B0MKncckLff GklA== X-Gm-Message-State: AD7BkJI/S3kO1JkrS3UBBsFtnoX8xIK8JU8kZigorpa3bsIVmSich6j8DgRS4JBwykxMPQ== X-Received: by 10.28.210.141 with SMTP id j135mr3416208wmg.0.1459508715350; Fri, 01 Apr 2016 04:05:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 04:05:14 -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 09/11] xtensa, rwsem: provide __down_write_killable Date: Fri, 1 Apr 2016 13:04:53 +0200 Message-Id: <1459508695-14915-10-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 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/xtensa/include/asm/rwsem.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/xtensa/include/asm/rwsem.h b/arch/xtensa/include/asm/rwsem.h index 593483f6e1ff..6283823b8040 100644 --- a/arch/xtensa/include/asm/rwsem.h +++ b/arch/xtensa/include/asm/rwsem.h @@ -59,6 +59,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;