From nobody Tue Mar 01 17:41:55 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 2D5A019DC313; Tue, 1 Mar 2022 17:41:56 +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 4K7Ph35rBgz4ZTZ; Tue, 1 Mar 2022 17:41:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646156515; 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=kogc+2Tfos1CAAPD2UhiloD+3rtKgBn2h0D9ZxshMoA=; b=iMOspkjVa6WwVPcFH7cgN4Dh6kedpWHjXFQSeEFgZ7fEF8CoGNPDtrb5mrMVPV4u6KPLBf LL2cekS5GXfbjzGrICvKuj2fuFRO4u928PxoEQt6J06g9VH2j1l+wP+Eb2juMmV49Dx5Ta 4RJZTuveZ/vK22PjkvT9DAurEfNxjF5nDIy8y7fgm5IQLLQ+Q4tnLwdGtwz0vOZjRjb+6z 0MJXyPe3bi1UlLN8KKB+Yxa81a5H0RagyqaUp3ZzCgHeH7TUNS0lECZch/8Ncvd6iQvs3C Vie6cyyhmgWTF4Yb+nhxGa9sAO9yGbbTjs4YeesbO4B89rkI5ydh8uyRlhXh7g== 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 9E6A714111; Tue, 1 Mar 2022 17:41:55 +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 221HftGn093304; Tue, 1 Mar 2022 17:41:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 221Hftwu093303; Tue, 1 Mar 2022 17:41:55 GMT (envelope-from git) Date: Tue, 1 Mar 2022 17:41:55 GMT Message-Id: <202203011741.221Hftwu093303@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 12fb39ec3e6b - main - 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/main X-Git-Reftype: branch X-Git-Commit: 12fb39ec3e6bc529feff3ba2862c6a4a30bd54eb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646156515; 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=kogc+2Tfos1CAAPD2UhiloD+3rtKgBn2h0D9ZxshMoA=; b=FGlGCI9SprHkHlziQkFgqW/NidK/UT5FEZt/OcySQRsx8GOumSC2+MSHVhNymSaldYP+In EoxtAOyHcmQm9XKvQv5rkS9tK+JuKAfwRH41X+eQJIpqHGy2M/hHjYtPofuocXFlF1VNRx /m/7Vvj6X/8VgG866wcf7RQ/5sGXVYIP1b3qPjDVd00ODwvhtW86RZmHeqGydWyZuU9ZUP LFAMHg1+MezMmcfRj09BvC5YgeVBaYtbCy0L88js1q8emLe2pBzzJF3oDq3cJsAQsoWuE7 Yfdg2k5KCkwnr2IQ85WDO+EZwXDWXCmqyexbbL/nowECNyFippyMwKTOQYlOSg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646156515; a=rsa-sha256; cv=none; b=ujCxh1JRQD56wzWKikXDxGMBpMgAM894HMrt8U4zb6VwKA/dUZ9knkyRyCsjjHQYZPxjNb Lrh/ZpnTI1RdvSLUmUk/PdEC4VU4fpoYh68KtQmEj0ASm7Lia80BBvI5XswZtBvc0LBsNY JUHmaRsUFJzX2lNVtg8OY1x5UcsvzOp6VuhYt0/1q/yuYtXr+9c07KtxeoTCGBK3cL2xp9 cjKK71c2fDdNzFV0/bagHcyUlnDnJ1EUfE+qFPUUDmUvTuur7tRkNIi/lC4rU7gqwZ7o+Z 2UTdq9n4fZZRZGFjqx8rZqdGv1aIc2478gCfAxGmLXWVMxPmG4cfGaugqAUuYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=12fb39ec3e6bc529feff3ba2862c6a4a30bd54eb commit 12fb39ec3e6bc529feff3ba2862c6a4a30bd54eb Author: Mark Johnston AuthorDate: 2022-03-01 16:48:39 +0000 Commit: Mark Johnston CommitDate: 2022-03-01 17:40:35 +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. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- 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 582bff962f1a..8d8c5a1d34ff 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -336,11 +336,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); /*