NetBSD-Bugs archive

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

kern/44969: vmem_xalloc() don't search best-fit free segment in spite of VMEM_BESTFIT



>Number:         44969
>Category:       kern
>Synopsis:       vmem_xalloc() don't search best-fit free segment in spite of 
>VMEM_BESTFIT
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 15 04:30:00 +0000 2011
>Originator:     Fumiyuki Yoshida
>Release:        5.1
>Organization:
>Environment:
I find this problem when I read source code for study.So I don't have the 
netbsd installed machine.
>Description:
Though you call vmem_xalloc() with VM_BESTFIT(allocation strategy) , you find 
that vmem_xalloc() don't search best-fit free segment. 
VMEM_BESTFIT means that using the smallest free segment that can satisfy the 
allocation.But current implementation use the free segment which is found at 
first.(not search best-fit free segment)


>How-To-Repeat:
Call vmem_xalloc() with VM_BESTFIT.
>Fix:
The patch for the bug is following.

Index: subr_vmem.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_vmem.c,v
retrieving revision 1.58
diff -r1.58 subr_vmem.c
891a892
>       bt_t *bestfit = NULL;
946c947,948
<                               if (bt->bt_size >= size) {
---
>                               /* very best-fit */
>                               if (bt->bt_size == size) {
952a955,962
>                               else if( bestfit == NULL || bestfit->size > 
> bt->size){
>                                       bestfit = bt;
>                               }
>                       }
> 
>                       if( bestfit ){
>                               bt = bestfit;
>                               goto gotit;



Home | Main Index | Thread Index | Old Index