From patchwork Mon Feb 29 12:58:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 589939 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 542E31402BF for ; Tue, 1 Mar 2016 00:02:20 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753005AbcB2NCA (ORCPT ); Mon, 29 Feb 2016 08:02:00 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36304 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753260AbcB2M6r (ORCPT ); Mon, 29 Feb 2016 07:58:47 -0500 Received: by mail-wm0-f65.google.com with SMTP id l68so8091141wml.3; Mon, 29 Feb 2016 04:58:46 -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=cfvQdyGvie6EX9jYmyAhg/vDbiIua1Sn5VpeQ+JMM6w=; b=DAMes3hgqTW9aaMx7z1Kcuyw2DG6JsrKN95UneT34Hwoy9d1Od7sNwwX4AAF2rCche WXcxCamhU/LqRmGpvt+ydm/8jR7FGMqmyCIvmDqGAWNuTl0RA3kiBFBbblg6tZuAFi/c X59pzcYetq8ujR6JQ+AI3FGwVZbIVENnc8acjKoqVmkxDE80W2CXUy4I4Qu1h1MofhSu LhNbAGgHpAuy3Eh0OsrJhHchc3JDN9KNth4NNJ15Mb6sOTWXLQbCNFKcRf07/fRU+Mzc QXMgyKFb8SQuMVYdpfFjOLbfl+58ZhXszxVog7lx4dKmOm28sqTLkJd9oS7CwxNFrGtU TVlQ== X-Gm-Message-State: AD7BkJLyPDz91ULq2125p6AjqOXSMy0A2Uqt083GN8PEZ5dRTemOM4R5+ndtNT3L3VqEfg== X-Received: by 10.28.227.213 with SMTP id a204mr12303002wmh.2.1456750725413; Mon, 29 Feb 2016 04:58:45 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Feb 2016 04:58:44 -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 09/11] xtensa, rwsem: provide __down_write_killable Date: Mon, 29 Feb 2016 13:58:23 +0100 Message-Id: <1456750705-7141-10-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: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org 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;