From c18ec832ed592e4c6171139a8aaadde827cb13da Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 10 May 2024 15:57:25 +0300 Subject: implement faster page allocator --- include/kmi/bits.h | 18 ++++++++++++++++++ include/kmi/pmem.h | 5 ++--- include/kmi/types.h | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/kmi/bits.h b/include/kmi/bits.h index a46f0ec..738f1d5 100644 --- a/include/kmi/bits.h +++ b/include/kmi/bits.h @@ -10,6 +10,7 @@ */ #include +#include #include /** @name Arithmetic integer bit manipulation. */ @@ -145,6 +146,23 @@ static inline void bitmap_clear(void *bmap, size_t n) clear_nbit(bitmap[i], r); } +/** + * Clear all bits in bitmap. + * + * @param bmap Bitmap. + * @param n Size of bitmap. + */ +static inline void bitmap_clear_all(void *bmap, size_t n) +{ + uint8_t *bitmap = bmap; + size_t i = n / 8; + size_t r = n - (i * 8); + memset(bitmap, 0, i); + + for (size_t k = 0; k < r; ++k) + clear_nbit(bitmap[i], k); +} + /** * Find first bit, either set or unset, in bitmap. * diff --git a/include/kmi/pmem.h b/include/kmi/pmem.h index 1eb1972..1917174 100644 --- a/include/kmi/pmem.h +++ b/include/kmi/pmem.h @@ -31,9 +31,8 @@ void mark_used(enum mm_order order, pm_t addr); /** * Allocate physical page. - * Allows the user to specify a hint as to which address to start looking for. - * Useful for allocating many pages for one virtual allocation, for example, and - * allows us to skip already checked pages when allocating a second page. + * Page is returned as a virtual address within the kernel address space, and + * can be converted to a physical address via the \ref __pa() macro. * * @param order Order of page to allocate. * @return pm_t Physical address of page when succesful, else \c NULL. diff --git a/include/kmi/types.h b/include/kmi/types.h index 2443f89..2b1492f 100644 --- a/include/kmi/types.h +++ b/include/kmi/types.h @@ -129,7 +129,9 @@ typedef int32_t ssize_t; /** Maximum alignment. Works for most platforms, I think. */ typedef union { + /** Either the system has an integer as its maximum width */ intmax_t ll; + /** Or it has a long double. */ long double ld; } max_align_t; -- cgit v1.3