From nobody Wed Aug 28 19:12:44 2024 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 4WvDZP12gYz5MZRL; Wed, 28 Aug 2024 19:12:45 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WvDZN4VJfz4pbc; Wed, 28 Aug 2024 19:12:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724872364; 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=A9E43Cr2nfgxnDATDCHpNXgXdqidOW0FMyEinjmOB/s=; b=cqx8sW+M5NZBNVar0JXEmJ65oB8qP6K5pVU0loiJpV0YuRadFVNsmIqzzwQpDH8YYwxCA+ IFtLx0MJnVhbHxsTbvEK2E41QNAemUdgWt+4nVrctC+jHHcaTV3M0ESUY0aST5orBFyUIo sHFWighbB8LXRZA2HrC4DhFKXXymtsWHElSV53seyzO+R5PAraHphpqQtdJMEFYjiwv2wE PTPJVPp/0hj86aZo9UEwj/VH1yGRqSRwT4Hz1yn5zkJbDQOuIh5HjN/E7sCoDTHIowxGSE vem41DyagnNWD2zr3a6O5DIRpVno/ad9OC3PprTnWuh1WPilTrTxEHSRPvRvUg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724872364; a=rsa-sha256; cv=none; b=WqSbQXMIjErl5OQtqcNDT5ylrmtSzgl2QVWMmDTCG5U+IiuAWRS06tRhTpZSQYhpy3S/bp lDjArEL4KU3+AVnIbKhSs4AJ/w4gbs40yt/HdHFP+gYRdSnYgWW8MhBkZWjy458E4uBfVc HaYnLd8G7v1ZHI++0pfDm9ZJTnDpJk0r7r+lot+tFB4TzbjU/EekCSpTS/Tw3QYjsQJkMe OYQ481qWZvFlgmZQWquTwVyc4W+j2IHh7uHTiS4XG6W5eUZ5g3kDEojK98zQ3qPvuH2nLd e8OPe6z20bwmeNDfZIDpoMQJIfWh8C9UNoLbC++oudD1u7NuedwdBlzFPvRtOQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724872364; 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=A9E43Cr2nfgxnDATDCHpNXgXdqidOW0FMyEinjmOB/s=; b=MS/FxdTtfoujVxHcomn1JsrHCmFtWC99YYKnktchLzJbiN8n8b5Lvqx+yO6GjdW4sOuGHP Yzdfw8p5dbBuBI47nZACzDBiZdGLkaXzGv6rkyVmzwqwFIxwkX5n9J8bbrTYyWjNdHUeqz Cv3q4cwdsMKqNboo7kCxOSy4QR5OtB2t+7SAQPmU9n8FLUYJNI/aY8U1w8MGD4BH1acLAh Llubu9CHbeiVL3EIT6neRxGx+goaNMIJjU23XkLCqxSy3kDdU2rjQ8vJcBj4Wd+nYv8FLi dY4v4hWNJfjL1qF4/7d+hxQoQexm2VhF/2xx5cMPBIe3s051nihCKi6LH06Ilw== 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 4WvDZN3r1vzm1d; Wed, 28 Aug 2024 19:12:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47SJCi2E059071; Wed, 28 Aug 2024 19:12:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47SJCiAj059068; Wed, 28 Aug 2024 19:12:44 GMT (envelope-from git) Date: Wed, 28 Aug 2024 19:12:44 GMT Message-Id: <202408281912.47SJCiAj059068@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: f4002135a2be - main - vmm: Remove an unneeded lookup in devmem_create_cdev() 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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: f4002135a2be59272f39f886fb270f5a4736ac08 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f4002135a2be59272f39f886fb270f5a4736ac08 commit f4002135a2be59272f39f886fb270f5a4736ac08 Author: Mark Johnston AuthorDate: 2024-08-28 18:57:21 +0000 Commit: Mark Johnston CommitDate: 2024-08-28 18:57:21 +0000 vmm: Remove an unneeded lookup in devmem_create_cdev() The sole caller of this function already holds a pointer to the VM's softc, so rather than passing the VM name and looking it up again, just pass the softc pointer directly. This function is only called from an ioctl context, so the softc structure will remain live. Reviewed by: corvink, jhb Differential Revision: https://reviews.freebsd.org/D46446 --- sys/dev/vmm/vmm_dev.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sys/dev/vmm/vmm_dev.c b/sys/dev/vmm/vmm_dev.c index 6bdcb51777d4..c42b2aaee5ed 100644 --- a/sys/dev/vmm/vmm_dev.c +++ b/sys/dev/vmm/vmm_dev.c @@ -42,8 +42,6 @@ _Static_assert(sizeof(struct vm_memseg_fbsd12) == 80, "COMPAT_FREEBSD12 ABI"); _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg_fbsd12) #endif -static int devmem_create_cdev(const char *vmname, int id, char *devmem); - struct devmem_softc { int segid; char *name; @@ -73,6 +71,7 @@ static MALLOC_DEFINE(M_VMMDEV, "vmmdev", "vmmdev"); SYSCTL_DECL(_hw_vmm); static void devmem_destroy(void *arg); +static int devmem_create_cdev(struct vmmdev_softc *sc, int id, char *devmem); static int vmm_priv_check(struct ucred *ucred) @@ -287,7 +286,7 @@ alloc_memseg(struct vmmdev_softc *sc, struct vm_memseg *mseg, size_t len) goto done; if (VM_MEMSEG_NAME(mseg)) { - error = devmem_create_cdev(vm_name(sc->vm), mseg->segid, name); + error = devmem_create_cdev(sc, mseg->segid, name); if (error) vm_free_memseg(sc->vm, mseg->segid); else @@ -989,13 +988,15 @@ static struct cdevsw devmemsw = { }; static int -devmem_create_cdev(const char *vmname, int segid, char *devname) +devmem_create_cdev(struct vmmdev_softc *sc, int segid, char *devname) { struct devmem_softc *dsc; - struct vmmdev_softc *sc; struct cdev *cdev; + const char *vmname; int error; + vmname = vm_name(sc->vm); + error = make_dev_p(MAKEDEV_CHECKNAME, &cdev, &devmemsw, NULL, UID_ROOT, GID_WHEEL, 0600, "vmm.io/%s.%s", vmname, devname); if (error) @@ -1004,8 +1005,6 @@ devmem_create_cdev(const char *vmname, int segid, char *devname) dsc = malloc(sizeof(struct devmem_softc), M_VMMDEV, M_WAITOK | M_ZERO); mtx_lock(&vmmdev_mtx); - sc = vmmdev_lookup(vmname); - KASSERT(sc != NULL, ("%s: vm %s softc not found", __func__, vmname)); if (sc->cdev == NULL) { /* virtual machine is being created or destroyed */ mtx_unlock(&vmmdev_mtx);