commit-hurd
[Top][All Lists]
Advanced

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

[hurd] 04/64: Fix mach-defpager's kalloc values


From: Samuel Thibault
Subject: [hurd] 04/64: Fix mach-defpager's kalloc values
Date: Wed, 10 Dec 2014 15:17:03 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit cfafc1a905f11da2b856aecea02b8c7e1f95e5dd
Author: Samuel Thibault <address@hidden>
Date:   Mon Nov 10 03:32:19 2014 +0100

    Fix mach-defpager's kalloc values
    
    * mach-defpager/kalloc.c (MINSIZE): Set to sizeof(vm_offset_t) instead
    of hardcoded 4.
    (kalloc_init): Set kalloc_max to MINSIZE << (KLIST_MAX-1) instead of
    hardcoded 16384.
    (kalloc, kfree): Use the cache for the maximum size too.
---
 mach-defpager/kalloc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/mach-defpager/kalloc.c b/mach-defpager/kalloc.c
index 2f8f002..ef844ac 100644
--- a/mach-defpager/kalloc.c
+++ b/mach-defpager/kalloc.c
@@ -58,7 +58,7 @@ void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) 
(void) = init_hook;
  *     next highest power of 2.
  */
 vm_size_t      kalloc_max;             /* max before we use vm_allocate */
-#define                MINSIZE 4               /* minimum allocation size */
+#define                MINSIZE sizeof(vm_offset_t)             /* minimum 
allocation size */
 
 struct free_list {
        pthread_spinlock_t      lock;
@@ -99,8 +99,8 @@ void kalloc_init(void)
         * 16Kbytes, whichever is less.
         */
 
-       if (vm_page_size > 16*1024)
-               kalloc_max = 16*1024;
+       if (vm_page_size > (MINSIZE << (KLIST_MAX-1)))
+               kalloc_max = (MINSIZE << (KLIST_MAX-1));
        else
                kalloc_max = vm_page_size;
 
@@ -197,7 +197,7 @@ void *kalloc(vm_size_t size)
        /* compute the size of the block that we will actually allocate */
 
        allocsize = size;
-       if (size < kalloc_max) {
+       if (size <= kalloc_max) {
            allocsize = MINSIZE;
            fl = kfree_list;
            while (allocsize < size) {
@@ -211,7 +211,7 @@ void *kalloc(vm_size_t size)
         * and allocate.
         */
 
-       if (allocsize < kalloc_max) {
+       if (allocsize <= kalloc_max) {
            pthread_spin_lock(&fl->lock);
            if ((addr = fl->head) != 0) {
                fl->head = *(vm_offset_t *)addr;
@@ -241,7 +241,7 @@ kfree(      void *data,
        struct free_list *fl;
 
        freesize = size;
-       if (size < kalloc_max) {
+       if (size <= kalloc_max) {
            freesize = MINSIZE;
            fl = kfree_list;
            while (freesize < size) {
@@ -250,7 +250,7 @@ kfree(      void *data,
            }
        }
 
-       if (freesize < kalloc_max) {
+       if (freesize <= kalloc_max) {
            pthread_spin_lock(&fl->lock);
            *(vm_offset_t *)data = fl->head;
            fl->head = (vm_offset_t) data;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]