View | Details | Raw Unified | Return to bug 233414 | Differences between
and this patch

Collapse All | Expand All

(-)b/sys/vm/uma_core.c (-6 / +25 lines)
Lines 362-374 bucket_init(void) Link Here
362
 * to allocate the bucket.
362
 * to allocate the bucket.
363
 */
363
 */
364
static struct uma_bucket_zone *
364
static struct uma_bucket_zone *
365
bucket_zone_lookup(int entries)
365
bucket_zone_lookup(uma_zone_t zone, int entries)
366
{
366
{
367
	struct uma_bucket_zone *ubz;
367
	struct uma_bucket_zone *ubz;
368
	uma_keg_t keg;
368
369
369
	for (ubz = &bucket_zones[0]; ubz->ubz_entries != 0; ubz++)
370
	for (ubz = &bucket_zones[0]; ubz->ubz_entries != 0; ubz++) {
370
		if (ubz->ubz_entries >= entries)
371
		if (ubz->ubz_entries < entries)
371
			return (ubz);
372
			continue;
373
#ifdef DEBUG_MEMGUARD
374
		if (zone == ubz->ubz_zone) {
375
			if ((ubz + 1)->ubz_entries != 0)
376
				continue;
377
			return (memguard_cmp_zone((ubz - 1)->ubz_zone) ?
378
			    ubz - 2 : ubz - 1);
379
		}
380
		if (zone != NULL && memguard_cmp_zone(ubz->ubz_zone) &&
381
		    (keg = zone_first_keg(zone)) != NULL &&
382
		    (keg->uk_flags & (UMA_ZONE_VM | UMA_ZFLAG_BUCKET)) != 0) {
383
			if ((ubz + 1)->ubz_entries == 0)
384
				return (zone == (ubz - 1)->ubz_zone ?
385
				    ubz - 2 : ubz - 1);
386
			continue;
387
		}
388
#endif
389
		return (ubz);
390
	}
372
	ubz--;
391
	ubz--;
373
	return (ubz);
392
	return (ubz);
374
}
393
}
Lines 422-428 bucket_alloc(uma_zone_t zone, void *udata, int flags) Link Here
422
	}
441
	}
423
	if ((uintptr_t)udata & UMA_ZFLAG_CACHEONLY)
442
	if ((uintptr_t)udata & UMA_ZFLAG_CACHEONLY)
424
		flags |= M_NOVM;
443
		flags |= M_NOVM;
425
	ubz = bucket_zone_lookup(zone->uz_count);
444
	ubz = bucket_zone_lookup(zone, zone->uz_count);
426
	if (ubz->ubz_zone == zone && (ubz + 1)->ubz_entries != 0)
445
	if (ubz->ubz_zone == zone && (ubz + 1)->ubz_entries != 0)
427
		ubz++;
446
		ubz++;
428
	bucket = uma_zalloc_arg(ubz->ubz_zone, udata, flags);
447
	bucket = uma_zalloc_arg(ubz->ubz_zone, udata, flags);
Lines 446-452 bucket_free(uma_zone_t zone, uma_bucket_t bucket, void *udata) Link Here
446
	    ("bucket_free: Freeing a non free bucket."));
465
	    ("bucket_free: Freeing a non free bucket."));
447
	if ((zone->uz_flags & UMA_ZFLAG_BUCKET) == 0)
466
	if ((zone->uz_flags & UMA_ZFLAG_BUCKET) == 0)
448
		udata = (void *)(uintptr_t)zone->uz_flags;
467
		udata = (void *)(uintptr_t)zone->uz_flags;
449
	ubz = bucket_zone_lookup(bucket->ub_entries);
468
	ubz = bucket_zone_lookup(NULL, bucket->ub_entries);
450
	uma_zfree_arg(ubz->ubz_zone, bucket, udata);
469
	uma_zfree_arg(ubz->ubz_zone, bucket, udata);
451
}
470
}
452
471

Return to bug 233414