Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog.d/20260426_150000_issue360_kernel_compaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: patch
---

### Changed
- Compact `include/pmm/**` below the 5000-line kernel subtree budget while preserving linked include anchors.
- Refresh the generated single-header bundle and rollout checker for the 5000-line budget.
68 changes: 24 additions & 44 deletions include/pmm/address_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,30 @@ namespace pmm {
## pmm-addresstraits
*/
template <typename IndexT, std::size_t GranuleSz> struct AddressTraits {
static_assert(std::is_unsigned<IndexT>::value,
"AddressTraits: IndexT must be an unsigned integer type");
static_assert(
GranuleSz >= 4,
"AddressTraits: GranuleSz must be >= 4 (minimum architecture word size)");
static_assert((GranuleSz & (GranuleSz - 1)) == 0,
"AddressTraits: GranuleSz must be a power of 2");
using index_type = IndexT;
static constexpr std::size_t granule_size = GranuleSz;
static constexpr index_type no_block = std::numeric_limits<IndexT>::max();
/*
### pmm-addresstraits-bytes_to_granules
*/
static constexpr index_type bytes_to_granules(std::size_t bytes) noexcept {
if (bytes == 0)
return static_cast<index_type>(0);
if (bytes > std::numeric_limits<std::size_t>::max() - (granule_size - 1))
return static_cast<index_type>(0);
std::size_t granules = (bytes + granule_size - 1) / granule_size;
if (granules > static_cast<std::size_t>(std::numeric_limits<IndexT>::max()))
return static_cast<index_type>(0);
return static_cast<index_type>(granules);
}
/*
### pmm-addresstraits-granules_to_bytes
*/
static constexpr std::size_t granules_to_bytes(index_type granules) noexcept {
return static_cast<std::size_t>(granules) * granule_size;
}
/*
### pmm-addresstraits-idx_to_byte_off
*/
static constexpr std::size_t idx_to_byte_off(index_type idx) noexcept {
return static_cast<std::size_t>(idx) * granule_size;
}
/*
### pmm-addresstraits-byte_off_to_idx
*/
static index_type byte_off_to_idx(std::size_t byte_off) noexcept {
assert(byte_off % granule_size == 0);
assert(byte_off / granule_size <=
static_cast<std::size_t>(std::numeric_limits<IndexT>::max()));
return static_cast<index_type>(byte_off / granule_size);
}
static_assert(std::is_unsigned<IndexT>::value, "AddressTraits: IndexT must be an unsigned integer type");
static_assert( GranuleSz >= 4, "AddressTraits: GranuleSz must be >= 4 (minimum architecture word size)");
static_assert((GranuleSz & (GranuleSz - 1)) == 0, "AddressTraits: GranuleSz must be a power of 2");
using index_type = IndexT;
static constexpr std::size_t granule_size = GranuleSz;
static constexpr index_type no_block = std::numeric_limits<IndexT>::max();
static constexpr index_type bytes_to_granules(std::size_t bytes) noexcept {
if (bytes == 0) return static_cast<index_type>(0);
if (bytes > std::numeric_limits<std::size_t>::max() - (granule_size - 1)) return static_cast<index_type>(0);
std::size_t granules = (bytes + granule_size - 1) / granule_size;
if (granules > static_cast<std::size_t>(std::numeric_limits<IndexT>::max())) return static_cast<index_type>(0);
return static_cast<index_type>(granules);
}
static constexpr std::size_t granules_to_bytes(index_type granules) noexcept {
return static_cast<std::size_t>(granules) * granule_size;
}
static constexpr std::size_t idx_to_byte_off(index_type idx) noexcept {
return static_cast<std::size_t>(idx) * granule_size;
}
static index_type byte_off_to_idx(std::size_t byte_off) noexcept {
assert(byte_off % granule_size == 0);
assert(byte_off / granule_size <= static_cast<std::size_t>(std::numeric_limits<IndexT>::max()));
return static_cast<index_type>(byte_off / granule_size);
}
};
using SmallAddressTraits = AddressTraits<std::uint16_t, 16>;
using DefaultAddressTraits = AddressTraits<std::uint32_t, 16>;
Expand Down
Loading
Loading