Пример #1
0
/* Allocate a `struct vperfctr'. Claim and reserve
   an entire page so that it can be mmap():ed. */
static struct vperfctr *vperfctr_alloc(void)
{
	unsigned long page;

	if (inc_nrctrs() != 0)
		return ERR_PTR(-EBUSY);
	page = get_zeroed_page(GFP_KERNEL);
	if (!page) {
		dec_nrctrs();
		return ERR_PTR(-ENOMEM);
	}
	SetPageReserved(virt_to_page((void *)(page)));
	return (struct vperfctr*) page;
}
Пример #2
0
/* Allocate a `struct vperfctr'. Claim and reserve
   an entire page so that it can be mmap():ed. */
static struct vperfctr *vperfctr_alloc(void)
{
	struct vperfctr *perf;

	if (inc_nrctrs() != 0)
		return ERR_PTR(-EBUSY);
	perf = (struct vperfctr *) kmem_alloc (sizeof (struct vperfctr)); 
	if (!perf) {
		dec_nrctrs();
		return ERR_PTR(-ENOMEM);
	}

	return perf;
}