Re: [PATCH v2 09/20] s390/zcrypt: Introduce pre-allocated device status array for ep11 misc

Harald Freudenberger
2025-03-25T11:09:39Z

On 2025-03-19 19:02, Holger Dengler wrote:
> On 04/03/2025 18:21, Harald Freudenberger wrote:
>> Introduce a pre-allocated device status array memory together with
>> a mutex controlling the occupation to be used by the findcard()
>> 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.
>
> I have the same concerns as for patch 8/20. Please think about an
> alternative to the dev_status_mem sharing, because it synchronizes all
> findcard() calls.
>

There are not so many findcard() calls in parallel. And the lock is only
during running the findcard itself. Ok, the function may need a couple
of milliseconds and during this time block other callers but as I wrote,
I do not expect this to have impact on any load.

I could think of giving this function a ptr to memory from the caller.
So then all ioctl calls could alloc some work mem and pass it down
to findcard(). On the other side exactly these callers have time and
a short delay because of the mutex does no harm. The real issue is
with a pkey request coming via in-kernel pkey API. The pkey_cca handler
could hold some memory for this purpose - but with that I am only
moving the mem + mutex one level up. I have no other idea.

Btw. the exit() function now locks the mutex before freeing the memory.
-> v3

>>
>> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
>> ---
>> drivers/s390/crypto/zcrypt_ep11misc.c | 46
>> +++++++++++++++++++++------
>> 1 file changed, 36 insertions(+), 10 deletions(-)