- Manage pid_table with kmem(9).

- Remove M_PROC and unused M_SESSION.
This commit is contained in:
rmind 2009-04-16 14:56:41 +00:00
parent 71923f262a
commit d062d5d72b
3 changed files with 20 additions and 21 deletions
sys
arch/arm/xscale
kern
sys

@ -1,4 +1,4 @@
/* $NetBSD: xscale_pmc.c,v 1.12 2007/10/17 19:53:45 garbled Exp $ */
/* $NetBSD: xscale_pmc.c,v 1.13 2009/04/16 14:56:41 rmind Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xscale_pmc.c,v 1.12 2007/10/17 19:53:45 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: xscale_pmc.c,v 1.13 2009/04/16 14:56:41 rmind Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@ -190,7 +190,7 @@ xscale_fork(struct proc *p1, struct proc *p2)
p2->p_md.pmc_enabled = p1->p_md.pmc_enabled;
p2->p_md.pmc_state = malloc(sizeof(struct xscale_pmc_state),
M_PROC, M_NOWAIT);
M_TEMP, M_NOWAIT);
if (p2->p_md.pmc_state == NULL) {
/* XXX
* Can't return failure at this point, so just disable
@ -364,7 +364,7 @@ xscale_process_exit(struct proc *p)
}
}
if (p->p_md.pmc_state)
free(p->p_md.pmc_state, M_PROC);
free(p->p_md.pmc_state, M_TEMP);
p->p_md.pmc_state = NULL;
p->p_md.pmc_enabled = 0;
}
@ -452,7 +452,7 @@ xscale_configure_counter(struct proc *p, int ctr, struct pmc_counter_cfg *cfg)
if (p->p_md.pmc_state == NULL) {
p->p_md.pmc_state = malloc(sizeof(struct xscale_pmc_state),
M_PROC, M_WAITOK);
M_TEMP, M_WAITOK);
if (!p->p_md.pmc_state)
return ENOMEM;
}

@ -1,4 +1,4 @@
/* $NetBSD: kern_proc.c,v 1.149 2009/04/16 00:17:19 rmind Exp $ */
/* $NetBSD: kern_proc.c,v 1.150 2009/04/16 14:56:41 rmind Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.149 2009/04/16 00:17:19 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.150 2009/04/16 14:56:41 rmind Exp $");
#include "opt_kstack.h"
#include "opt_maxuprc.h"
@ -78,7 +78,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.149 2009/04/16 00:17:19 rmind Exp $"
#include <sys/file.h>
#include <ufs/ufs/quota.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/pool.h>
#include <sys/pset.h>
#include <sys/mbuf.h>
@ -214,7 +213,6 @@ int maxuprc = MAXUPRC;
int cmask = CMASK;
MALLOC_DEFINE(M_EMULDATA, "emuldata", "Per-process emulation data");
MALLOC_DEFINE(M_PROC, "proc", "Proc structures");
MALLOC_DEFINE(M_SUBPROC, "subproc", "Proc sub-structures");
/*
@ -242,16 +240,16 @@ void
procinit(void)
{
const struct proclist_desc *pd;
int i;
u_int i;
#define LINK_EMPTY ((PID_MAX + INITIAL_PID_TABLE_SIZE) & ~(INITIAL_PID_TABLE_SIZE - 1))
for (pd = proclists; pd->pd_list != NULL; pd++)
LIST_INIT(pd->pd_list);
proc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
pid_table = kmem_alloc(INITIAL_PID_TABLE_SIZE
* sizeof(struct pid_table), KM_SLEEP);
pid_table = malloc(INITIAL_PID_TABLE_SIZE * sizeof *pid_table,
M_PROC, M_WAITOK);
/* Set free list running through table...
Preset 'use count' above PID_MAX so we allocate pid 1 next. */
for (i = 0; i <= pid_tbl_mask; i++) {
@ -484,20 +482,22 @@ pg_find(pid_t pgid, uint flags)
static void
expand_pid_table(void)
{
uint pt_size = pid_tbl_mask + 1;
size_t pt_size, tsz;
struct pid_table *n_pt, *new_pt;
struct proc *proc;
struct pgrp *pgrp;
int i;
pid_t pid;
u_int i;
new_pt = malloc(pt_size * 2 * sizeof *new_pt, M_PROC, M_WAITOK);
pt_size = pid_tbl_mask + 1;
tsz = pt_size * 2 * sizeof(struct pid_table);
new_pt = kmem_alloc(tsz, KM_SLEEP);
mutex_enter(proc_lock);
if (pt_size != pid_tbl_mask + 1) {
/* Another process beat us to it... */
mutex_exit(proc_lock);
free(new_pt, M_PROC);
kmem_free(new_pt, tsz);
return;
}
@ -540,7 +540,8 @@ expand_pid_table(void)
break;
}
/* Switch tables */
/* Save old table size and switch tables */
tsz = pt_size * sizeof(struct pid_table);
n_pt = pid_table;
pid_table = new_pt;
pid_tbl_mask = pt_size * 2 - 1;
@ -556,7 +557,7 @@ expand_pid_table(void)
pid_alloc_lim <<= 1; /* doubles number of free slots... */
mutex_exit(proc_lock);
free(n_pt, M_PROC);
kmem_free(n_pt, tsz);
}
struct proc *

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.285 2009/04/16 00:17:19 rmind Exp $ */
/* $NetBSD: proc.h,v 1.286 2009/04/16 14:56:41 rmind Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -418,8 +418,6 @@ struct proclist_desc {
#ifdef _KERNEL
#include <sys/mallocvar.h>
MALLOC_DECLARE(M_EMULDATA);
MALLOC_DECLARE(M_PROC);
MALLOC_DECLARE(M_SESSION);
MALLOC_DECLARE(M_SUBPROC); /* XXX - only used by sparc/sparc64 */
/*