From patchwork Fri Jul 13 17:50:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10523943 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B1F91602A0 for ; Fri, 13 Jul 2018 17:51:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5D9E29EDD for ; Fri, 13 Jul 2018 17:51:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9990429F03; Fri, 13 Jul 2018 17:51:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D3E529EDD for ; Fri, 13 Jul 2018 17:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CATtvaw3AoSykZxrAioVy9KO8Yi+oFNhIolY8laxKDc=; b=MN2RcH/NVgFcPL 2UTuMrYJrULZEfOQMVoWbb10yx9tDSpzZGovA9hvohdrYALz89cg6aIEmGpZHc+Ux/vufotNOucPS YxoZX3Df4z1VYGPpue5gB65Eq5Vsb0WCdtHki+otZHZ6SS5TWSgKDjsfuzmJUsOhq/zAnIyglki0x L+eq+8vMuvV3EHKLiMEa4GPfL8+uEJ93Se09007VuQ3dOK/z52Y7beQR85P+MUDhHnpAzKhS7YGg1 13a3od5U2CApcZ5fURtK+ipeSH/d2M4ULQONBrpDDPRUZvDSP582pyowavnXHJDEhOwVRKsHggTaY X/dJPoDKY3wTOJjuxuuw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fe2Dm-0001kX-3a; Fri, 13 Jul 2018 17:51:10 +0000 Received: from galois.linutronix.de ([2a01:7a0:2:106d:700::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fe2Dh-0001YI-KC for linux-arm-kernel@lists.infradead.org; Fri, 13 Jul 2018 17:51:08 +0000 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1fe2DR-0004jL-JP; Fri, 13 Jul 2018 19:50:49 +0200 Date: Fri, 13 Jul 2018 19:50:49 +0200 From: Sebastian Andrzej Siewior To: Steven Rostedt Subject: [PATCH RT] locallock: add local_lock_bh() Message-ID: <20180713175049.nx2xg4no4zbfcnfl@linutronix.de> References: <20180517124006.ohygrrpg7z2moqqt@linutronix.de> <20180522131004.3012953c@gandalf.local.home> <20180522172115.fpqguqlsq6bavtxy@linutronix.de> <20180522132429.6f1dcf92@gandalf.local.home> <20180522173333.aawadhkcekzvrswp@linutronix.de> <20180711092555.268adf7f@gandalf.local.home> <20180711133157.bvrza5vmthu6lwjd@linutronix.de> <20180711093346.782af07a@gandalf.local.home> <20180713174937.5ddaqpylalcmc3jq@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180713174937.5ddaqpylalcmc3jq@linutronix.de> User-Agent: NeoMutt/20180622 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180713_105105_823625_2F589B23 X-CRM114-Status: UNSURE ( 9.16 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rt-users@vger.kernel.org, Catalin Marinas , Mike Galbraith , Will Deacon , linux-kernel@vger.kernel.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP For the ARM64 simd locking it would be easier to have local_lock_bh() which grabs a local_lock with BH disabled and turns into a local_bh_disable() on !RT. Signed-off-by: Sebastian Andrzej Siewior --- obviously required by the previous oneā€¦ include/linux/locallock.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/linux/locallock.h b/include/linux/locallock.h index 921eab83cd34..15aa0dea2bfb 100644 --- a/include/linux/locallock.h +++ b/include/linux/locallock.h @@ -47,9 +47,23 @@ static inline void __local_lock(struct local_irq_lock *lv) lv->nestcnt++; } +static inline void __local_lock_bh(struct local_irq_lock *lv) +{ + if (lv->owner != current) { + spin_lock_bh(&lv->lock); + LL_WARN(lv->owner); + LL_WARN(lv->nestcnt); + lv->owner = current; + } + lv->nestcnt++; +} + #define local_lock(lvar) \ do { __local_lock(&get_local_var(lvar)); } while (0) +#define local_lock_bh(lvar) \ + do { __local_lock_bh(&get_local_var(lvar)); } while (0) + #define local_lock_on(lvar, cpu) \ do { __local_lock(&per_cpu(lvar, cpu)); } while (0) @@ -88,12 +102,29 @@ static inline void __local_unlock(struct local_irq_lock *lv) spin_unlock(&lv->lock); } +static inline void __local_unlock_bh(struct local_irq_lock *lv) +{ + LL_WARN(lv->nestcnt == 0); + LL_WARN(lv->owner != current); + if (--lv->nestcnt) + return; + + lv->owner = NULL; + spin_unlock_bh(&lv->lock); +} + #define local_unlock(lvar) \ do { \ __local_unlock(this_cpu_ptr(&lvar)); \ put_local_var(lvar); \ } while (0) +#define local_unlock_bh(lvar) \ + do { \ + __local_unlock_bh(this_cpu_ptr(&lvar)); \ + put_local_var(lvar); \ + } while (0) + #define local_unlock_on(lvar, cpu) \ do { __local_unlock(&per_cpu(lvar, cpu)); } while (0) @@ -253,6 +284,8 @@ static inline void local_irq_lock_init(int lvar) { } #define local_lock(lvar) preempt_disable() #define local_unlock(lvar) preempt_enable() +#define local_lock_bh(lvar) local_bh_disable() +#define local_unlock_bh(lvar) local_bh_enable() #define local_lock_irq(lvar) local_irq_disable() #define local_lock_irq_on(lvar, cpu) local_irq_disable() #define local_unlock_irq(lvar) local_irq_enable()