svn commit: r249248 - projects/counters/sys/vm
Gleb Smirnoff
glebius at FreeBSD.org
Mon Apr 8 08:35:25 UTC 2013
Author: glebius
Date: Mon Apr 8 08:35:24 2013
New Revision: 249248
URL: http://svnweb.freebsd.org/changeset/base/249248
Log:
Simplify uk_ppera calculation using howmany() macro.
Suggested by: antoine
Modified:
projects/counters/sys/vm/uma_core.c
Modified: projects/counters/sys/vm/uma_core.c
==============================================================================
--- projects/counters/sys/vm/uma_core.c Mon Apr 8 08:33:31 2013 (r249247)
+++ projects/counters/sys/vm/uma_core.c Mon Apr 8 08:35:24 2013 (r249248)
@@ -1140,10 +1140,8 @@ keg_small_init(uma_keg_t keg)
if (keg->uk_flags & UMA_ZONE_PCPU) {
keg->uk_slabsize = sizeof(struct pcpu);
- keg->uk_ppera = mp_ncpus/(PAGE_SIZE/sizeof(struct pcpu));
- /* Account for remainder. */
- if (mp_ncpus * sizeof(struct pcpu) > PAGE_SIZE * keg->uk_ppera)
- keg->uk_ppera++;
+ keg->uk_ppera = howmany(mp_ncpus * sizeof(struct pcpu),
+ PAGE_SIZE);
} else {
keg->uk_slabsize = UMA_SLAB_SIZE;
keg->uk_ppera = 1;
@@ -1226,7 +1224,6 @@ keg_small_init(uma_keg_t keg)
static void
keg_large_init(uma_keg_t keg)
{
- int pages;
KASSERT(keg != NULL, ("Keg is null in keg_large_init"));
KASSERT((keg->uk_flags & UMA_ZFLAG_CACHEONLY) == 0,
@@ -1234,14 +1231,8 @@ keg_large_init(uma_keg_t keg)
KASSERT((keg->uk_flags & UMA_ZONE_PCPU) == 0,
("%s: Cannot large-init a UMA_ZONE_PCPU keg", __func__));
- pages = keg->uk_size / PAGE_SIZE;
-
- /* Account for remainder */
- if ((pages * PAGE_SIZE) < keg->uk_size)
- pages++;
-
- keg->uk_ppera = pages;
- keg->uk_slabsize = pages * PAGE_SIZE;
+ keg->uk_ppera = howmany(keg->uk_size, PAGE_SIZE);
+ keg->uk_slabsize = keg->uk_ppera * PAGE_SIZE;
keg->uk_ipers = 1;
keg->uk_rsize = keg->uk_size;
More information about the svn-src-projects
mailing list