From owner-freebsd-current@freebsd.org Fri Mar 10 13:57:23 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30BA3D041D6 for ; Fri, 10 Mar 2017 13:57:23 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CD47FAE4 for ; Fri, 10 Mar 2017 13:57:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v2ADvGjN045116 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 10 Mar 2017 15:57:16 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v2ADvGjN045116 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v2ADvGi0045115; Fri, 10 Mar 2017 15:57:16 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 10 Mar 2017 15:57:16 +0200 From: Konstantin Belousov To: Alexandre Martins Cc: freebsd-current Subject: Re: smp_rendezvous_action: Are atomics correctly used ? Message-ID: <20170310135716.GI16105@kib.kiev.ua> References: <2092905.6A8RAGlt18@pc-alex> <3034263.GEZH9i4V44@pc-alex> <20170309142516.GA16105@kib.kiev.ua> <1584060.AQ0HNTQbMq@pc-alex> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1584060.AQ0HNTQbMq@pc-alex> User-Agent: Mutt/1.8.0 (2017-02-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Mar 2017 13:57:23 -0000 On Fri, Mar 10, 2017 at 02:24:52PM +0100, Alexandre Martins wrote: > Le jeudi 9 mars 2017, 16:25:17 Konstantin Belousov a ?crit : > > On Thu, Mar 09, 2017 at 02:52:09PM +0100, Alexandre Martins wrote: > > > Le jeudi 9 mars 2017, 15:07:54 Konstantin Belousov a ?crit : > > > > On Thu, Mar 09, 2017 at 10:59:27AM +0100, Alexandre Martins wrote: > > > > > I have the save question for the cpu_ipi_pending here: > > > > > > > > > > https://svnweb.freebsd.org/base/head/sys/x86/x86/mp_x86.c?view=annotat > > > > > e#l1 > > > > > 080> > > > > > > > > > > Le jeudi 9 mars 2017, 10:43:14 Alexandre Martins a ?crit : > > > > > > Hello, > > > > > > > > > > > > I'm curently reading the code of the function smp_rendezvous_action, > > > > > > in > > > > > > kern/subr_smp.c file. In that function, i see that the variable > > > > > > smp_rv_waiters is read in some while() loop in a non-atomic way. > > > > > > > > > > > > https://svnweb.freebsd.org/base/head/sys/kern/subr_smp.c?view=annota > > > > > > te#l > > > > > > 412 > > > > > > https://svnweb.freebsd.org/base/head/sys/kern/subr_smp.c?view=annota > > > > > > te#l > > > > > > 458 > > > > > > https://svnweb.freebsd.org/base/head/sys/kern/subr_smp.c?view=annota > > > > > > te#l > > > > > > 472 > > > > > > > > > > > > I suspect one of my freeze to be due by that. > > > > > > > > You should provide either evidence or, at least, some reasoning > > > > supporting > > > > your claims. > > > > > > I curently have a software watchdog that triger and does a coredump. In > > > the > > > coredumps, I always see a CPU trying to write-lock a "rm lock". Every > > > time, > > > that CPU is spinning into the smp_rendezvous_action, in the first while > > > loop) while the others are into the idle threads. > > > > > > The fact is that freeze is not clear and I start to search "exotic" causes > > > to explain it. > > > > This sounds as the 'usual' deadlock, where some other thread owns rmlock in > > read mode. I recommend you to follow the > > https://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kernel > > debug-deadlocks.html > > Just a last question, for my personnal knowledge. > > In ARM >= 6, for atomic acces, the code should (?) use LDREX and STREX for, I > quote : "Use LDREX and STREX to implement interprocess communication in > multiple-processor and shared-memory systems." (see here : > http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489e/Cihbghef.html > In my previous response to you, I explicitely defined what 'atomic' means when adjected to the term 'load'. The *EX instructions are used on ll/sc architectures to implement read/modify/write atomic operations, which are different from load (read) operations. > But, in that while loop, it's a standard "LDR" that is used. Is it correct > too, and why ? Which 'that while loop' ? while (atomic_load_acq_int(&smp_rv_waiters[3]) < ncpus) cpu_spinwait(); This one ? Because the semantic of the normal load + DMB barrier provides the expected semantic of atomic_load_acq(), as explained in atomic(9) and utilized by the author of the code.