mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 13:43:45 +03:00
Add a kmalloc lock. This definitely reduces flakiness.
This commit is contained in:
parent
8e27cf2428
commit
82dae8fc90
Notes:
sideshowbarker
2024-07-19 18:39:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/82dae8fc905
@ -33,6 +33,11 @@ public:
|
||||
m_lock = 0;
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
m_lock = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
volatile dword m_lock { 0 };
|
||||
};
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "VGA.h"
|
||||
#include "system.h"
|
||||
#include "Assertions.h"
|
||||
#include <AK/Lock.h>
|
||||
|
||||
#define SANITIZE_KMALLOC
|
||||
|
||||
@ -29,9 +30,12 @@ PRIVATE BYTE alloc_map[POOL_SIZE / CHUNK_SIZE / 8];
|
||||
DWORD sum_alloc = 0;
|
||||
DWORD sum_free = POOL_SIZE;
|
||||
|
||||
static SpinLock s_kmallocLock;
|
||||
|
||||
PUBLIC void
|
||||
kmalloc_init()
|
||||
{
|
||||
s_kmallocLock.init();
|
||||
memset( &alloc_map, 0, sizeof(alloc_map) );
|
||||
memset( (void *)BASE_PHYS, 0, POOL_SIZE );
|
||||
|
||||
@ -42,6 +46,8 @@ kmalloc_init()
|
||||
PUBLIC void *
|
||||
kmalloc( DWORD size )
|
||||
{
|
||||
Locker locker(s_kmallocLock);
|
||||
|
||||
DWORD chunks_needed, chunks_here, first_chunk;
|
||||
DWORD real_size;
|
||||
DWORD i, j, k;
|
||||
@ -117,6 +123,8 @@ kfree( void *ptr )
|
||||
if( !ptr )
|
||||
return;
|
||||
|
||||
Locker locker(s_kmallocLock);
|
||||
|
||||
allocation_t *a = (allocation_t *)((((BYTE *)ptr) - sizeof(allocation_t)));
|
||||
|
||||
#if 0
|
||||
|
Loading…
Reference in New Issue
Block a user