From patchwork Mon Sep 12 12:05:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 668755 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sXmkX6mKrz9sf6 for ; Mon, 12 Sep 2016 22:06:44 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3sXmkX69fhzDsNl for ; Mon, 12 Sep 2016 22:06:44 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3sXmjH58s9zDrp3 for ; Mon, 12 Sep 2016 22:05:39 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8CC2vK5060921 for ; Mon, 12 Sep 2016 08:05:37 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 25ccg9xmpj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 12 Sep 2016 08:05:36 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 Sep 2016 06:05:35 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 12 Sep 2016 06:05:32 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: aneesh.kumar@linux.vnet.ibm.com Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id BCBB119D801C; Mon, 12 Sep 2016 06:05:01 -0600 (MDT) Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8CC5V5v065920; Mon, 12 Sep 2016 05:05:31 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90228BE044; Mon, 12 Sep 2016 06:05:31 -0600 (MDT) Received: from skywalker.in.ibm.com (unknown [9.79.188.243]) by b03ledav005.gho.boulder.ibm.com (Postfix) with SMTP id E8310BE038; Mon, 12 Sep 2016 06:05:29 -0600 (MDT) Received: (nullmailer pid 17682 invoked by uid 1000); Mon, 12 Sep 2016 12:05:28 -0000 From: "Aneesh Kumar K.V" To: Anshuman Khandual , linuxppc-dev@lists.ozlabs.org Subject: Re: [RFC] KVM: PPC: Book3S HV: Fall back to same size HPT in allocation ioctl In-Reply-To: <1473678797-22069-1-git-send-email-khandual@linux.vnet.ibm.com> References: <1473678797-22069-1-git-send-email-khandual@linux.vnet.ibm.com> Date: Mon, 12 Sep 2016 17:35:28 +0530 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16091212-0004-0000-0000-000010573061 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005749; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000185; SDB=6.00756826; UDB=6.00358744; IPR=6.00530104; BA=6.00004710; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012648; XFM=3.00000011; UTC=2016-09-12 12:05:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16091212-0005-0000-0000-000078CBD333 Message-Id: <8760q1pblj.fsf@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-12_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=5 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609120187 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Anshuman Khandual writes: > When the HPT size is explicitly passed on from the userspace, currently > the KVM_PPC_ALLOCATE_HTAB will try to allocate the requested size of HPT > from reserved CMA area and if that is not possible, the allocation just > fails. With the commit 572abd563befd56 ("KVM: PPC: Book3S HV: Don't fall > back to smaller HPT size in allocation ioctl"), it does not even try to > allocate the same order pages from the page allocator before failing for > good. Same order allocation should be attempted from the page allocator > as a fallback option when the CMA allocation attempt fails. IMO we should fix the reason for these CMA allocation failure. We are just doing work around here. > > Signed-off-by: Anshuman Khandual > --- > - This change saves guests from failing to start after migration > > arch/powerpc/kvm/book3s_64_mmu_hv.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c > index 05f09ae..0a30eb4 100644 > --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c > +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c > @@ -78,6 +78,14 @@ long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp) > --order; > } > > + /* > + * Fallback in case the userspace has provided a size via ioctl. > + * Try allocating the same order pages from the page allocator. > + */ > + if (!hpt && order > PPC_MIN_HPT_ORDER && htab_orderp) > + hpt = __get_free_pages(GFP_KERNEL|__GFP_ZERO|__GFP_REPEAT| > + __GFP_NOWARN, order - PAGE_SHIFT); > + > if (!hpt) > return -ENOMEM; A better way to do that would be (not even compile tested) ? diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index 65b2b00d93d7..3f8995f27339 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -68,16 +68,18 @@ long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp) memset((void *)hpt, 0, (1ul << order)); kvm->arch.hpt_cma_alloc = 1; } - - /* Lastly try successively smaller sizes from the page allocator */ - /* Only do this if userspace didn't specify a size via ioctl */ - while (!hpt && order > PPC_MIN_HPT_ORDER && !htab_orderp) { + /* + * Try successively smaller sizes from the page allocator. + * If a size was specified via an ioctl, we just try that + * specific size + */ +- while (!hpt && order > PPC_MIN_HPT_ORDER) { hpt = __get_free_pages(GFP_KERNEL|__GFP_ZERO|__GFP_REPEAT| __GFP_NOWARN, order - PAGE_SHIFT); - if (!hpt) - --order; + if (htab_orderp) + break; + --order; } - if (!hpt) return -ENOMEM;