Commit 8bc9708b authored by Kalesh Singh's avatar Kalesh Singh
Browse files

ANDROID: mm: swapon: Introduce mthp_reserve_* flags



In order to effectively be able to allocate swap slots for large folios,
it is necessary to partition the swap clusters into subsets based on the
order of the folio that will be allocated from the cluster. This is
because if allocations for small folios are allowed to pollute any swap
cluster, the swap space becomes more and more fragmented and eventually
will only be able to allocate swap slots for order 0 folios.

To partition the swap clusters, reserve a percentage of the clusters for
use by specified higher order folios. This reservation for simplicity is
done at swapon time, since reserving X% after swapon is not guaranteed
to be possbile.

The current state of swap on flag bits (32bit int):

    [0-14] : SWAP_FLAG_PRIO_MASK
    15     : SWAP_FLAG_PREFER
    16     : SWAP_FLAG_DISCARD
    17     : SWAP_FLAG_DISCARD_ONCE
    18     : SWAP_FLAG_DISCARD_PAGES
    [19-31]: Unused

Utilize the unsed bits to specify an order and percentage for the swap
cluster reservation as below:

    19     : SWAP_FLAG_MTHP_RESERVE
    [20-23]: SWAP_FLAG_MTHP_RESERVE_ORDER
    [24-30]: SWAP_FLAG_MTHP_RESERVE_PERCENT
    31     : Unused

SWAP_FLAG_MTHP_RESERVE         - If this bit is set then bits [20-30]
                                 are used to specify the mthp reserve
                                 order and percent.
SWAP_FLAG_MTHP_RESERVE_ORDER   - 4 bits are used which allows specifying
                                 any order from 0 to 15; however order 0
                                 and any order > PMD_ORDER are not valid
SWAP_FLAG_MTHP_RESERVE_PERCENT - 7 bits are used which allows specifying
                                 any percentage; however valid
                                 percentages must be between [1, 100].

Bug: 313807618
Change-Id: I758252c445fcf011fa3aef77e9f7fc6dcc4312a2
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
parent 15f36aa8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment