Re: [PATCH v4 10/24] s390/zcrypt: Introduce pre-allocated device status array for ep11 misc

Holger Dengler
2025-04-11T13:08:59Z

On 09/04/2025 16:02, Harald Freudenberger wrote:
> Introduce a pre-allocated device status array memory together with
> a mutex controlling the occupation to be used by the findcard()

findcard2()?
(sorry, missed that one for the previous patch)

> function. Limit the device status array to max 128 cards and max
> 128 domains to reduce the size of this pre-allocated memory to 64 KB.
>
> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>

> ---
> drivers/s390/crypto/zcrypt_ep11misc.c | 48 +++++++++++++++++++++------
> 1 file changed, 38 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/s390/crypto/zcrypt_ep11misc.c b/drivers/s390/crypto/zcrypt_ep11misc.c
> index e1a1d047ac8a..688624b75500 100644
> --- a/drivers/s390/crypto/zcrypt_ep11misc.c
> +++ b/drivers/s390/crypto/zcrypt_ep11misc.c
> @@ -39,6 +39,22 @@ static const u8 def_iv[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
> #define CPRB_MEMPOOL_ITEM_SIZE (8 * 1024)
> static mempool_t *cprb_mempool;
>
> +/*
> + * This is a pre-allocated memory for the device status array
> + * used within the findcard() functions. It is currently

findcard2()?

> + * 128 * 128 * 4 bytes = 64 KB big. Usage of this memory is
> + * controlled via dev_status_mem_mutex. Needs adaption if more
> + * than 128 cards or domains to be are supported.
> + */
> +#define ZCRYPT_DEV_STATUS_CARD_MAX 128
> +#define ZCRYPT_DEV_STATUS_QUEUE_MAX 128
> +#define ZCRYPT_DEV_STATUS_ENTRIES (ZCRYPT_DEV_STATUS_CARD_MAX * \
> + ZCRYPT_DEV_STATUS_QUEUE_MAX)
> +#define ZCRYPT_DEV_STATUS_EXT_SIZE (ZCRYPT_DEV_STATUS_ENTRIES * \
> + sizeof(struct zcrypt_device_status_ext))
> +static void *dev_status_mem;
> +static DEFINE_MUTEX(dev_status_mem_mutex);
> +
> /* ep11 card info cache */
> struct card_list_entry {
> struct list_head list;
[...]

--
Mit freundlichen Grüßen / Kind regards
Holger Dengler
--
IBM Systems, Linux on IBM Z Development
dengler@linux.ibm.com