ksiginfo_alloc(): change to directly take M_WAITOK/NOWAIT flags

Also style, and remove unneeded cast.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36207
This commit is contained in:
Konstantin Belousov 2022-08-17 19:57:20 +03:00
parent 5c78797e42
commit cc29f221aa
4 changed files with 9 additions and 10 deletions

View File

@ -498,7 +498,7 @@ exit1(struct thread *td, int rval, int signo)
wakeup(q->p_reaper);
for (; q != NULL; q = nq) {
nq = LIST_NEXT(q, p_sibling);
ksi = ksiginfo_alloc(TRUE);
ksi = ksiginfo_alloc(M_WAITOK);
PROC_LOCK(q);
q->p_sigparent = SIGCHLD;

View File

@ -365,14 +365,13 @@ sigqueue_start(void)
}
ksiginfo_t *
ksiginfo_alloc(int wait)
ksiginfo_alloc(int mwait)
{
int flags;
MPASS(mwait == M_WAITOK || mwait == M_NOWAIT);
flags = M_ZERO | (wait ? M_WAITOK : M_NOWAIT);
if (ksiginfo_zone != NULL)
return ((ksiginfo_t *)uma_zalloc(ksiginfo_zone, flags));
return (NULL);
if (ksiginfo_zone == NULL)
return (NULL);
return (uma_zalloc(ksiginfo_zone, mwait | M_ZERO));
}
void
@ -513,7 +512,7 @@ sigqueue_add(sigqueue_t *sq, int signo, ksiginfo_t *si)
if (p != NULL && p->p_pendingcnt >= max_pending_per_proc) {
signal_overflow++;
ret = EAGAIN;
} else if ((ksi = ksiginfo_alloc(0)) == NULL) {
} else if ((ksi = ksiginfo_alloc(M_NOWAIT)) == NULL) {
signal_alloc_fail++;
ret = EAGAIN;
} else {

View File

@ -468,7 +468,7 @@ proc_linkup(struct proc *p, struct thread *td)
{
sigqueue_init(&p->p_sigqueue, p);
p->p_ksi = ksiginfo_alloc(1);
p->p_ksi = ksiginfo_alloc(M_WAITOK);
if (p->p_ksi != NULL) {
/* XXX p_ksi may be null if ksiginfo zone is not ready */
p->p_ksi->ksi_flags = KSI_EXT | KSI_INS;

View File

@ -384,7 +384,7 @@ int cursig(struct thread *td);
void execsigs(struct proc *p);
void gsignal(int pgid, int sig, ksiginfo_t *ksi);
void killproc(struct proc *p, const char *why);
ksiginfo_t * ksiginfo_alloc(int wait);
ksiginfo_t *ksiginfo_alloc(int mwait);
void ksiginfo_free(ksiginfo_t *ksi);
int pksignal(struct proc *p, int sig, ksiginfo_t *ksi);
void pgsigio(struct sigio **sigiop, int sig, int checkctty);