From owner-svn-src-all@freebsd.org Tue Jul 30 23:13:05 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44131AF8C2; Tue, 30 Jul 2019 23:13:05 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B1C0D8525C; Tue, 30 Jul 2019 23:13:04 +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 x6UNCu9G026200 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 31 Jul 2019 02:12:59 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x6UNCu9G026200 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x6UNCuBY026199; Wed, 31 Jul 2019 02:12:56 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 31 Jul 2019 02:12:56 +0300 From: Konstantin Belousov To: Bryan Drewery Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r350005 - head/sys/kern Message-ID: <20190730231256.GL2731@kib.kiev.ua> References: <201907151918.x6FJIPFo077975@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jul 2019 23:13:05 -0000 On Tue, Jul 30, 2019 at 03:04:57PM -0700, Bryan Drewery wrote: > On 7/15/2019 12:18 PM, Konstantin Belousov wrote: > > Author: kib > > Date: Mon Jul 15 19:18:25 2019 > > New Revision: 350005 > > URL: https://svnweb.freebsd.org/changeset/base/350005 > > > > Log: > > In do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on retry. > > > > Is this also needed in do_sem_wait()? A similar pattern seems to be there. No, I do not think do_sem_wait() has similar issue, because the again label does not re-get the key. > > I ask because of what I referenced on IRC. I have some processes stuck > in here from a 10.4 jail. > > > ~/git/poudriere # procstat -kk 1498 > > PID TID COMM TDNAME KSTACK > > 1498 100710 python2.7 - mi_switch+0x174 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101 > > 1498 101575 python2.7 - mi_switch+0x174 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101 > > 1498 101657 python2.7 - > ... > > ~/git/poudriere # procstat -kk 1498 > > PID TID COMM TDNAME KSTACK > > 1498 100710 python2.7 - mi_switch+0x174 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101 > > 1498 101575 python2.7 - mi_switch+0x174 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101 > > 1498 101657 python2.7 - do_sem_wait+0x1b6 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101 > ... > > ~/git/poudriere # procstat -kk 94392 > > PID TID COMM TDNAME KSTACK > > 94392 101815 python2.7 - mi_switch+0x174 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101 > > 94392 101816 python2.7 - __mtx_lock_sleep+0x118 __mtx_lock_flags+0x102 _sleep+0x334 umtxq_busy+0xb7 do_sem_wait+0x161 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101 > > 94392 102076 python2.7 - __mtx_lock_flags+0x94 do_sem_wait+0x228 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101 Try this. We should only retry casueword if it failed spuriously. diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index bb998457975..6c914ab6f3e 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -3229,7 +3229,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, struct _umtx_time *timeout) rv = casueword32(&sem->_has_waiters, 0, &count1, 1); if (rv == 0) rv1 = fueword32(&sem->_count, &count); - if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) || rv == 1) { + if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) || + (rv == 1 && count1 == 0)) { umtxq_lock(&uq->uq_key); umtxq_unbusy(&uq->uq_key); umtxq_remove(uq);