git: 93288e2445fe - main - Employ thread_cow_synced in setrlimit
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Feb 2022 13:58:00 UTC
The branch main has been updated by mjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=93288e2445fea95cb15b266759c2d9e382ea4e47
commit 93288e2445fea95cb15b266759c2d9e382ea4e47
Author: Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-02-01 13:22:22 +0000
Commit: Mateusz Guzik <mjg@FreeBSD.org>
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 &&
/*