From: Miod Vallat Subject: kernel: cut code in subr_blist To: tech@openbsd.org Date: Sat, 24 Oct 2026 18:02:52 +0000 There are a few routines in kern/subr_blist.c, which are either only used by the regress test but never by the kernel, or are only used by the kernel and the hibernate code. And of course these functions turn out to be the only users of some more functions. The following diff leaves out these functions unless needed. Saves about 1.5KB (before compression) on amd64 install media, 3KB on hppa GENERIC. Index: kern/subr_blist.c =================================================================== RCS file: /OpenBSD/src/sys/kern/subr_blist.c,v diff -u -p -r1.4 subr_blist.c --- kern/subr_blist.c 30 May 2023 08:30:01 -0000 1.4 +++ kern/subr_blist.c 24 Oct 2026 17:59:46 -0000 @@ -144,16 +144,22 @@ static void blst_leaf_free(blmeta_t *sca static void blst_meta_free(blmeta_t *scan, swblk_t freeBlk, swblk_t count, swblk_t radix, swblk_t skip, swblk_t blk); +#if (!defined(_KERNEL) && defined(BLIST_DEBUG)) || defined(HIBERNATE) static swblk_t blst_leaf_fill(blmeta_t *scan, swblk_t blk, swblk_t count); static swblk_t blst_meta_fill(blmeta_t *scan, swblk_t fillBlk, swblk_t count, swblk_t radix, swblk_t skip, swblk_t blk); +#endif +#if !defined(_KERNEL) && defined(BLIST_DEBUG) static void blst_copy(blmeta_t *scan, swblk_t blk, swblk_t radix, swblk_t skip, blist_t dest, swblk_t count); +#endif static swblk_t blst_radix_init(blmeta_t *scan, swblk_t radix, swblk_t skip, swblk_t count); +#if (!defined(_KERNEL) && defined(BLIST_DEBUG)) || defined(HIBERNATE) static int blst_radix_gapfind(blmeta_t *scan, swblk_t blk, swblk_t radix, swblk_t skip, int state, swblk_t *maxbp, swblk_t *maxep, swblk_t *bp, swblk_t *ep); +#endif #if defined(BLIST_DEBUG) || defined(DDB) static void blst_radix_print(blmeta_t *scan, swblk_t blk, @@ -259,6 +265,7 @@ blist_alloc(blist_t bl, swblk_t count) return(blk); } +#if !defined(_KERNEL) && defined(BLIST_DEBUG) swblk_t blist_allocat(blist_t bl, swblk_t count, swblk_t blkat) { @@ -282,6 +289,7 @@ blist_allocat(blist_t bl, swblk_t count, } return(blk); } +#endif /* !_KERNEL && BLIST_DEBUG */ /* * blist_free() - free up space in the block bitmap. Return the base @@ -306,6 +314,7 @@ blist_free(blist_t bl, swblk_t blkno, sw } } +#if (!defined(_KERNEL) && defined(BLIST_DEBUG)) || defined(HIBERNATE) /* * blist_fill() - mark a region in the block bitmap as off-limits * to the allocator (i.e. allocate it), ignoring any @@ -335,7 +344,9 @@ blist_fill(blist_t bl, swblk_t blkno, sw return 0; } } +#endif /* (!_KERNEL && BLIST_DEBUG) || HIBERNATE */ +#if !defined(_KERNEL) && defined(BLIST_DEBUG) /* * blist_resize() - resize an existing radix tree to handle the * specified number of blocks. This will reallocate @@ -363,6 +374,9 @@ blist_resize(blist_t *pbl, swblk_t count } blist_destroy(save); } +#endif /* !_KERNEL && BLIST_DEBUG */ + +#if (!defined(_KERNEL) && defined(BLIST_DEBUG)) || defined(HIBERNATE) #define GAPFIND_FIRSTFREE 0 #define GAPFIND_FIRSTUSED 1 @@ -491,6 +505,7 @@ blst_radix_gapfind(blmeta_t *scan, swblk return state; } +#endif /* (!_KERNEL && BLIST_DEBUG) || HIBERNATE */ #if defined(BLIST_DEBUG) || defined(DDB) @@ -846,6 +861,7 @@ blst_meta_free(blmeta_t *scan, swblk_t f } } +#if (!defined(_KERNEL) && defined(BLIST_DEBUG)) || defined(HIBERNATE) /* * BLST_LEAF_FILL() - allocate specific blocks in leaf bitmap * @@ -950,7 +966,9 @@ blst_meta_fill(blmeta_t *scan, swblk_t f scan->u.bmu_avail -= nblks; return (nblks); } +#endif /* (!_KERNEL && BLIST_DEBUG) || HIBERNATE */ +#if !defined(_KERNEL) && defined(BLIST_DEBUG) /* * BLIST_RADIX_COPY() - copy one radix tree to another * @@ -1038,6 +1056,7 @@ blst_copy(blmeta_t *scan, swblk_t blk, s blk += (swblk_t)radix; } } +#endif /* !_KERNEL && BLIST_DEBUG */ /* * BLST_RADIX_INIT() - initialize radix tree