diff mbox series

[v2,2/6] xen/arm: optee: check for preemption while freeing shared buffers

Message ID 20190918185041.22738-3-volodymyr_babchuk@epam.com (mailing list archive)
State Superseded
Headers show
Series arch/arm: optee: fix TODOs and change status to "Tech Preview" | expand

Commit Message

Volodymyr Babchuk Sept. 18, 2019, 6:50 p.m. UTC
We can check for hypercall_preempt_check() in the loop inside
optee_relinquish_resources() to increase hypervisor responsiveness in
case if preemption is required.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

---

Changes from v1:
 - Removed extra hypercall_preempt_check()
 - Updated the commit message
---
 xen/arch/arm/tee/optee.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Julien Grall Sept. 23, 2019, 9:30 a.m. UTC | #1
Hi Volodymyr,

On 18/09/2019 19:50, Volodymyr Babchuk wrote:
> We can check for hypercall_preempt_check() in the loop inside
> optee_relinquish_resources() to increase hypervisor responsiveness in
> case if preemption is required.
> 
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Cheers,

> 
> ---
> 
> Changes from v1:
>   - Removed extra hypercall_preempt_check()
>   - Updated the commit message
> ---
>   xen/arch/arm/tee/optee.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
> index d64e9c3b85..55d11b91a9 100644
> --- a/xen/arch/arm/tee/optee.c
> +++ b/xen/arch/arm/tee/optee.c
> @@ -633,17 +633,14 @@ static int optee_relinquish_resources(struct domain *d)
>       list_for_each_entry_safe( shm_rpc, shm_rpc_tmp, &ctx->shm_rpc_list, list )
>           free_shm_rpc(ctx, shm_rpc->cookie);
>   
> -    if ( hypercall_preempt_check() )
> -        return -ERESTART;
> -
> -    /*
> -     * TODO: Guest can pin up to MAX_TOTAL_SMH_BUF_PG pages and all of
> -     * them will be put in this loop. It is worth considering to
> -     * check for preemption inside the loop.
> -     */
>       list_for_each_entry_safe( optee_shm_buf, optee_shm_buf_tmp,
>                                 &ctx->optee_shm_buf_list, list )
> +    {
> +        if ( hypercall_preempt_check() )
> +            return -ERESTART;
> +
>           free_optee_shm_buf(ctx, optee_shm_buf->cookie);
> +    }
>   
>       if ( hypercall_preempt_check() )
>           return -ERESTART;
>
diff mbox series

Patch

diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index d64e9c3b85..55d11b91a9 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -633,17 +633,14 @@  static int optee_relinquish_resources(struct domain *d)
     list_for_each_entry_safe( shm_rpc, shm_rpc_tmp, &ctx->shm_rpc_list, list )
         free_shm_rpc(ctx, shm_rpc->cookie);
 
-    if ( hypercall_preempt_check() )
-        return -ERESTART;
-
-    /*
-     * TODO: Guest can pin up to MAX_TOTAL_SMH_BUF_PG pages and all of
-     * them will be put in this loop. It is worth considering to
-     * check for preemption inside the loop.
-     */
     list_for_each_entry_safe( optee_shm_buf, optee_shm_buf_tmp,
                               &ctx->optee_shm_buf_list, list )
+    {
+        if ( hypercall_preempt_check() )
+            return -ERESTART;
+
         free_optee_shm_buf(ctx, optee_shm_buf->cookie);
+    }
 
     if ( hypercall_preempt_check() )
         return -ERESTART;