From nobody Fri Feb 11 13:58:00 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 0447519B0520; Fri, 11 Feb 2022 13:58:01 +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 4JwFZ05NGWz3sgc; Fri, 11 Feb 2022 13:58:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644587880; 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=Uy5+CS5mpMmW7IgMwOBz3VIKIzEEcemLFBLtVDSGAyc=; b=jIqC7jIYaNqm/3iBR7qkbYzFEMYU8fPmSj4Yntl0SF4oBilL4AAHDsvpx2VpVtU7+kpWXJ O0IqQSIOJw4IcBV9L+7BE5oq6843SvdHS16EjpRz1nIsLNwmrU2fPG6nRoTqzzfbogVx2h H/nbLi9hk7evmgsjYIUil+yqWQYRoh2fhsO2B2uHScI9m/7e7FuTeqcUJaZaX9BY2ZxgIk shmvM0JFvi6rqfId1oxdTNUzzjANHYzGVoTAHNf7rYC2ZvHkX48yrbt9Gy7/wchcUKmIpD FfRbhBCFRsLz7Ak5QhcuXyjIi593mXOgsLWe00rvwwD+1nI0GJAOma5CnxNeng== 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 6F29C1527F; Fri, 11 Feb 2022 13:58:00 +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 21BDw0Gn093059; Fri, 11 Feb 2022 13:58:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21BDw0Gq093058; Fri, 11 Feb 2022 13:58:00 GMT (envelope-from git) Date: Fri, 11 Feb 2022 13:58:00 GMT Message-Id: <202202111358.21BDw0Gq093058@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: 93288e2445fe - main - Employ thread_cow_synced in setrlimit 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 93288e2445fea95cb15b266759c2d9e382ea4e47 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644587880; 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=Uy5+CS5mpMmW7IgMwOBz3VIKIzEEcemLFBLtVDSGAyc=; b=SOyrtDZIQs4TeX7WZVHx/+6IojVfvfQyQvYIvSOFj/7i6b7zaw8VWQzNUwekbNYiHV+wq4 OeAwogUrEDa5qHr8+dkMFhQCPNJlrxjkjgxgOvIoNszNLhdx3Yq5CkTnEuLRsIlntuyNrb R+paThqpHPNfPkdXCx97RBDE1mnO99PkIZvFw17qkaLdfu6D2nt/2FpDyrZObyrDDCUtcc Ecr66SZda4UF2vNWvuAp0aCeWzsjgEKr7wERPmQhUOUD4HrwY6LKD567eF7jBdHjpw50Tv /0eQilcHLWcJUMpPNDcuIaiLKBtjNy0U4ty7PWAl3ic83QNCES9Fi3Acfo6TkQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644587880; a=rsa-sha256; cv=none; b=AttyncybD940DVFWBaaImeeFziNVtezRMYAmYAnIZcTeuj+tguNiZ09gAwvH68MNuRi890 83b/QFz3MoISrpOBvmrTddW8g+ob77kEH1aevRQiHkbhsmb6oB7ns/S0g7nN1Fum6KTpjq MVGGEc7Q4jAfwvEdHqubr2THc1dUBeXgy/ySmxUEEd8iibbzzxnTYOrEoZCb4bfNlkT8FF kje44+k7wcYBz58j302pdEflBgKlxgYtUkB6Im1MyX/uOKo4nB4uzvauPY5VmyVl9PQuTN OZxXMjHInjpTDPLKAIP2qmYqgUoIbHKAp9qP2Ll4KyW9FNbrT4oMMw9DKg7irQ== 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=93288e2445fea95cb15b266759c2d9e382ea4e47 commit 93288e2445fea95cb15b266759c2d9e382ea4e47 Author: Mateusz Guzik AuthorDate: 2022-02-01 13:22:22 +0000 Commit: Mateusz Guzik CommitDate: 2022-02-11 11:44:07 +0000 Employ thread_cow_synced in setrlimit In order to avoid proc lock/unlock on next kernel entry. --- sys/kern/kern_resource.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index c2d75f86d183..0c1fd4303d3d 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -656,7 +656,7 @@ int kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which, struct rlimit *limp) { - struct plimit *newlim, *oldlim; + struct plimit *newlim, *oldlim, *oldlim_td; struct rlimit *alimp; struct rlimit oldssiz; int error; @@ -738,8 +738,18 @@ kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which, *alimp = *limp; p->p_limit = newlim; PROC_UPDATE_COW(p); + oldlim_td = NULL; + if (td == curthread && PROC_COW_CHANGECOUNT(td, p) == 1) { + oldlim_td = lim_cowsync(); + thread_cow_synced(td); + } PROC_UNLOCK(p); - lim_free(oldlim); + if (oldlim_td != NULL) { + MPASS(oldlim_td == oldlim); + lim_freen(oldlim, 2); + } else { + lim_free(oldlim); + } if (which == RLIMIT_STACK && /*