lkml.org 
[lkml]   [2024]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v10 11/14] x86/sgx: Abstract check for global reclaimable pages
    Date
    From: Kristen Carlson Accardi <kristen@linux.intel.com>

    To determine if any page available for reclamation at the global level,
    only checking for emptiness of the global LRU is not adequate when pages
    are tracked in multiple LRUs, one per cgroup. For this purpose, create a
    new helper, sgx_can_reclaim(), currently only checks the global LRU,
    later will check emptiness of LRUs of all cgroups when per-cgroup
    tracking is turned on. Replace all the checks of the global LRU,
    list_empty(&sgx_global_lru.reclaimable), with calls to
    sgx_can_reclaim().

    Co-developed-by: Sean Christopherson <sean.j.christopherson@intel.com>
    Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
    Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
    Co-developed-by: Haitao Huang <haitao.huang@linux.intel.com>
    Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
    ---
    V10:
    - Add comments for the new function. (Jarkko)

    V7:
    - Split this out from the big patch, #10 in V6. (Dave, Kai)
    ---
    arch/x86/kernel/cpu/sgx/main.c | 12 ++++++++++--
    1 file changed, 10 insertions(+), 2 deletions(-)

    diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
    index c94f8b49e6f2..7f92455d957d 100644
    --- a/arch/x86/kernel/cpu/sgx/main.c
    +++ b/arch/x86/kernel/cpu/sgx/main.c
    @@ -37,6 +37,14 @@ static inline struct sgx_epc_lru_list *sgx_lru_list(struct sgx_epc_page *epc_pag
    return &sgx_global_lru;
    }

    +/*
    + * Check if there is any reclaimable page at global level.
    + */
    +static inline bool sgx_can_reclaim(void)
    +{
    + return !list_empty(&sgx_global_lru.reclaimable);
    +}
    +
    static atomic_long_t sgx_nr_free_pages = ATOMIC_LONG_INIT(0);

    /* Nodes with one or more EPC sections. */
    @@ -391,7 +399,7 @@ unsigned int sgx_reclaim_pages(struct sgx_epc_lru_list *lru, struct mm_struct *c
    static bool sgx_should_reclaim(unsigned long watermark)
    {
    return atomic_long_read(&sgx_nr_free_pages) < watermark &&
    - !list_empty(&sgx_global_lru.reclaimable);
    + sgx_can_reclaim();
    }

    static void sgx_reclaim_pages_global(struct mm_struct *charge_mm)
    @@ -593,7 +601,7 @@ struct sgx_epc_page *sgx_alloc_epc_page(void *owner, enum sgx_reclaim reclaim)
    break;
    }

    - if (list_empty(&sgx_global_lru.reclaimable)) {
    + if (!sgx_can_reclaim()) {
    page = ERR_PTR(-ENOMEM);
    break;
    }
    --
    2.25.1

    \
     
     \ /
      Last update: 2024-05-27 16:13    [W:4.156 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site