Re: [RFC PATCH] x86/sgx: Remove 'reclaim' boolean parameters

From: Dave Hansen
Date: Mon Feb 19 2024 - 10:57:45 EST


On 2/19/24 07:39, Haitao Huang wrote:
> Remove all boolean parameters for 'reclaim' from the function
> sgx_alloc_epc_page() and its callers by making two versions of each
> function.
>
> Also opportunistically remove non-static declaration of
> __sgx_alloc_epc_page() and a typo
>
> Signed-off-by: Haitao Huang <haitao.huang@xxxxxxxxxxxxxxx>
> Suggested-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
> ---
> arch/x86/kernel/cpu/sgx/encl.c | 56 +++++++++++++++++++++------
> arch/x86/kernel/cpu/sgx/encl.h | 6 ++-
> arch/x86/kernel/cpu/sgx/ioctl.c | 23 ++++++++---
> arch/x86/kernel/cpu/sgx/main.c | 68 ++++++++++++++++++++++-----------
> arch/x86/kernel/cpu/sgx/sgx.h | 4 +-
> arch/x86/kernel/cpu/sgx/virt.c | 2 +-
> 6 files changed, 115 insertions(+), 44 deletions(-)

Jarkko, did this turn out how you expected?

I think passing around a function pointer to *only* communicate 1 bit of
information is a _bit_ overkill here.

Simply replacing the bool with:

enum sgx_reclaim {
SGX_NO_RECLAIM,
SGX_DO_RECLAIM
};

would do the same thing. Right?

Are you sure you want a function pointer for this?