kmm_map.c: Add way to test if addr is within kmap area or not
is_kmap_vaddr is added and used to test that a given (v)addr is actually inside the kernel map area. This gives a speed optimization for kmm_unmap, as it is no longer necessary to take the mm_map_lock to check if such a mapping exists; obviously if the address is not within the kmap area, it won't be in the list either.
This commit is contained in:
parent
d199264dca
commit
5dd0474269
@ -192,6 +192,26 @@ static FAR void *map_single_user_page(uintptr_t vaddr)
|
|||||||
return (FAR void *)vaddr;
|
return (FAR void *)vaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: is_kmap_vaddr
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return true if the virtual address, vaddr, lies in the kmap address
|
||||||
|
* space.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* vaddr - The kernel virtual address where the mapping begins.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* True if vaddr is in the kmap address space; false otherwise.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static bool is_kmap_vaddr(uintptr_t vaddr)
|
||||||
|
{
|
||||||
|
return (vaddr >= CONFIG_ARCH_KMAP_VBASE && vaddr < ARCH_KMAP_VEND);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: kmm_map_lock
|
* Name: kmm_map_lock
|
||||||
*
|
*
|
||||||
@ -301,6 +321,15 @@ void kmm_unmap(FAR void *kaddr)
|
|||||||
unsigned int npages;
|
unsigned int npages;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* Speed optimization: check that addr is within kmap area */
|
||||||
|
|
||||||
|
if (!is_kmap_vaddr((uintptr_t)kaddr))
|
||||||
|
{
|
||||||
|
/* Nope: get out */
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Lock the mapping list when we fiddle around with it */
|
/* Lock the mapping list when we fiddle around with it */
|
||||||
|
|
||||||
ret = kmm_map_lock();
|
ret = kmm_map_lock();
|
||||||
|
Loading…
Reference in New Issue
Block a user