diff mbox series

[v10,18/19] KVM: s390: pv: avoid export before import if possible

Message ID 20220414080311.1084834-19-imbrenda@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series KVM: s390: pv: implement lazy destroy for reboot | expand

Commit Message

Claudio Imbrenda April 14, 2022, 8:03 a.m. UTC
If the appropriate UV feature bit is set, there is no need to perform
an export before import.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 arch/s390/kernel/uv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Nico Boehr May 30, 2022, 10:07 a.m. UTC | #1
On Thu, 2022-04-14 at 10:03 +0200, Claudio Imbrenda wrote:

> diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
> index e358b8bd864b..43393568f844 100644
> --- a/arch/s390/kernel/uv.c
> +++ b/arch/s390/kernel/uv.c
> @@ -236,7 +236,8 @@ static int make_secure_pte(pte_t *ptep, unsigned
> long addr,
>  
>  static bool should_export_before_import(struct uv_cb_header *uvcb,
> struct mm_struct *mm)
>  {
> -       return uvcb->cmd != UVC_CMD_UNPIN_PAGE_SHARED &&
> +       return !test_bit_inv(BIT_UV_FEAT_MISC,
> &uv_info.uv_feature_indications) &&
> +               uvcb->cmd != UVC_CMD_UNPIN_PAGE_SHARED &&
>                 atomic_read(&mm->context.protected_count) > 1;

This might be nicer to read like this:

if (test_bit_inv(BIT_UV_FEAT_MISC, &uv_info.uv_feature_indications))
  return false;

if (uvcb->cmd == UVC_CMD_UNPIN_PAGE_SHARED)
  return false;

return atomic_read(&mm->context.protected_count) > 1;
Claudio Imbrenda May 30, 2022, 11:16 a.m. UTC | #2
On Mon, 30 May 2022 12:07:43 +0200
Nico Boehr <nrb@linux.ibm.com> wrote:

> On Thu, 2022-04-14 at 10:03 +0200, Claudio Imbrenda wrote:
> 
> > diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
> > index e358b8bd864b..43393568f844 100644
> > --- a/arch/s390/kernel/uv.c
> > +++ b/arch/s390/kernel/uv.c
> > @@ -236,7 +236,8 @@ static int make_secure_pte(pte_t *ptep, unsigned
> > long addr,
> >  
> >  static bool should_export_before_import(struct uv_cb_header *uvcb,
> > struct mm_struct *mm)
> >  {
> > -       return uvcb->cmd != UVC_CMD_UNPIN_PAGE_SHARED &&
> > +       return !test_bit_inv(BIT_UV_FEAT_MISC,
> > &uv_info.uv_feature_indications) &&
> > +               uvcb->cmd != UVC_CMD_UNPIN_PAGE_SHARED &&
> >                 atomic_read(&mm->context.protected_count) > 1;  
> 
> This might be nicer to read like this:
> 
> if (test_bit_inv(BIT_UV_FEAT_MISC, &uv_info.uv_feature_indications))
>   return false;
> 
> if (uvcb->cmd == UVC_CMD_UNPIN_PAGE_SHARED)
>   return false;
> 
> return atomic_read(&mm->context.protected_count) > 1;

fair enough

then I'll also fix patch 6 in a similar way, the function is first
introduced there
diff mbox series

Patch

diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
index e358b8bd864b..43393568f844 100644
--- a/arch/s390/kernel/uv.c
+++ b/arch/s390/kernel/uv.c
@@ -236,7 +236,8 @@  static int make_secure_pte(pte_t *ptep, unsigned long addr,
 
 static bool should_export_before_import(struct uv_cb_header *uvcb, struct mm_struct *mm)
 {
-	return uvcb->cmd != UVC_CMD_UNPIN_PAGE_SHARED &&
+	return !test_bit_inv(BIT_UV_FEAT_MISC, &uv_info.uv_feature_indications) &&
+		uvcb->cmd != UVC_CMD_UNPIN_PAGE_SHARED &&
 		atomic_read(&mm->context.protected_count) > 1;
 }