All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leonardo Bras <leonardo@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Cc: Paul Mackerras <paulus@ozlabs.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: [PATCH 1/1] powerpc: kvm: Reduce calls to get current->mm by storing the value locally
Date: Mon, 23 Sep 2019 22:22:03 -0300	[thread overview]
Message-ID: <26335319c18d082408a6ee5e10779c3ddc0f175c.camel@linux.ibm.com> (raw)
In-Reply-To: <20190923213022.7740-1-leonardo@linux.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2876 bytes --]

I have done a very simple comparison with gdb disassemble:
By applying this patch, there was a reduction in the function size from
882 to 878 instructions.

(It's a resend, due to not having all the correct lists on my previous
mail) 

On Mon, 2019-09-23 at 18:30 -0300, Leonardo Bras wrote:
> Reduces the number of calls to get_current() in order to get the value of
> current->mm by doing it once and storing the value, since it is not
> supposed to change inside the same process).
> 
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> ---
> Re-sending to all lists involved. (I missed kvm ones)
> 
>  arch/powerpc/kvm/book3s_64_mmu_hv.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> index 9a75f0e1933b..f2b9aea43216 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> @@ -508,6 +508,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	struct vm_area_struct *vma;
>  	unsigned long rcbits;
>  	long mmio_update;
> +	struct mm_struct *mm;
>  
>  	if (kvm_is_radix(kvm))
>  		return kvmppc_book3s_radix_page_fault(run, vcpu, ea, dsisr);
> @@ -584,6 +585,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	is_ci = false;
>  	pfn = 0;
>  	page = NULL;
> +	mm = current->mm;
>  	pte_size = PAGE_SIZE;
>  	writing = (dsisr & DSISR_ISSTORE) != 0;
>  	/* If writing != 0, then the HPTE must allow writing, if we get here */
> @@ -592,8 +594,8 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	npages = get_user_pages_fast(hva, 1, writing ? FOLL_WRITE : 0, pages);
>  	if (npages < 1) {
>  		/* Check if it's an I/O mapping */
> -		down_read(&current->mm->mmap_sem);
> -		vma = find_vma(current->mm, hva);
> +		down_read(&mm->mmap_sem);
> +		vma = find_vma(mm, hva);
>  		if (vma && vma->vm_start <= hva && hva + psize <= vma->vm_end &&
>  		    (vma->vm_flags & VM_PFNMAP)) {
>  			pfn = vma->vm_pgoff +
> @@ -602,7 +604,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			is_ci = pte_ci(__pte((pgprot_val(vma->vm_page_prot))));
>  			write_ok = vma->vm_flags & VM_WRITE;
>  		}
> -		up_read(&current->mm->mmap_sem);
> +		up_read(&mm->mmap_sem);
>  		if (!pfn)
>  			goto out_put;
>  	} else {
> @@ -621,8 +623,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			 * hugepage split and collapse.
>  			 */
>  			local_irq_save(flags);
> -			ptep = find_current_mm_pte(current->mm->pgd,
> -						   hva, NULL, NULL);
> +			ptep = find_current_mm_pte(mm->pgd, hva, NULL, NULL);
>  			if (ptep) {
>  				pte = kvmppc_read_update_linux_pte(ptep, 1);
>  				if (__pte_write(pte))

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Leonardo Bras <leonardo@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 1/1] powerpc: kvm: Reduce calls to get current->mm by storing the value locally
Date: Mon, 23 Sep 2019 22:22:03 -0300	[thread overview]
Message-ID: <26335319c18d082408a6ee5e10779c3ddc0f175c.camel@linux.ibm.com> (raw)
In-Reply-To: <20190923213022.7740-1-leonardo@linux.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2876 bytes --]

I have done a very simple comparison with gdb disassemble:
By applying this patch, there was a reduction in the function size from
882 to 878 instructions.

(It's a resend, due to not having all the correct lists on my previous
mail) 

On Mon, 2019-09-23 at 18:30 -0300, Leonardo Bras wrote:
> Reduces the number of calls to get_current() in order to get the value of
> current->mm by doing it once and storing the value, since it is not
> supposed to change inside the same process).
> 
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> ---
> Re-sending to all lists involved. (I missed kvm ones)
> 
>  arch/powerpc/kvm/book3s_64_mmu_hv.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> index 9a75f0e1933b..f2b9aea43216 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> @@ -508,6 +508,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	struct vm_area_struct *vma;
>  	unsigned long rcbits;
>  	long mmio_update;
> +	struct mm_struct *mm;
>  
>  	if (kvm_is_radix(kvm))
>  		return kvmppc_book3s_radix_page_fault(run, vcpu, ea, dsisr);
> @@ -584,6 +585,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	is_ci = false;
>  	pfn = 0;
>  	page = NULL;
> +	mm = current->mm;
>  	pte_size = PAGE_SIZE;
>  	writing = (dsisr & DSISR_ISSTORE) != 0;
>  	/* If writing != 0, then the HPTE must allow writing, if we get here */
> @@ -592,8 +594,8 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	npages = get_user_pages_fast(hva, 1, writing ? FOLL_WRITE : 0, pages);
>  	if (npages < 1) {
>  		/* Check if it's an I/O mapping */
> -		down_read(&current->mm->mmap_sem);
> -		vma = find_vma(current->mm, hva);
> +		down_read(&mm->mmap_sem);
> +		vma = find_vma(mm, hva);
>  		if (vma && vma->vm_start <= hva && hva + psize <= vma->vm_end &&
>  		    (vma->vm_flags & VM_PFNMAP)) {
>  			pfn = vma->vm_pgoff +
> @@ -602,7 +604,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			is_ci = pte_ci(__pte((pgprot_val(vma->vm_page_prot))));
>  			write_ok = vma->vm_flags & VM_WRITE;
>  		}
> -		up_read(&current->mm->mmap_sem);
> +		up_read(&mm->mmap_sem);
>  		if (!pfn)
>  			goto out_put;
>  	} else {
> @@ -621,8 +623,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			 * hugepage split and collapse.
>  			 */
>  			local_irq_save(flags);
> -			ptep = find_current_mm_pte(current->mm->pgd,
> -						   hva, NULL, NULL);
> +			ptep = find_current_mm_pte(mm->pgd, hva, NULL, NULL);
>  			if (ptep) {
>  				pte = kvmppc_read_update_linux_pte(ptep, 1);
>  				if (__pte_write(pte))

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Leonardo Bras <leonardo@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Cc: Paul Mackerras <paulus@ozlabs.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: [PATCH 1/1] powerpc: kvm: Reduce calls to get current->mm by storing the value locally
Date: Tue, 24 Sep 2019 01:22:03 +0000	[thread overview]
Message-ID: <26335319c18d082408a6ee5e10779c3ddc0f175c.camel@linux.ibm.com> (raw)
In-Reply-To: <20190923213022.7740-1-leonardo@linux.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2876 bytes --]

I have done a very simple comparison with gdb disassemble:
By applying this patch, there was a reduction in the function size from
882 to 878 instructions.

(It's a resend, due to not having all the correct lists on my previous
mail) 

On Mon, 2019-09-23 at 18:30 -0300, Leonardo Bras wrote:
> Reduces the number of calls to get_current() in order to get the value of
> current->mm by doing it once and storing the value, since it is not
> supposed to change inside the same process).
> 
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> ---
> Re-sending to all lists involved. (I missed kvm ones)
> 
>  arch/powerpc/kvm/book3s_64_mmu_hv.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> index 9a75f0e1933b..f2b9aea43216 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> @@ -508,6 +508,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	struct vm_area_struct *vma;
>  	unsigned long rcbits;
>  	long mmio_update;
> +	struct mm_struct *mm;
>  
>  	if (kvm_is_radix(kvm))
>  		return kvmppc_book3s_radix_page_fault(run, vcpu, ea, dsisr);
> @@ -584,6 +585,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	is_ci = false;
>  	pfn = 0;
>  	page = NULL;
> +	mm = current->mm;
>  	pte_size = PAGE_SIZE;
>  	writing = (dsisr & DSISR_ISSTORE) != 0;
>  	/* If writing != 0, then the HPTE must allow writing, if we get here */
> @@ -592,8 +594,8 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	npages = get_user_pages_fast(hva, 1, writing ? FOLL_WRITE : 0, pages);
>  	if (npages < 1) {
>  		/* Check if it's an I/O mapping */
> -		down_read(&current->mm->mmap_sem);
> -		vma = find_vma(current->mm, hva);
> +		down_read(&mm->mmap_sem);
> +		vma = find_vma(mm, hva);
>  		if (vma && vma->vm_start <= hva && hva + psize <= vma->vm_end &&
>  		    (vma->vm_flags & VM_PFNMAP)) {
>  			pfn = vma->vm_pgoff +
> @@ -602,7 +604,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			is_ci = pte_ci(__pte((pgprot_val(vma->vm_page_prot))));
>  			write_ok = vma->vm_flags & VM_WRITE;
>  		}
> -		up_read(&current->mm->mmap_sem);
> +		up_read(&mm->mmap_sem);
>  		if (!pfn)
>  			goto out_put;
>  	} else {
> @@ -621,8 +623,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			 * hugepage split and collapse.
>  			 */
>  			local_irq_save(flags);
> -			ptep = find_current_mm_pte(current->mm->pgd,
> -						   hva, NULL, NULL);
> +			ptep = find_current_mm_pte(mm->pgd, hva, NULL, NULL);
>  			if (ptep) {
>  				pte = kvmppc_read_update_linux_pte(ptep, 1);
>  				if (__pte_write(pte))

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-09-24  1:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-23 21:30 [PATCH 1/1] powerpc: kvm: Reduce calls to get current->mm by storing the value locally Leonardo Bras
2019-09-23 21:30 ` Leonardo Bras
2019-09-23 21:30 ` Leonardo Bras
2019-09-24  1:22 ` Leonardo Bras [this message]
2019-09-24  1:22   ` Leonardo Bras
2019-09-24  1:22   ` Leonardo Bras
  -- strict thread matches above, loose matches on Subject: below --
2019-09-19 22:27 Leonardo Bras
2019-09-19 22:27 ` Leonardo Bras
2019-09-20  2:47 ` Leonardo Bras
2019-09-23 18:35   ` Leonardo Bras
2019-09-23 19:12     ` Leonardo Bras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26335319c18d082408a6ee5e10779c3ddc0f175c.camel@linux.ibm.com \
    --to=leonardo@linux.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.