From nobody Tue Mar 15 16:26:39 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BA81A1A27F33; Tue, 15 Mar 2022 16:26:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KHzLl4tNgz4lvV; Tue, 15 Mar 2022 16:26:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647361599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WPH0XUVqWnuQp82N122T7bCk1aQYY8M2gxccwhBqciI=; b=F1vcUWQKmYCc6xC5c5/sPMYNAiqs4GHGWGRUETv24wXf57fId9pyLrLB11eYEe7VZ65KrV UyXW8+qPh9/Ao82rgLERfK3MgQAr10q0IJtWOgoKOxCvptsCyv1WvjGLaoV/xNgQQGFV6j KS3zwFpzZ+5mzrv1J7kBVKK/JhUHjN4HLkPPuq2a05MGRFeWoSzXPEJxVQrkrFzF23/NJ4 vxiYKvBK4/fH8EtVPpQUvsRgNbTFk9fgMU/lJU6e9ewX5sXL3s/XC9s5WRQKCJEpqSkbky asz8+4/PMZl/c+lSkZaY2LPDlFHz9pYRBgHkPaiMGUqGbVSCjem5VLO5RK7RSw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8366A251FD; Tue, 15 Mar 2022 16:26:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22FGQdxo024794; Tue, 15 Mar 2022 16:26:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22FGQdc3024793; Tue, 15 Mar 2022 16:26:39 GMT (envelope-from git) Date: Tue, 15 Mar 2022 16:26:39 GMT Message-Id: <202203151626.22FGQdc3024793@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 76dcbd770d7b - stable/13 - proc: Relax proc_rwmem()'s assertion on the process hold count List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 76dcbd770d7b1e37e3fe14472d9f339b9180ebd8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647361599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WPH0XUVqWnuQp82N122T7bCk1aQYY8M2gxccwhBqciI=; b=PpRpnZlG5dWWDhwpMt47AhPsgb/tPAv/S0jnBmO4JMlHSh+PX14K5bv88y3KFaEMwbs2CW PE+Q/7BAL1pQLo16NnAvviZZas0wYZqRIPAoMxX1nntjPsrY5GRZP4Z0NxBGfaG4m7K2BL bpCYyeYedUKF/mIval+C8DcUUtXCwQPEgFpQjMHroreG9j+oPwcZKAwwecpZ4IxcvYtUsS 0YaNf4LSeh5F8vJfUIpsMk841DJShu7vjK4W08yvToPnnveZTPMDKd+pe02mUckW8aax3v sre2riT+Q1BC9bRG9zzsNAiYycIBBKScp65wGtAAT9TMNfBuYgiYajagZoOQ/g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647361599; a=rsa-sha256; cv=none; b=qOw3DQesferuwsoYPQk9iBlXEFvaOaj157DGwhi6RbIwfYNqK0Zqz0v3X8O9aMi7WJTiT5 TvD29qHNLFmZZchiM7JjZ25rvBUc2zc3DNfX1Bdl/m0T2SSn3maM50OsjyB0AFXgy0rfaV HNEL5W5AEU7pEW601cZoLmUxGEgg5hecsmkvOGIHmoqT+ga257+0Tfy/o115DC/R4cxWst 2MNZWmwTHK4PMA/8qu8/6tNNWKDwOSxXmP/HZZz0ue4E2tYSMT/og5D9JvDcVuJoDRz3Zr m/pQyk6XSJcPBXaILpmAqB7BNKQBA7Feqcuyg0YuxSHE5wSQC8FobdpY4CtG2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=76dcbd770d7b1e37e3fe14472d9f339b9180ebd8 commit 76dcbd770d7b1e37e3fe14472d9f339b9180ebd8 Author: Mark Johnston AuthorDate: 2022-03-01 16:48:39 +0000 Commit: Mark Johnston CommitDate: 2022-03-15 15:39:55 +0000 proc: Relax proc_rwmem()'s assertion on the process hold count This reference ensures that the process and its associated vmspace will not be destroyed while proc_rwmem() is executing. If, however, the calling thread belongs to the target process, then it is unnecessary to hold the process. In particular, fasttrap - a module which enables userspace dtrace - may frequently call proc_rwmem(), and we'd prefer to avoid the overhead of locking and bumping the hold count when possible. Thus, make the assertion conditional on "p != curproc". Also assert that the process is not already exiting. No functional change intended. Sponsored by: The FreeBSD Foundation (cherry picked from commit 12fb39ec3e6bc529feff3ba2862c6a4a30bd54eb) --- sys/kern/sys_process.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 1b9c00179bda..273adca19a0d 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -215,11 +215,12 @@ proc_rwmem(struct proc *p, struct uio *uio) int error, fault_flags, page_offset, writing; /* - * Assert that someone has locked this vmspace. (Should be - * curthread but we can't assert that.) This keeps the process - * from exiting out from under us until this operation completes. + * Make sure that the process' vmspace remains live. */ - PROC_ASSERT_HELD(p); + if (p != curproc) + PROC_ASSERT_HELD(p); + KASSERT((p->p_flag & P_WEXIT) == 0, + ("%s: process %p is exiting", __func__, p)); PROC_LOCK_ASSERT(p, MA_NOTOWNED); /*