Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp22020imm; Thu, 30 Aug 2018 07:26:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ6z/mQ7giECBZ7bGzATZlHNIAo4xz4S2ncvUXof/ZqSIRqJkTL+uqSSPdUCbq/MkX8GUi3 X-Received: by 2002:a17:902:ba86:: with SMTP id k6-v6mr10215255pls.84.1535639197848; Thu, 30 Aug 2018 07:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535639197; cv=none; d=google.com; s=arc-20160816; b=YJ7lzzHEZEC6gpDjUMzzLnVxRWNA7oKjwAl1PScknNRuSS/gneOli4zXjyg31ED9Jv qGym0Dr7MHd0VFUBXn5Rn1vd0umcNvhFpLZQuGGPtRrzYiLs9MCwsC7B11lxXzCeKKfr nL61IjULBqeWERcDDKA0wouq6b2dBByiYqkgVGfsT6fBLFnJ13fGW/O2H8U06ZSxZx18 D453/6nUhNWpW4tE/THhz/ZE39JPNxAsch8Gvc55ZExo9C7WTwA5CGAJGPpuXgmUHEVR aMuoGvboHvl4JZ50mxmquEOdBHqiW7Q/ryj2mjYj1Zdx93c4PtX602s6+86iXWi+0wE/ uwhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=f82X9RHrhbpqQ+Lgy//acha1ch7mZzJab7SGC3sk7uQ=; b=Mmx4ymfXqCv2pXMB3oJAOeq2155OUhk17y9MWxkkGckRJc/wX3GeMcgAAi39zM+Ov5 Ab1l3NXYaw/ssNzgAxiVUkT/aaLZS/k0mGnnPOGhnm7vroqEn0QyAcQUfPPPwYjNtNh+ lxlrxuvZqWEjQaI7DFz7VrXFyZiB1Reo/b/7ce6+0muvOA7q+x5/lPUu2Vcq1CvADBxZ 4bU9mlwkuGcxtA9CgnbWZ4vQeeybX3tGH2frvxBrcShfNx1AVN39BSk6DVm8/k74Tcot haVpRe+Z4KOT9Y2bZKzVDDemPgr8LWiG9p6Y+2fH3nYO1i1ouLeku4S+lkxQw5sLTfap 4UuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a65-v6si6638042pge.694.2018.08.30.07.26.22; Thu, 30 Aug 2018 07:26:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729330AbeH3S0H (ORCPT + 99 others); Thu, 30 Aug 2018 14:26:07 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:42432 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728990AbeH3S0G (ORCPT ); Thu, 30 Aug 2018 14:26:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0EC0A7A9; Thu, 30 Aug 2018 07:23:43 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D39CD3F5BC; Thu, 30 Aug 2018 07:23:42 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 1E4761AE3490; Thu, 30 Aug 2018 15:23:55 +0100 (BST) Date: Thu, 30 Aug 2018 15:23:55 +0100 From: Will Deacon To: Peter Zijlstra Cc: Eugeniy Paltsev , "mingo@kernel.org" , "linux-kernel@vger.kernel.org" , "Alexey.Brodkin@synopsys.com" , "Vineet.Gupta1@synopsys.com" , "tglx@linutronix.de" , "linux-snps-arc@lists.infradead.org" , "yamada.masahiro@socionext.com" , "linux-arm-kernel@lists.infradead.org" , "linux-arch@vger.kernel.org" Subject: Re: Patch "asm-generic/bitops/lock.h: Rewrite using atomic_fetch_" causes kernel crash Message-ID: <20180830142354.GB13005@arm.com> References: <1535567633.4465.23.camel@synopsys.com> <20180830094411.GX24124@hirez.programming.kicks-ass.net> <20180830095148.GB5942@arm.com> <1535629996.4465.44.camel@synopsys.com> <20180830141713.GN24082@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180830141713.GN24082@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 30, 2018 at 04:17:13PM +0200, Peter Zijlstra wrote: > On Thu, Aug 30, 2018 at 11:53:17AM +0000, Eugeniy Paltsev wrote: > > I can see crashes with LLSC enabled in both SMP running on 4 cores > > and SMP running on 1 core. > > So you're running on LL/SC enabled hardware; that would make Will's > patch irrelevant (although still a good idea for the hardware that does > care about that spinlocked atomic crud). Yeah, that's a good point. I think the !LLSC case is broken without my patch, so we're looking at two bugs... > Does something like the below cure things? That would confirm the > suggestion that the change to __clear_bit_unlock() is the curprit. > > If that doesn't cure things, then we've been looking in entirely the > wrong place. Yes, that would be worth trying. However, I also just noticed that the fetch-ops (which are now used to implement test_and_set_bit_lock()) seem to be missing the backwards branch in the LL/SC case. Yet another diff below. Will --->8 diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h index 4e0072730241..f06c5ed672b3 100644 --- a/arch/arc/include/asm/atomic.h +++ b/arch/arc/include/asm/atomic.h @@ -84,7 +84,7 @@ static inline int atomic_fetch_##op(int i, atomic_t *v) \ "1: llock %[orig], [%[ctr]] \n" \ " " #asm_op " %[val], %[orig], %[i] \n" \ " scond %[val], [%[ctr]] \n" \ - " \n" \ + " bnz 1b \n" \ : [val] "=&r" (val), \ [orig] "=&r" (orig) \ : [ctr] "r" (&v->counter), \