Re: [PATCH 10/13] KVM: PPC: e500: Stop keeping shadow TLB

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

 



On 03.06.2011, at 01:17, Scott Wood wrote:

> From: Liu Yu <yu.liu@xxxxxxxxxxxxx>
> 
> Instead of a fully separate set of TLB entries, keep just the
> pfn and dirty status.
> 
> Signed-off-by: Liu Yu <yu.liu@xxxxxxxxxxxxx>
> Signed-off-by: Scott Wood <scottwood@xxxxxxxxxxxxx>
> ---
> arch/powerpc/include/asm/kvm_e500.h |   20 ++-
> arch/powerpc/kvm/e500_tlb.c         |  317 +++++++++++++++-------------------
> 2 files changed, 154 insertions(+), 183 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/kvm_e500.h b/arch/powerpc/include/asm/kvm_e500.h
> index f181ad1..4a6d77a 100644
> --- a/arch/powerpc/include/asm/kvm_e500.h
> +++ b/arch/powerpc/include/asm/kvm_e500.h
> @@ -29,15 +29,23 @@ struct tlbe{
> 	u32 mas7;
> };
> 
> +#define E500_TLB_VALID 1
> +#define E500_TLB_DIRTY 2
> +
> +struct tlbe_priv {
> +	pfn_t pfn;
> +	unsigned int flags; /* E500_TLB_* */
> +};
> +
> struct kvmppc_vcpu_e500 {
> 	/* Unmodified copy of the guest's TLB. */
> -	struct tlbe *guest_tlb[E500_TLB_NUM];
> -	/* TLB that's actually used when the guest is running. */
> -	struct tlbe *shadow_tlb[E500_TLB_NUM];
> +	struct tlbe *gtlb_arch[E500_TLB_NUM];
> +
> +	/* KVM internal information associated with each guest TLB entry */
> +	struct tlbe_priv *gtlb_priv[E500_TLB_NUM];
> 
> -	unsigned int guest_tlb_size[E500_TLB_NUM];
> -	unsigned int shadow_tlb_size[E500_TLB_NUM];
> -	unsigned int guest_tlb_nv[E500_TLB_NUM];
> +	unsigned int gtlb_size[E500_TLB_NUM];
> +	unsigned int gtlb_nv[E500_TLB_NUM];
> 
> 	u32 host_pid[E500_PID_NUM];
> 	u32 pid[E500_PID_NUM];
> diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
> index c09e642..9d1e28d 100644
> --- a/arch/powerpc/kvm/e500_tlb.c
> +++ b/arch/powerpc/kvm/e500_tlb.c
> @@ -41,25 +41,14 @@ void kvmppc_dump_tlbs(struct kvm_vcpu *vcpu)
> 
> 	for (tlbsel = 0; tlbsel < 2; tlbsel++) {

The 2 here should be E500_TLB_NUM

> 		printk("Guest TLB%d:\n", tlbsel);
> -		for (i = 0; i < vcpu_e500->guest_tlb_size[tlbsel]; i++) {
> -			tlbe = &vcpu_e500->guest_tlb[tlbsel][i];
> +		for (i = 0; i < vcpu_e500->gtlb_size[tlbsel]; i++) {
> +			tlbe = &vcpu_e500->gtlb_arch[tlbsel][i];
> 			if (tlbe->mas1 & MAS1_VALID)
> 				printk(" G[%d][%3d] |  %08X | %08X | %08X | %08X |\n",
> 					tlbsel, i, tlbe->mas1, tlbe->mas2,
> 					tlbe->mas3, tlbe->mas7);
> 		}
> 	}
> -
> -	for (tlbsel = 0; tlbsel < 2; tlbsel++) {
> -		printk("Shadow TLB%d:\n", tlbsel);
> -		for (i = 0; i < vcpu_e500->shadow_tlb_size[tlbsel]; i++) {
> -			tlbe = &vcpu_e500->shadow_tlb[tlbsel][i];
> -			if (tlbe->mas1 & MAS1_VALID)
> -				printk(" S[%d][%3d] |  %08X | %08X | %08X | %08X |\n",
> -					tlbsel, i, tlbe->mas1, tlbe->mas2,
> -					tlbe->mas3, tlbe->mas7);
> -		}
> -	}
> }
> 

[...]

> 
> 
> +static inline void kvmppc_e500_setup_stlbe(struct kvmppc_vcpu_e500 *vcpu_e500,
> +					   struct tlbe *gtlbe, int tsize,
> +					   struct tlbe_priv *priv,
> +					   u64 gvaddr, struct tlbe *stlbe)
> +{
> +	pfn_t pfn = priv->pfn;
> +
> +	/* Force TS=1 IPROT=0 for all guest mappings. */
> +	stlbe->mas1 = MAS1_TSIZE(tsize)
> +		| MAS1_TID(get_tlb_tid(gtlbe)) | MAS1_TS | MAS1_VALID;
> +	stlbe->mas2 = (gvaddr & MAS2_EPN)
> +		| e500_shadow_mas2_attrib(gtlbe->mas2,
> +				vcpu_e500->vcpu.arch.shared->msr & MSR_PR);
> +	stlbe->mas3 = ((pfn << PAGE_SHIFT) & MAS3_RPN)
> +		| e500_shadow_mas3_attrib(gtlbe->mas3,
> +				vcpu_e500->vcpu.arch.shared->msr & MSR_PR);

This is another source of slowness. Guest PR should only be yet another bit to account for in the TID, so we can keep both active at the same time. That should be possible with the shadow PID code, right?


Alex

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


[Index of Archives]     [KVM Development]     [KVM ARM]     [KVM ia64]     [Linux Virtualization]     [Linux USB Devel]     [Linux Video]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux