From nobody Fri Feb 11 13:57:58 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 5230819B0581; Fri, 11 Feb 2022 13:57:58 +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 4JwFYy1tkXz3sgQ; Fri, 11 Feb 2022 13:57:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644587878; 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=zf/OVsj9TihMbssbE4k1Sc4QWUV9rn6qa3sJ/xyrvFs=; b=JyMF9aokBrhdMybVZJLNI4aRoqmCBAyovQ9osGH4x82aPGsRd8BeR1tbEMqXkWOQiDHBMA daIChz6LySnJUlBTP1nPp7YghPJ3eZIb4H9p3E6CUgIITxQdejOI4Oq2NqbMK+Nu2bhudP I7oOg/ow8QKnW7xXn/gcHP72T8sGUpOapRVuRd1OPy6BA0YAkIqZcftlE20Hf9w9g1PujP cpPdApwdSwo4vk0RH4LSSUDS9WK5ew/rz5rIYKHLeSEA5yAXs4Rj7C3fLvv6zZHQq8JpEU EcfOT8Re7spVH2o7wXRoSxHElvg+hPAMv/WiTwoN10IYNx+xse+CEP0AW4uLRg== 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 211001527E; Fri, 11 Feb 2022 13:57:58 +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 21BDvwVN093004; Fri, 11 Feb 2022 13:57:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21BDvwAL093003; Fri, 11 Feb 2022 13:57:58 GMT (envelope-from git) Date: Fri, 11 Feb 2022 13:57:58 GMT Message-Id: <202202111357.21BDvwAL093003@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: 8a0cb04df4ff - main - Add lim_cowsync, similar to crcowsync 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: 8a0cb04df4ff9902b17c9cb4b2e7413354fb630d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644587878; 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=zf/OVsj9TihMbssbE4k1Sc4QWUV9rn6qa3sJ/xyrvFs=; b=PzG72H+K1XNLeSicnC5TWrs2cGQJ76M9mpxH0wfnhLXVdak91swD4NwxWsVW7VemEKfKzh brk0rL7ahRbopTMPxq32fIXOJJEWN8FiUNtD9WFvXgbQqSAMiyWbMsW4LyqHKJlEha+UuM CdrHCbVgkD27n4XcOeiXQ7dAFErwKYCbiuywCwsu0erWdiO/LWOCeSAoMFVkZEfiDZkJB1 h+wD7aV7RT5rvQ/TNBdTFWYIzPhx4vODdIUmas7fP77/keI72oEPKefShY3a6NFpTcy4hN WLw9tOCx+DKZkxlQn2X0cnTBNQ6L5JBacNNFTDxtCatXkij0uhMKM0LRTq7KCg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644587878; a=rsa-sha256; cv=none; b=cLVXDXuIT3QriGS7HsIBwXI1s45BwOsRfGGe8P6msvO6ofvx6le9i0l+rsTpI7BtBbnmIV FK/yJVjvHuSlo85Vwxbraj2V2EDbwCa9CnAuJNe1zIkr5urZZ1D5EaE1ewyXqK1Vl9LoQy AlzZ5NFJKKKndMQOqEnqyCEzbBL0XS5NUZCIjn160PLhOrINOfmlyIgwz9EYxGchuChwcq LPjPZLyA4qWLPyMuu+G5R/Oiz1sJxhReH8Tl6rVjDhMDRI+uOumNSO183thZ1xs+P2ZRyx BC7/HXJ6nyFJSJWi0hIaGavQ1tHElHBemiE3qTerJk2cFc+PJVKrCIOg3VOuHQ== 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=8a0cb04df4ff9902b17c9cb4b2e7413354fb630d commit 8a0cb04df4ff9902b17c9cb4b2e7413354fb630d Author: Mateusz Guzik AuthorDate: 2022-02-01 13:10:21 +0000 Commit: Mateusz Guzik CommitDate: 2022-02-11 11:44:07 +0000 Add lim_cowsync, similar to crcowsync --- sys/kern/kern_resource.c | 20 ++++++++++++++++++++ sys/kern/kern_thread.c | 5 +---- sys/sys/resourcevar.h | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 504e338ba922..c2d75f86d183 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1216,6 +1216,26 @@ lim_hold(struct plimit *limp) return (limp); } +struct plimit * +lim_cowsync(void) +{ + struct thread *td; + struct proc *p; + struct plimit *oldlimit; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + + if (td->td_limit == p->p_limit) + return (NULL); + + oldlimit = td->td_limit; + td->td_limit = lim_hold(p->p_limit); + + return (oldlimit); +} + void lim_fork(struct proc *p1, struct proc *p2) { diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 7b0ff604b086..dcb52b137b58 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -859,10 +859,7 @@ thread_cow_update(struct thread *td) oldlimit = NULL; PROC_LOCK(p); oldcred = crcowsync(); - if (td->td_limit != p->p_limit) { - oldlimit = td->td_limit; - td->td_limit = lim_hold(p->p_limit); - } + oldlimit = lim_cowsync(); td->td_cowgen = p->p_cowgen; PROC_UNLOCK(p); if (oldcred != NULL) diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h index d1c9e6d4985f..bd57211c75f0 100644 --- a/sys/sys/resourcevar.h +++ b/sys/sys/resourcevar.h @@ -148,6 +148,8 @@ void lim_free(struct plimit *limp); void lim_freen(struct plimit *limp, int n); struct plimit *lim_hold(struct plimit *limp); +struct plimit + *lim_cowsync(void); rlim_t lim_max(struct thread *td, int which); rlim_t lim_max_proc(struct proc *p, int which); void lim_rlimit(struct thread *td, int which, struct rlimit *rlp);