From owner-svn-src-head@freebsd.org Tue Sep 3 14:06:45 2019 Return-Path: Delivered-To: svn-src-head@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 AA35CDCE22; Tue, 3 Sep 2019 14:06:42 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N7zk0g4Hz4PpT; Tue, 3 Sep 2019 14:06:42 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id BBA141AA42; Tue, 3 Sep 2019 14:06:14 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id CAC907D76; Thu, 11 Apr 2019 17:51:32 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 310917072E; Thu, 11 Apr 2019 17:51:32 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 11A887D5F; Thu, 11 Apr 2019 17:51:32 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id C58B97D5B; Thu, 11 Apr 2019 17:51:29 +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 061D470724; Thu, 11 Apr 2019 17:51:28 +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 x3BHpKF1092990 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 11 Apr 2019 20:51:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x3BHpKF1092990 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x3BHpKrt092989; Thu, 11 Apr 2019 20:51:20 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f From: Konstantin Belousov To: Conrad Meyer Cc: Edward Tomasz Napierala , src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r346120 - head/sys/kern Message-ID: <20190411175120.GX1923@kib.kiev.ua> References: <201904111121.x3BBLj2K023087@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) 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 Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 310917072E X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.989,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Status: O X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Tue, 03 Sep 2019 14:06:45 -0000 X-Original-Date: Thu, 11 Apr 2019 20:51:20 +0300 X-List-Received-Date: Tue, 03 Sep 2019 14:06:45 -0000 On Thu, Apr 11, 2019 at 08:59:14AM -0700, Conrad Meyer wrote: > Hi Edward, > > I have a question about this change below. > > On Thu, Apr 11, 2019 at 4:22 AM Edward Tomasz Napierala > wrote: > > > > Author: trasz > > Date: Thu Apr 11 11:21:45 2019 > > New Revision: 346120 > > URL: https://svnweb.freebsd.org/changeset/base/346120 > > > > Log: > > Use shared vnode locks for the ELF interpreter. > > > > ... > > Differential Revision: https://reviews.freebsd.org/D19874 > > ... > > Modified: head/sys/kern/imgact_elf.c > > ============================================================================== > > --- head/sys/kern/imgact_elf.c Thu Apr 11 08:06:45 2019 (r346119) > > +++ head/sys/kern/imgact_elf.c Thu Apr 11 11:21:45 2019 (r346120) > > ... > > - NDINIT(nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_SYSSPACE, file, curthread); > > + flags = FOLLOW | LOCKSHARED | LOCKLEAF; > > + > > +again: > > + NDINIT(nd, LOOKUP, flags, UIO_SYSSPACE, file, curthread); > > if ((error = namei(nd)) != 0) { > > ... > > @@ -759,15 +762,30 @@ __elfN(load_file)(struct proc *p, const char *file, u_ > > ... > > + if (VOP_IS_TEXT(nd->ni_vp) == 0) { > > + if (VOP_ISLOCKED(nd->ni_vp) != LK_EXCLUSIVE) { > > + /* > > + * LK_UPGRADE could have resulted in dropping > > + * the lock. Just try again from the start, > > + * this time with exclusive vnode lock. > > + */ > > + vput(nd->ni_vp); > > + flags &= ~LOCKSHARED; > > + goto again; > > It's unclear to me why we don't attempt LK_UPGRADE first. If upgrade > succeeds, we avoid an extra filesystem traversal (namei/lookup). If > it fails, of course we can 'goto again' the same as we do > unconditionally here. LK_UPGRADE drops the vnode lock, this was discussed in the phab review. Perhaps you can do LK_TRYUPGRADE first, by the cost of even more complicated code then was in the initial review, if fixed. > > There was some discussion about the topic in the linked phabricator PR > with Konstantin, but I did not follow it fully. > > On the one hand, perhaps VOP_IS_TEXT() is rarely false for common > interpreters anyway. On the other hand, there is sort of a > renaissance of static linking happening. Statically linked binaries do not need interpreter. > So maybe the thought is, > !VOP_IS_TEXT is likely to be rare, and LK_UPGRADE success even more > rare, so why bother writing additional code for it? I do not understand the question. > > Thanks, > Conrad > > P.S., It is orthogonal to this discussion, but I don't see any reason > for VOP_IS_TEXT to be a vnode_if operation. Neither it, nor > VOP_UNSET_TEXT, is ever specialized. They simply check or clear the > VV_TEXT flag on the vnode's vflags, respectively. It is common for > the kernel to reach out and interact with other vnode vflags directly; > e.g., pretty much all other VV_flags, like VV_ROOT. The only > specialization of VOP_SET_TEXT is NFSclient, and it is unclear to me > why the same requirements NFS client has for setting VV_TEXT do not > apply universally. VOP is bypassed, unlike direct vnode flags access. As result, when you execute file on nullfs, VV_TEXT is set on the lower vnode, instead of the upper nullfs vnode. If lower vnode is not marked by VV_TEXT, EBUSY does not work. This was described in the commit log where VOPs were introduced.