Re: [PATCH 3/4] kvm: powerpc: define a linux pte lookup function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2013-10-09 at 03:48 -0500, Bhushan Bharat-R65777 wrote:
> 
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Wednesday, October 09, 2013 3:07 AM
> > To: Bhushan Bharat-R65777
> > Cc: agraf@xxxxxxx; Yoder Stuart-B08248; kvm@xxxxxxxxxxxxxxx; kvm-
> > ppc@xxxxxxxxxxxxxxx; paulus@xxxxxxxxx; Bhushan Bharat-R65777
> > Subject: Re: [PATCH 3/4] kvm: powerpc: define a linux pte lookup function
> > 
> > On Tue, 2013-10-08 at 11:33 +0530, Bharat Bhushan wrote:
> > > We need to search linux "pte" to get "pte" attributes for setting TLB
> > > in KVM.
> > > This patch defines a linux_pte_lookup() function for same.
> > >
> > > Signed-off-by: Bharat Bhushan <bharat.bhushan@xxxxxxxxxxxxx>
> > > ---
> > >  arch/powerpc/include/asm/pgtable.h |   35 +++++++++++++++++++++++++++++++++++
> > >  1 files changed, 35 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/arch/powerpc/include/asm/pgtable.h
> > > b/arch/powerpc/include/asm/pgtable.h
> > > index 7d6eacf..fd26c04 100644
> > > --- a/arch/powerpc/include/asm/pgtable.h
> > > +++ b/arch/powerpc/include/asm/pgtable.h
> > > @@ -223,6 +223,41 @@ extern int gup_hugepte(pte_t *ptep, unsigned long
> > > sz, unsigned long addr,  #endif  pte_t
> > > *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
> > >  				 unsigned *shift);
> > > +
> > > +static inline pte_t lookup_linux_pte(pgd_t *pgdir, unsigned long hva,
> > > +				     unsigned long *pte_sizep)
> > > +{
> > > +	pte_t *ptep;
> > > +	pte_t pte;
> > > +	unsigned long ps = *pte_sizep;
> > > +	unsigned int shift;
> > > +
> > > +	ptep = find_linux_pte_or_hugepte(pgdir, hva, &shift);
> > > +	if (!ptep)
> > > +		return __pte(0);
> > > +	if (shift)
> > > +		*pte_sizep = 1ul << shift;
> > > +	else
> > > +		*pte_sizep = PAGE_SIZE;
> > > +
> > > +	if (ps > *pte_sizep)
> > > +		return __pte(0);
> > > +
> > > +	/* wait until _PAGE_BUSY is clear */
> > > +	while (1) {
> > > +		pte = pte_val(*ptep);
> > > +		if (unlikely(pte & _PAGE_BUSY)) {
> > > +			cpu_relax();
> > > +			continue;
> > > +		}
> > > +	}
> > > +
> > > +	/* If pte is not present return None */
> > > +	if (unlikely(!(pte & _PAGE_PRESENT)))
> > > +		return __pte(0);
> > > +
> > > +	return pte;
> > > +}
> > 
> > Can lookup_linux_pte_and_update() call lookup_linux_pte()?
> 
> What lookup_linux_pte_and_update() does:-
>  - find_linux_pte_or_hugepte()
>  - does size and some other trivial checks
>  - Then atomically update the pte:-
>    => while()
>    => wait till _PAGE_BUSY is clear
>    => atomically update the pte
>    => if not updated then go back to while() above else break
> 
> 
> While what lookup_linux_pte() does:-
>  - find_linux_pte_or_hugepte()
>  - does size and some other trivial checks
>  - wait till _PAGE_BUSY is clear
>  - return pte
> 
> I am finding it difficult to call lookup_linux_pte() from lookup_linux_pte_and_update().

You could factor out a common lookup_linux_ptep().

-Scott



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux