Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752765AbbKBJnM (ORCPT ); Mon, 2 Nov 2015 04:43:12 -0500 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:47857 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752541AbbKBJnL (ORCPT ); Mon, 2 Nov 2015 04:43:11 -0500 Subject: Re: [PATCH v1 05/20] ARC: rwlock: disable interrupts in !LLSC variant To: Noam Camus , References: <1446297327-16298-1-git-send-email-noamc@ezchip.com> <1446297327-16298-6-git-send-email-noamc@ezchip.com> CC: , , , , Peter Zijlstra Newsgroups: gmane.linux.kernel,gmane.linux.kernel.arc From: Vineet Gupta Message-ID: <56373019.6080501@synopsys.com> Date: Mon, 2 Nov 2015 15:12:49 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1446297327-16298-6-git-send-email-noamc@ezchip.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.12.197.182] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3489 Lines: 112 On Saturday 31 October 2015 06:45 PM, Noam Camus wrote: > From: Noam Camus > > If we hold rw->lock_mutex and interrupt occures we may > end up spinning on it for ever during softirq. > > Below you may see an example for interrupt we get while > nl_table_lock is holding its rw->lock_mutex and we spinned > on it for ever. > > The concept for the fix was taken from SPARC. > > [2015-05-12 19:16:12] Stack Trace: > [2015-05-12 19:16:12] arc_unwind_core+0xb8/0x11c > [2015-05-12 19:16:12] dump_stack+0x68/0xac > [2015-05-12 19:16:12] _raw_read_lock+0xa8/0xac > [2015-05-12 19:16:12] netlink_broadcast_filtered+0x56/0x35c > [2015-05-12 19:16:12] nlmsg_notify+0x42/0xa4 > [2015-05-12 19:16:13] neigh_update+0x1fe/0x44c > [2015-05-12 19:16:13] neigh_event_ns+0x40/0xa4 > [2015-05-12 19:16:13] arp_process+0x46e/0x5a8 > [2015-05-12 19:16:13] __netif_receive_skb_core+0x358/0x500 > [2015-05-12 19:16:13] process_backlog+0x92/0x154 > [2015-05-12 19:16:13] net_rx_action+0xb8/0x188 > [2015-05-12 19:16:13] __do_softirq+0xda/0x1d8 > [2015-05-12 19:16:14] irq_exit+0x8a/0x8c > [2015-05-12 19:16:14] arch_do_IRQ+0x6c/0xa8 > [2015-05-12 19:16:14] handle_interrupt_level1+0xe4/0xf0 > > Signed-off-by: Noam Camus > Cc: Peter Zijlstra > --- > arch/arc/include/asm/spinlock.h | 14 ++++++++++++++ > 1 files changed, 14 insertions(+), 0 deletions(-) > > diff --git a/arch/arc/include/asm/spinlock.h b/arch/arc/include/asm/spinlock.h > index db8c59d..800e7c4 100644 > --- a/arch/arc/include/asm/spinlock.h > +++ b/arch/arc/include/asm/spinlock.h > @@ -610,7 +610,9 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) > static inline int arch_read_trylock(arch_rwlock_t *rw) > { > int ret = 0; > + unsigned long flags; > > + local_irq_save(flags); > arch_spin_lock(&(rw->lock_mutex)); > > /* > @@ -623,6 +625,7 @@ static inline int arch_read_trylock(arch_rwlock_t *rw) > } > > arch_spin_unlock(&(rw->lock_mutex)); > + local_irq_restore(flags); > > smp_mb(); > return ret; > @@ -632,7 +635,9 @@ static inline int arch_read_trylock(arch_rwlock_t *rw) > static inline int arch_write_trylock(arch_rwlock_t *rw) > { > int ret = 0; > + unsigned long flags; > > + local_irq_save(flags); > arch_spin_lock(&(rw->lock_mutex)); > > /* > @@ -646,6 +651,7 @@ static inline int arch_write_trylock(arch_rwlock_t *rw) > ret = 1; > } > arch_spin_unlock(&(rw->lock_mutex)); > + local_irq_restore(flags); > > return ret; > } > @@ -664,16 +670,24 @@ static inline void arch_write_lock(arch_rwlock_t *rw) > > static inline void arch_read_unlock(arch_rwlock_t *rw) > { > + unsigned long flags; > + > + local_irq_save(flags); > arch_spin_lock(&(rw->lock_mutex)); Isn't raw_spin_lock_irqsave() equivalent and more concise ? > rw->counter++; > arch_spin_unlock(&(rw->lock_mutex)); > + local_irq_restore(flags); > } > > static inline void arch_write_unlock(arch_rwlock_t *rw) > { > + unsigned long flags; > + > + local_irq_save(flags); > arch_spin_lock(&(rw->lock_mutex)); > rw->counter = __ARCH_RW_LOCK_UNLOCKED__; > arch_spin_unlock(&(rw->lock_mutex)); > + local_irq_restore(flags); > } > > #endif > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/