51c51
< __FBSDID("$FreeBSD: head/sys/vm/uma_core.c 251983 2013-06-19 02:30:32Z jeff $");
---
> __FBSDID("$FreeBSD: head/sys/vm/uma_core.c 252040 2013-06-20 19:08:12Z jeff $");
249,250c249,250
< static uma_bucket_t bucket_alloc(int, int);
< static void bucket_free(uma_bucket_t);
---
> static uma_bucket_t bucket_alloc(uma_zone_t zone, int);
> static void bucket_free(uma_zone_t zone, uma_bucket_t);
259,260d258
< static inline void zone_relock(uma_zone_t zone, uma_keg_t keg);
< static inline void keg_relock(uma_keg_t keg, uma_zone_t zone);
355c353
< bucket_alloc(int entries, int bflags)
---
> bucket_alloc(uma_zone_t zone, int flags)
369,370c367,370
< ubz = bucket_zone_lookup(entries);
< bucket = uma_zalloc(ubz->ubz_zone, bflags);
---
> if (zone->uz_flags & UMA_ZFLAG_CACHEONLY)
> flags |= M_NOVM;
> ubz = bucket_zone_lookup(zone->uz_count);
> bucket = uma_zalloc(ubz->ubz_zone, flags);
383c383
< bucket_free(uma_bucket_t bucket)
---
> bucket_free(uma_zone_t zone, uma_bucket_t bucket)
665c665
< bucket_free(cache->uc_allocbucket);
---
> bucket_free(zone, cache->uc_allocbucket);
667c667
< bucket_free(cache->uc_freebucket);
---
> bucket_free(zone, cache->uc_freebucket);
691c691
< bucket_free(bucket);
---
> bucket_free(zone, bucket);
804c804
< msleep(zone, zone->uz_lock, PVM, "zonedrain", 1);
---
> msleep(zone, zone->uz_lockptr, PVM, "zonedrain", 1);
1378c1378
< * Initialize keg's lock (shared among zones).
---
> * Initialize keg's lock
1380,1383c1380
< if (arg->flags & UMA_ZONE_MTXCLASS)
< KEG_LOCK_INIT(keg, 1);
< else
< KEG_LOCK_INIT(keg, 0);
---
> KEG_LOCK_INIT(keg, (arg->flags & UMA_ZONE_MTXCLASS));
1471a1469,1470
> ZONE_LOCK_INIT(zone, (arg->flags & UMA_ZONE_MTXCLASS));
>
1475a1475
> zone->uz_size = arg->size;
1479,1480c1479,1480
< zone->uz_count = BUCKET_MAX;
< return (0);
---
> zone->uz_lockptr = &zone->uz_lock;
> goto out;
1494c1494
< zone->uz_lock = &keg->uk_lock;
---
> zone->uz_lockptr = &keg->uk_lock;
1532c1532
< zone->uz_lock = &keg->uk_lock;
---
> zone->uz_lockptr = &keg->uk_lock;
1547,1548c1547,1549
< if ((keg->uk_flags & UMA_ZONE_MAXBUCKET) == 0)
< zone->uz_count = bucket_select(keg->uk_rsize);
---
> out:
> if ((arg->flags & UMA_ZONE_MAXBUCKET) == 0)
> zone->uz_count = bucket_select(zone->uz_size);
1628a1630
> ZONE_LOCK_FINI(zone);
1852,1854c1854,1856
< uma_zcache_create(char *name, uma_ctor ctor, uma_dtor dtor, uma_init zinit,
< uma_fini zfini, uma_import zimport, uma_release zrelease,
< void *arg, int flags)
---
> uma_zcache_create(char *name, int size, uma_ctor ctor, uma_dtor dtor,
> uma_init zinit, uma_fini zfini, uma_import zimport,
> uma_release zrelease, void *arg, int flags)
1860c1862
< args.size = 0;
---
> args.size = size;
1879c1881
< mtx_lock_flags(b->uz_lock, MTX_DUPOK);
---
> mtx_lock_flags(b->uz_lockptr, MTX_DUPOK);
1882c1884
< mtx_lock_flags(a->uz_lock, MTX_DUPOK);
---
> mtx_lock_flags(a->uz_lockptr, MTX_DUPOK);
2074c2076
< bucket_free(bucket);
---
> bucket_free(zone, bucket);
2244,2261d2245
< static inline void
< zone_relock(uma_zone_t zone, uma_keg_t keg)
< {
< if (zone->uz_lock != &keg->uk_lock) {
< KEG_UNLOCK(keg);
< ZONE_LOCK(zone);
< }
< }
<
< static inline void
< keg_relock(uma_keg_t keg, uma_zone_t zone)
< {
< if (zone->uz_lock != &keg->uk_lock) {
< ZONE_UNLOCK(zone);
< KEG_LOCK(keg);
< }
< }
<
2267c2251
< if (keg == NULL)
---
> if (keg == NULL) {
2268a2253,2254
> KEG_LOCK(keg);
> }
2276a2263
> KEG_UNLOCK(keg);
2282,2283c2269
< * with the keg locked. Caller must call zone_relock() afterwards if the
< * zone lock is required. On NULL the zone lock is held.
---
> * with the keg locked. On NULL no lock is held.
2307c2293
< if (last) {
---
> if (last != NULL) {
2311,2312c2297
< zone_relock(zone, last);
< last = NULL;
---
> KEG_UNLOCK(last);
2328c2313
< keg_relock(keg, zone);
---
> KEG_LOCK(keg);
2338c2323
< zone_relock(zone, keg);
---
> KEG_UNLOCK(keg);
2347a2333
> ZONE_LOCK(zone);
2351c2337,2338
< msleep(zone, zone->uz_lock, PVM, "zonelimit", hz/100);
---
> msleep(zone, zone->uz_lockptr, PVM,
> "zonelimit", hz/100);
2352a2340
> ZONE_UNLOCK(zone);
2390,2391d2377
< ZONE_LOCK(zone);
< /* Try to keep the buckets totally full */
2393a2380
> /* Try to keep the buckets totally full */
2398c2385
< while (slab->us_freecount && i < max)
---
> while (slab->us_freecount && i < max)
2407,2408d2393
< else
< ZONE_UNLOCK(zone);
2417d2401
< int bflags;
2420,2424c2404
< max = zone->uz_count;
< bflags = (flags & ~M_WAITOK) | M_NOWAIT;
< if (zone->uz_flags & UMA_ZFLAG_CACHEONLY)
< bflags |= M_NOVM;
< bucket = bucket_alloc(zone->uz_count, bflags);
---
> bucket = bucket_alloc(zone, M_NOWAIT | (flags & M_NOVM));
2428c2408
< max = MIN(bucket->ub_entries, max);
---
> max = MIN(bucket->ub_entries, zone->uz_count);
2447c2427
< zone->uz_release(zone->uz_arg, bucket->ub_bucket[i],
---
> zone->uz_release(zone->uz_arg, &bucket->ub_bucket[i],
2460c2440
< bucket_free(bucket);
---
> bucket_free(zone, bucket);
2532d2511
< int bflags;
2657,2660c2636
< bflags = M_NOWAIT;
< if (zone->uz_flags & UMA_ZFLAG_CACHEONLY)
< bflags |= M_NOVM;
< bucket = bucket_alloc(zone->uz_count, bflags);
---
> bucket = bucket_alloc(zone, M_NOWAIT);
2674c2650
< bucket_free(bucket);
---
> bucket_free(zone, bucket);
2724d2699
< ZONE_LOCK(zone);
2725a2701
> KEG_LOCK(keg);
2761c2737
< zone_relock(zone, keg);
---
> KEG_UNLOCK(keg);
2762a2739
> ZONE_LOCK(zone);
2764a2742
> ZONE_UNLOCK(zone);
2766d2743
< ZONE_UNLOCK(zone);
2810c2787
< ZONE_LOCK(zone);
---
> KEG_LOCK(keg);
2815c2792
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2830c2807
< ZONE_LOCK(zone);
---
> KEG_LOCK(keg);
2832c2809
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2876d2852
< ZONE_LOCK(zone);
2878a2855
> KEG_LOCK(keg);
2882c2859
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2891d2867
< ZONE_LOCK(zone);
2893a2870
> KEG_LOCK(keg);
2897c2874
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2903a2881
>
2914a2893
>
2929d2907
< ZONE_LOCK(zone);
2931a2910
> KEG_LOCK(keg);
2933c2912
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2943d2921
< ZONE_LOCK(zone);
2944a2923
> KEG_LOCK(keg);
2947c2926
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2976c2955
< ZONE_LOCK(zone);
---
> KEG_LOCK(keg);
2986c2965,2966
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
>
3001c2981
< ZONE_LOCK(zone);
---
> KEG_LOCK(keg);
3013c2993
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
< __FBSDID("$FreeBSD: head/sys/vm/uma_core.c 251983 2013-06-19 02:30:32Z jeff $");
---
> __FBSDID("$FreeBSD: head/sys/vm/uma_core.c 252040 2013-06-20 19:08:12Z jeff $");
249,250c249,250
< static uma_bucket_t bucket_alloc(int, int);
< static void bucket_free(uma_bucket_t);
---
> static uma_bucket_t bucket_alloc(uma_zone_t zone, int);
> static void bucket_free(uma_zone_t zone, uma_bucket_t);
259,260d258
< static inline void zone_relock(uma_zone_t zone, uma_keg_t keg);
< static inline void keg_relock(uma_keg_t keg, uma_zone_t zone);
355c353
< bucket_alloc(int entries, int bflags)
---
> bucket_alloc(uma_zone_t zone, int flags)
369,370c367,370
< ubz = bucket_zone_lookup(entries);
< bucket = uma_zalloc(ubz->ubz_zone, bflags);
---
> if (zone->uz_flags & UMA_ZFLAG_CACHEONLY)
> flags |= M_NOVM;
> ubz = bucket_zone_lookup(zone->uz_count);
> bucket = uma_zalloc(ubz->ubz_zone, flags);
383c383
< bucket_free(uma_bucket_t bucket)
---
> bucket_free(uma_zone_t zone, uma_bucket_t bucket)
665c665
< bucket_free(cache->uc_allocbucket);
---
> bucket_free(zone, cache->uc_allocbucket);
667c667
< bucket_free(cache->uc_freebucket);
---
> bucket_free(zone, cache->uc_freebucket);
691c691
< bucket_free(bucket);
---
> bucket_free(zone, bucket);
804c804
< msleep(zone, zone->uz_lock, PVM, "zonedrain", 1);
---
> msleep(zone, zone->uz_lockptr, PVM, "zonedrain", 1);
1378c1378
< * Initialize keg's lock (shared among zones).
---
> * Initialize keg's lock
1380,1383c1380
< if (arg->flags & UMA_ZONE_MTXCLASS)
< KEG_LOCK_INIT(keg, 1);
< else
< KEG_LOCK_INIT(keg, 0);
---
> KEG_LOCK_INIT(keg, (arg->flags & UMA_ZONE_MTXCLASS));
1471a1469,1470
> ZONE_LOCK_INIT(zone, (arg->flags & UMA_ZONE_MTXCLASS));
>
1475a1475
> zone->uz_size = arg->size;
1479,1480c1479,1480
< zone->uz_count = BUCKET_MAX;
< return (0);
---
> zone->uz_lockptr = &zone->uz_lock;
> goto out;
1494c1494
< zone->uz_lock = &keg->uk_lock;
---
> zone->uz_lockptr = &keg->uk_lock;
1532c1532
< zone->uz_lock = &keg->uk_lock;
---
> zone->uz_lockptr = &keg->uk_lock;
1547,1548c1547,1549
< if ((keg->uk_flags & UMA_ZONE_MAXBUCKET) == 0)
< zone->uz_count = bucket_select(keg->uk_rsize);
---
> out:
> if ((arg->flags & UMA_ZONE_MAXBUCKET) == 0)
> zone->uz_count = bucket_select(zone->uz_size);
1628a1630
> ZONE_LOCK_FINI(zone);
1852,1854c1854,1856
< uma_zcache_create(char *name, uma_ctor ctor, uma_dtor dtor, uma_init zinit,
< uma_fini zfini, uma_import zimport, uma_release zrelease,
< void *arg, int flags)
---
> uma_zcache_create(char *name, int size, uma_ctor ctor, uma_dtor dtor,
> uma_init zinit, uma_fini zfini, uma_import zimport,
> uma_release zrelease, void *arg, int flags)
1860c1862
< args.size = 0;
---
> args.size = size;
1879c1881
< mtx_lock_flags(b->uz_lock, MTX_DUPOK);
---
> mtx_lock_flags(b->uz_lockptr, MTX_DUPOK);
1882c1884
< mtx_lock_flags(a->uz_lock, MTX_DUPOK);
---
> mtx_lock_flags(a->uz_lockptr, MTX_DUPOK);
2074c2076
< bucket_free(bucket);
---
> bucket_free(zone, bucket);
2244,2261d2245
< static inline void
< zone_relock(uma_zone_t zone, uma_keg_t keg)
< {
< if (zone->uz_lock != &keg->uk_lock) {
< KEG_UNLOCK(keg);
< ZONE_LOCK(zone);
< }
< }
<
< static inline void
< keg_relock(uma_keg_t keg, uma_zone_t zone)
< {
< if (zone->uz_lock != &keg->uk_lock) {
< ZONE_UNLOCK(zone);
< KEG_LOCK(keg);
< }
< }
<
2267c2251
< if (keg == NULL)
---
> if (keg == NULL) {
2268a2253,2254
> KEG_LOCK(keg);
> }
2276a2263
> KEG_UNLOCK(keg);
2282,2283c2269
< * with the keg locked. Caller must call zone_relock() afterwards if the
< * zone lock is required. On NULL the zone lock is held.
---
> * with the keg locked. On NULL no lock is held.
2307c2293
< if (last) {
---
> if (last != NULL) {
2311,2312c2297
< zone_relock(zone, last);
< last = NULL;
---
> KEG_UNLOCK(last);
2328c2313
< keg_relock(keg, zone);
---
> KEG_LOCK(keg);
2338c2323
< zone_relock(zone, keg);
---
> KEG_UNLOCK(keg);
2347a2333
> ZONE_LOCK(zone);
2351c2337,2338
< msleep(zone, zone->uz_lock, PVM, "zonelimit", hz/100);
---
> msleep(zone, zone->uz_lockptr, PVM,
> "zonelimit", hz/100);
2352a2340
> ZONE_UNLOCK(zone);
2390,2391d2377
< ZONE_LOCK(zone);
< /* Try to keep the buckets totally full */
2393a2380
> /* Try to keep the buckets totally full */
2398c2385
< while (slab->us_freecount && i < max)
---
> while (slab->us_freecount && i < max)
2407,2408d2393
< else
< ZONE_UNLOCK(zone);
2417d2401
< int bflags;
2420,2424c2404
< max = zone->uz_count;
< bflags = (flags & ~M_WAITOK) | M_NOWAIT;
< if (zone->uz_flags & UMA_ZFLAG_CACHEONLY)
< bflags |= M_NOVM;
< bucket = bucket_alloc(zone->uz_count, bflags);
---
> bucket = bucket_alloc(zone, M_NOWAIT | (flags & M_NOVM));
2428c2408
< max = MIN(bucket->ub_entries, max);
---
> max = MIN(bucket->ub_entries, zone->uz_count);
2447c2427
< zone->uz_release(zone->uz_arg, bucket->ub_bucket[i],
---
> zone->uz_release(zone->uz_arg, &bucket->ub_bucket[i],
2460c2440
< bucket_free(bucket);
---
> bucket_free(zone, bucket);
2532d2511
< int bflags;
2657,2660c2636
< bflags = M_NOWAIT;
< if (zone->uz_flags & UMA_ZFLAG_CACHEONLY)
< bflags |= M_NOVM;
< bucket = bucket_alloc(zone->uz_count, bflags);
---
> bucket = bucket_alloc(zone, M_NOWAIT);
2674c2650
< bucket_free(bucket);
---
> bucket_free(zone, bucket);
2724d2699
< ZONE_LOCK(zone);
2725a2701
> KEG_LOCK(keg);
2761c2737
< zone_relock(zone, keg);
---
> KEG_UNLOCK(keg);
2762a2739
> ZONE_LOCK(zone);
2764a2742
> ZONE_UNLOCK(zone);
2766d2743
< ZONE_UNLOCK(zone);
2810c2787
< ZONE_LOCK(zone);
---
> KEG_LOCK(keg);
2815c2792
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2830c2807
< ZONE_LOCK(zone);
---
> KEG_LOCK(keg);
2832c2809
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2876d2852
< ZONE_LOCK(zone);
2878a2855
> KEG_LOCK(keg);
2882c2859
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2891d2867
< ZONE_LOCK(zone);
2893a2870
> KEG_LOCK(keg);
2897c2874
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2903a2881
>
2914a2893
>
2929d2907
< ZONE_LOCK(zone);
2931a2910
> KEG_LOCK(keg);
2933c2912
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2943d2921
< ZONE_LOCK(zone);
2944a2923
> KEG_LOCK(keg);
2947c2926
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
2976c2955
< ZONE_LOCK(zone);
---
> KEG_LOCK(keg);
2986c2965,2966
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);
>
3001c2981
< ZONE_LOCK(zone);
---
> KEG_LOCK(keg);
3013c2993
< ZONE_UNLOCK(zone);
---
> KEG_UNLOCK(keg);