From nobody Sun Feb 13 13:07:17 2022 X-Original-To: dev-commits-src-main@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 63BA119BC665; Sun, 13 Feb 2022 13:07:18 +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 4JxSLY6Zs7z3JCk; Sun, 13 Feb 2022 13:07:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644757638; 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=CQ/9bJD7XXATxbvBfTnLmooTG7rq13x1nfj90UzgW7o=; b=au72M3bt8kjSvX1YZjBwGNhjS2EA3KzBMP/BaijUPJlOgPCFBVqfSKWdWfbpqX1E7XvIfB sduZ4b/iebLMAlKPnUcTbXWUHO1CgwTTQkDWiJInMqaGxI7eFFJxElVmWc5YMgwLjNj5jL AfdK3qARTY2xd+4gMNDOwRfiOyavJ7QQ9+j9+P2YPrR5gYmsR9Kx3uuKSWfg+2nV50ZVfH jFm7YUe8COYvhB1eaNg8F5SKF8hzGyTIeuKfvYolP83F7ysadVKwb0WXbP/WiB6LRya068 0i+A/o5pzEBXowhyl1OUscoJrldicHKALJMoU7Da7+ftWPNMmR7QkXxDHRA4dQ== 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 7843A1BAB1; Sun, 13 Feb 2022 13:07:17 +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 21DD7H8j073984; Sun, 13 Feb 2022 13:07:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21DD7H46073983; Sun, 13 Feb 2022 13:07:17 GMT (envelope-from git) Date: Sun, 13 Feb 2022 13:07:17 GMT Message-Id: <202202131307.21DD7H46073983@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 893d20c95ade - main - fd: move fd table sizing out of fdinit List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 893d20c95ade6ae4b6a514bb003457ce8f2959fd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644757638; 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=CQ/9bJD7XXATxbvBfTnLmooTG7rq13x1nfj90UzgW7o=; b=uta7j9JzinZP8eCjPGhgr7aN1Kj5hLYGFqEfXfMJ3YONzf93DsFGOh5losw5DcIsZuzFHI fTgEiAH/aQoQs0F5KzTvWqW0ljqJvKqQmgSSnUtPSbZoAxH5+cWUCvZQ5SfYcyJ/Xc9CA0 uk1SGCBDKl87j3mome/RLbOSuXJseBNuoxj2Gdx2DPQZJp+X5UOrHHAO4QY69tOB+iXRRW sX0iiIsIH3/LBaAurkL+d5bl+Kz5vYhcOGeDhD7edhCcD277JT0Ksg1cMg8mitC1yO9l2G mYn0Qm+of0Keaj5BJ+ytb6Vx6MXT3KhowIf+f0xO/Lc+wJ8AS9elAT8/BIz5Mg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644757638; a=rsa-sha256; cv=none; b=lbE0iauwHWDN9OsoT0xVXFMiLIZ5X2MiIbSr8cYJrdypI5tq/UABSxIxpSGT0IyQoi6tYq 1Dk/RtBDcYG9y2lx8wT6vlnYJqiiHJk/A3xILVv2OvDksAABM3ZcVcTBOcydVWd41t0pDW jZNg32KTmVxGsbK7mx/crFW4085isUCIBLt8IpDymj3elPpxHBRnv0uw8tzGk3tbSmjIDl K/E+dsM4pzk/TXFr28t6ZcUqpFdOMq+RjUVc1D5tNqHjD3+iDGHqK9NBHz3GqiCgmqJSCb Jo3h102NEb80C/vVBB5QcRyfihPKgBq5OAH4yxiw2xGInelmDr3/IXZiN/Weag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=893d20c95ade6ae4b6a514bb003457ce8f2959fd commit 893d20c95ade6ae4b6a514bb003457ce8f2959fd Author: Mateusz Guzik AuthorDate: 2022-01-29 22:07:06 +0000 Commit: Mateusz Guzik CommitDate: 2022-02-13 13:07:08 +0000 fd: move fd table sizing out of fdinit now it is placed with the rest of actual initialisation --- sys/kern/init_main.c | 2 +- sys/kern/kern_descrip.c | 36 +++++++++++------------------------- sys/kern/kern_fork.c | 4 ++-- sys/sys/filedesc.h | 2 +- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 5ab9eed6a114..2225c5ed95d5 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -568,7 +568,7 @@ proc0_init(void *dummy __unused) /* Create the file descriptor table. */ p->p_pd = pdinit(NULL, false); - p->p_fd = fdinit(NULL, false, NULL); + p->p_fd = fdinit(); p->p_fdtol = NULL; /* Create the limits structures. */ diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index bf4a3a3f20e5..1dc0f1e647d6 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2150,16 +2150,11 @@ finstall(struct thread *td, struct file *fp, int *fd, int flags, * If fdp is not NULL, return with it shared locked. */ struct filedesc * -fdinit(struct filedesc *fdp, bool prepfiles, int *lastfile) +fdinit(void) { struct filedesc0 *newfdp0; struct filedesc *newfdp; - if (prepfiles) - MPASS(lastfile != NULL); - else - MPASS(lastfile == NULL); - newfdp0 = uma_zalloc(filedesc0_zone, M_WAITOK | M_ZERO); newfdp = &newfdp0->fd_fd; @@ -2171,24 +2166,6 @@ fdinit(struct filedesc *fdp, bool prepfiles, int *lastfile) newfdp->fd_files = (struct fdescenttbl *)&newfdp0->fd_dfiles; newfdp->fd_files->fdt_nfiles = NDFILE; - if (fdp == NULL) - return (newfdp); - - FILEDESC_SLOCK(fdp); - if (!prepfiles) { - FILEDESC_SUNLOCK(fdp); - return (newfdp); - } - - for (;;) { - *lastfile = fdlastfile(fdp); - if (*lastfile < newfdp->fd_nfiles) - break; - FILEDESC_SUNLOCK(fdp); - fdgrowtable(newfdp, *lastfile + 1); - FILEDESC_SLOCK(fdp); - } - return (newfdp); } @@ -2368,7 +2345,16 @@ fdcopy(struct filedesc *fdp) MPASS(fdp != NULL); - newfdp = fdinit(fdp, true, &lastfile); + newfdp = fdinit(); + FILEDESC_SLOCK(fdp); + for (;;) { + lastfile = fdlastfile(fdp); + if (lastfile < newfdp->fd_nfiles) + break; + FILEDESC_SUNLOCK(fdp); + fdgrowtable(newfdp, lastfile + 1); + FILEDESC_SLOCK(fdp); + } /* copy all passable descriptors (i.e. not kqueue) */ newfdp->fd_freefile = -1; for (i = 0; i <= lastfile; ++i) { diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index a6d83fc8049d..0062f7419ac0 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -340,7 +340,7 @@ fork_norfproc(struct thread *td, int flags) struct filedesc *fdtmp; struct pwddesc *pdtmp; pdtmp = pdinit(td->td_proc->p_pd, false); - fdtmp = fdinit(td->td_proc->p_fd, false, NULL); + fdtmp = fdinit(); pdescfree(td); fdescfree(td); p1->p_fd = fdtmp; @@ -418,7 +418,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * */ if (fr->fr_flags & RFCFDG) { pd = pdinit(p1->p_pd, false); - fd = fdinit(p1->p_fd, false, NULL); + fd = fdinit(); fdtol = NULL; } else if (fr->fr_flags & RFFDG) { if (fr->fr_flags2 & FR2_SHARE_PATHS) diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 7d106adb756f..0560a517c160 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -254,7 +254,7 @@ void fdunshare(struct thread *td); void fdescfree(struct thread *td); int fdlastfile(struct filedesc *fdp); int fdlastfile_single(struct filedesc *fdp); -struct filedesc *fdinit(struct filedesc *fdp, bool prepfiles, int *lastfile); +struct filedesc *fdinit(void); struct filedesc *fdshare(struct filedesc *fdp); struct filedesc_to_leader * filedesc_to_leader_alloc(struct filedesc_to_leader *old,