tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/external/bsd/drm/dist/bsd-core



lars%heidieker.de@localhost said:
> you can change the amount of memory allocated to the kmem_arena in
> uvm_km.c currently it's 2/3 of kva-space, probably it needs to be a
> bit lower on kva limited machines.

Thanks - I've just changed the "2/3" to "2/4", and now
my X server works again with DRI. This certainly needs
some good heuristics to get the right balance.
As said elsewhere, I'd prefer to give malloc(9) its old
alignment semantics back. There might be more code out there
which relies on it. Here is my patch. This can be somewhat
wasteful for allocation sizes which are just a little bit
larger than a multiple of the page size. For exact
multiples, it should be not different from the existing
code because a page is wasted for bookkeeping anyway.

best regards
Matthias


-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------

Kennen Sie schon unsere app? http://www.fz-juelich.de/app
# HG changeset patch
# Parent b72467925a50848b94d77e1963b1a08b4801ae44

diff -r b72467925a50 sys/kern/kern_malloc.c
--- a/sys/kern/kern_malloc.c    Tue Jan 31 13:28:26 2012 +0100
+++ b/sys/kern/kern_malloc.c    Tue Jan 31 18:34:17 2012 +0100
@@ -108,10 +108,13 @@
 #endif /* MALLOCLOG */
 {
        const int kmflags = (flags & M_NOWAIT) ? KM_NOSLEEP : KM_SLEEP;
-       const size_t allocsize = sizeof(struct malloc_header) + size;
+       size_t allocsize = sizeof(struct malloc_header) + size;
        struct malloc_header *mh;
        void *p;
 
+       if (size >= NBPG)
+               allocsize = size + NBPG;
+
        p = kmem_intr_alloc(allocsize, kmflags);
        if (p == NULL)
                return NULL;
@@ -119,6 +122,10 @@
        if ((flags & M_ZERO) != 0) {
                memset(p, 0, allocsize);
        }
+       if (size >= NBPG) {
+               p = (char *)p + NBPG - sizeof(*mh);
+               allocsize = size + sizeof(*mh);
+       }
        mh = (void *)p;
        mh->mh_size = allocsize;
 
@@ -137,11 +144,20 @@
 #endif /* MALLOCLOG */
 {
        struct malloc_header *mh;
+       size_t allocsize;
 
        mh = addr;
        mh--;
 
-       kmem_intr_free(mh, mh->mh_size);
+       if (mh->mh_size >= NBPG + sizeof(*mh)) {
+               addr = (char *)addr - NBPG;
+               allocsize = mh->mh_size + NBPG - sizeof(*mh);
+       } else {
+               addr = mh;
+               allocsize = mh->mh_size;
+       }
+               
+       kmem_intr_free(addr, allocsize);
 }
 
 /*


Home | Main Index | Thread Index | Old Index