type pageBits … // get returns the value of the i'th bit in the bitmap. func (b *pageBits) get(i uint) uint { … } // block64 returns the 64-bit aligned block of bits containing the i'th bit. func (b *pageBits) block64(i uint) uint64 { … } // set sets bit i of pageBits. func (b *pageBits) set(i uint) { … } // setRange sets bits in the range [i, i+n). func (b *pageBits) setRange(i, n uint) { … } // setAll sets all the bits of b. func (b *pageBits) setAll() { … } // setBlock64 sets the 64-bit aligned block of bits containing the i'th bit that // are set in v. func (b *pageBits) setBlock64(i uint, v uint64) { … } // clear clears bit i of pageBits. func (b *pageBits) clear(i uint) { … } // clearRange clears bits in the range [i, i+n). func (b *pageBits) clearRange(i, n uint) { … } // clearAll frees all the bits of b. func (b *pageBits) clearAll() { … } // clearBlock64 clears the 64-bit aligned block of bits containing the i'th bit that // are set in v. func (b *pageBits) clearBlock64(i uint, v uint64) { … } // popcntRange counts the number of set bits in the // range [i, i+n). func (b *pageBits) popcntRange(i, n uint) (s uint) { … } type pallocBits … // summarize returns a packed summary of the bitmap in pallocBits. func (b *pallocBits) summarize() pallocSum { … } // find searches for npages contiguous free pages in pallocBits and returns // the index where that run starts, as well as the index of the first free page // it found in the search. searchIdx represents the first known free page and // where to begin the next search from. // // If find fails to find any free space, it returns an index of ^uint(0) and // the new searchIdx should be ignored. // // Note that if npages == 1, the two returned values will always be identical. func (b *pallocBits) find(npages uintptr, searchIdx uint) (uint, uint) { … } // find1 is a helper for find which searches for a single free page // in the pallocBits and returns the index. // // See find for an explanation of the searchIdx parameter. func (b *pallocBits) find1(searchIdx uint) uint { … } // findSmallN is a helper for find which searches for npages contiguous free pages // in this pallocBits and returns the index where that run of contiguous pages // starts as well as the index of the first free page it finds in its search. // // See find for an explanation of the searchIdx parameter. // // Returns a ^uint(0) index on failure and the new searchIdx should be ignored. // // findSmallN assumes npages <= 64, where any such contiguous run of pages // crosses at most one aligned 64-bit boundary in the bits. func (b *pallocBits) findSmallN(npages uintptr, searchIdx uint) (uint, uint) { … } // findLargeN is a helper for find which searches for npages contiguous free pages // in this pallocBits and returns the index where that run starts, as well as the // index of the first free page it found it its search. // // See alloc for an explanation of the searchIdx parameter. // // Returns a ^uint(0) index on failure and the new searchIdx should be ignored. // // findLargeN assumes npages > 64, where any such run of free pages // crosses at least one aligned 64-bit boundary in the bits. func (b *pallocBits) findLargeN(npages uintptr, searchIdx uint) (uint, uint) { … } // allocRange allocates the range [i, i+n). func (b *pallocBits) allocRange(i, n uint) { … } // allocAll allocates all the bits of b. func (b *pallocBits) allocAll() { … } // free1 frees a single page in the pallocBits at i. func (b *pallocBits) free1(i uint) { … } // free frees the range [i, i+n) of pages in the pallocBits. func (b *pallocBits) free(i, n uint) { … } // freeAll frees all the bits of b. func (b *pallocBits) freeAll() { … } // pages64 returns a 64-bit bitmap representing a block of 64 pages aligned // to 64 pages. The returned block of pages is the one containing the i'th // page in this pallocBits. Each bit represents whether the page is in-use. func (b *pallocBits) pages64(i uint) uint64 { … } // allocPages64 allocates a 64-bit block of 64 pages aligned to 64 pages according // to the bits set in alloc. The block set is the one containing the i'th page. func (b *pallocBits) allocPages64(i uint, alloc uint64) { … } // findBitRange64 returns the bit index of the first set of // n consecutive 1 bits. If no consecutive set of 1 bits of // size n may be found in c, then it returns an integer >= 64. // n must be > 0. func findBitRange64(c uint64, n uint) uint { … } type pallocData … // allocRange sets bits [i, i+n) in the bitmap to 1 and // updates the scavenged bits appropriately. func (m *pallocData) allocRange(i, n uint) { … } // allocAll sets every bit in the bitmap to 1 and updates // the scavenged bits appropriately. func (m *pallocData) allocAll() { … }