From owner-svn-src-all@freebsd.org Mon Jun 10 19:01:55 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 58D8915C6885; Mon, 10 Jun 2019 19:01:55 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F1FBB88A30; Mon, 10 Jun 2019 19:01:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CE5AD1E6AA; Mon, 10 Jun 2019 19:01:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5AJ1su1002585; Mon, 10 Jun 2019 19:01:54 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5AJ1ssW002584; Mon, 10 Jun 2019 19:01:54 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201906101901.x5AJ1ssW002584@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 10 Jun 2019 19:01:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348874 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 348874 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: F1FBB88A30 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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: Mon, 10 Jun 2019 19:01:55 -0000 Author: jhb Date: Mon Jun 10 19:01:54 2019 New Revision: 348874 URL: https://svnweb.freebsd.org/changeset/base/348874 Log: Remove an overly-aggressive assertion. While it is true that the new vmspace passed to vmspace_switch_aio will always have a valid reference due to the AIO job or the extra reference on the original vmspace in the worker thread, it is not true that the old vmspace being switched away from will have more than one reference. Specifically, when a process with queued AIO jobs exits, the exit hook in aio_proc_rundown will only ensure that all of the AIO jobs have completed or been cancelled. However, the last AIO job might have completed and woken up the exiting process before the worker thread servicing that job has switched back to its original vmspace. In that case, the process might finish exiting dropping its reference to the vmspace before the worker thread resulting in the worker thread dropping the last reference. Reported by: np Reviewed by: alc, markj, np, imp MFC after: 2 weeks Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D20542 Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Mon Jun 10 18:19:49 2019 (r348873) +++ head/sys/vm/vm_map.c Mon Jun 10 19:01:54 2019 (r348874) @@ -454,18 +454,17 @@ vmspace_acquire_ref(struct proc *p) /* * Switch between vmspaces in an AIO kernel process. * - * The AIO kernel processes switch to and from a user process's - * vmspace while performing an I/O operation on behalf of a user - * process. The new vmspace is either the vmspace of a user process - * obtained from an active AIO request or the initial vmspace of the - * AIO kernel process (when it is idling). Because user processes - * will block to drain any active AIO requests before proceeding in - * exit() or execve(), the vmspace reference count for these vmspaces - * can never be 0. This allows for a much simpler implementation than - * the loop in vmspace_acquire_ref() above. Similarly, AIO kernel - * processes hold an extra reference on their initial vmspace for the - * life of the process so that this guarantee is true for any vmspace - * passed as 'newvm'. + * The new vmspace is either the vmspace of a user process obtained + * from an active AIO request or the initial vmspace of the AIO kernel + * process (when it is idling). Because user processes will block to + * drain any active AIO requests before proceeding in exit() or + * execve(), the reference count for vmspaces from AIO requests can + * never be 0. Similarly, AIO kernel processes hold an extra + * reference on their initial vmspace for the life of the process. As + * a result, the 'newvm' vmspace always has a non-zero reference + * count. This permits an additional reference on 'newvm' to be + * acquired via a simple atomic increment rather than the loop in + * vmspace_acquire_ref() above. */ void vmspace_switch_aio(struct vmspace *newvm) @@ -490,9 +489,6 @@ vmspace_switch_aio(struct vmspace *newvm) /* Activate the new mapping. */ pmap_activate(curthread); - /* Remove the daemon's reference to the old address space. */ - KASSERT(oldvm->vm_refcnt > 1, - ("vmspace_switch_aio: oldvm dropping last reference")); vmspace_free(oldvm); }