sync with OpenBSD -current

This commit is contained in:
purplerain 2024-01-20 03:21:37 +00:00
parent fdad81bcfc
commit ed28f347da
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
53 changed files with 1138 additions and 405 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_exit.c,v 1.219 2024/01/16 19:05:01 deraadt Exp $ */
/* $OpenBSD: kern_exit.c,v 1.220 2024/01/19 01:43:26 bluhm Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@ -165,8 +165,6 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
/* main thread gotta wait because it has the pid, et al */
while (pr->ps_threadcnt > 1)
tsleep_nsec(&pr->ps_threads, PWAIT, "thrdeath", INFSLP);
LIST_REMOVE(pr, ps_list);
refcnt_finalize(&pr->ps_refcnt, "psdtor");
}
rup = pr->ps_ru;
@ -259,6 +257,7 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
if ((p->p_flag & P_THREAD) == 0) {
LIST_REMOVE(pr, ps_hash);
LIST_REMOVE(pr, ps_list);
if ((pr->ps_flags & PS_NOZOMBIE) == 0)
LIST_INSERT_HEAD(&zombprocess, pr, ps_list);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_fork.c,v 1.255 2024/01/16 19:05:01 deraadt Exp $ */
/* $OpenBSD: kern_fork.c,v 1.256 2024/01/19 01:43:26 bluhm Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@ -197,7 +197,6 @@ process_initialize(struct process *pr, struct proc *p)
LIST_INIT(&pr->ps_sigiolst);
TAILQ_INIT(&pr->ps_tslpqueue);
refcnt_init(&pr->ps_refcnt);
rw_init(&pr->ps_lock, "pslock");
mtx_init(&pr->ps_mtx, IPL_HIGH);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_proc.c,v 1.96 2024/01/15 15:47:37 mvs Exp $ */
/* $OpenBSD: kern_proc.c,v 1.97 2024/01/19 01:43:27 bluhm Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@ -231,26 +231,6 @@ prfind(pid_t pid)
return (NULL);
}
struct process *
priterator(struct process *ps)
{
struct process *nps;
KERNEL_ASSERT_LOCKED();
if (ps == NULL)
nps = LIST_FIRST(&allprocess);
else
nps = LIST_NEXT(ps, ps_list);
if (nps)
refcnt_take(&nps->ps_refcnt);
if (ps)
refcnt_rele_wake(&ps->ps_refcnt);
return nps;
}
/*
* Locate a process group by number
*/

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sysctl.c,v 1.423 2024/01/18 08:48:32 mvs Exp $ */
/* $OpenBSD: kern_sysctl.c,v 1.424 2024/01/19 01:43:27 bluhm Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@ -1529,7 +1529,7 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
break;
}
matched = 0;
for (pr = priterator(NULL); pr != NULL; pr = priterator(pr)) {
LIST_FOREACH(pr, &allprocess, ps_list) {
/*
* skip system, exiting, embryonic and undead
* processes
@ -1561,7 +1561,7 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
error = ESRCH;
break;
case KERN_FILE_BYUID:
for (pr = priterator(NULL); pr != NULL; pr = priterator(pr)) {
LIST_FOREACH(pr, &allprocess, ps_list) {
/*
* skip system, exiting, embryonic and undead
* processes

View file

@ -1,4 +1,4 @@
/* $OpenBSD: subr_extent.c,v 1.64 2022/12/05 23:18:37 deraadt Exp $ */
/* $OpenBSD: subr_extent.c,v 1.65 2024/01/19 22:12:24 kettenis Exp $ */
/* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */
/*-
@ -398,9 +398,10 @@ extent_insert_and_optimize(struct extent *ex, u_long start, u_long size,
* Allocate a specific region in an extent map.
*/
int
extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
extent_do_alloc_region(struct extent *ex, u_long start, u_long size,
int flags, struct extent_region *myrp)
{
struct extent_region *rp, *last, *myrp;
struct extent_region *rp, *last;
u_long end = start + (size - 1);
int error;
@ -435,23 +436,11 @@ extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
__func__, start, end);
panic("%s: region lies outside extent", __func__);
#else
extent_free_region_descriptor(ex, myrp);
return (EINVAL);
#endif
}
/*
* Allocate the region descriptor. It will be freed later
* if we can coalesce with another region.
*/
myrp = extent_alloc_region_descriptor(ex, flags);
if (myrp == NULL) {
#ifdef DIAGNOSTIC
printf(
"%s: can't allocate region descriptor\n", __func__);
#endif
return (ENOMEM);
}
alloc_start:
/*
* Attempt to place ourselves in the desired area of the
@ -567,6 +556,39 @@ extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
return (0);
}
int
extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
{
struct extent_region *rp;
/*
* Allocate the region descriptor. It will be freed later
* if we can coalesce with another region.
*/
rp = extent_alloc_region_descriptor(ex, flags);
if (rp == NULL) {
#ifdef DIAGNOSTIC
printf("%s: can't allocate region descriptor\n", __func__);
#endif
return (ENOMEM);
}
return extent_do_alloc_region(ex, start, size, flags, rp);
}
int
extent_alloc_region_with_descr(struct extent *ex, u_long start,
u_long size, int flags, struct extent_region *rp)
{
#ifdef DIAGNOSTIC
if ((ex->ex_flags & EXF_NOCOALESCE) == 0)
panic("%s: EX_NOCOALESCE not set", __func__);
#endif
rp->er_flags = ER_DISCARD;
return extent_do_alloc_region(ex, start, size, flags, rp);
}
/*
* Macro to check (x + y) <= z. This check is designed to fail
* if an overflow occurs.