From patchwork Thu Sep 6 05:43:41 2018 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: 10589871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEB9913BB for ; Thu, 6 Sep 2018 05:44:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0DEF2A574 for ; Thu, 6 Sep 2018 05:44:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9502E2A58B; Thu, 6 Sep 2018 05:44:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 337AB2A574 for ; Thu, 6 Sep 2018 05:44:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9D446B7721; Thu, 6 Sep 2018 01:44:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B502C6B7723; Thu, 6 Sep 2018 01:44:08 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FECD6B7724; Thu, 6 Sep 2018 01:44:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by kanga.kvack.org (Postfix) with ESMTP id 5D9596B7721 for ; Thu, 6 Sep 2018 01:44:08 -0400 (EDT) Received: by mail-oi0-f71.google.com with SMTP id p14-v6so11751978oip.0 for ; Wed, 05 Sep 2018 22:44:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=aZ52QrJ34AqFpIq4fFrVUelgxTADQ3L8kCte64iUIeI=; b=T+aqMNplD983mOV7VeYajSQYlil7RJp8UOVWj6Rz5l2nnt1LCYCWvlPPcyrapEoo8Y T5L6syKL7WtD2+O4yDzdGulKst9ue9nGOPzhNGgqvQATtsNXrkfzHgCtZ58UL7YKciuh G5jt9okMB2J4lKwDL/n6Fmc1luXlE3z5jgQ1N3SmmTfGZO9Z3I8giYFPx0jnbbFAa06M gWS82zCebPEJqCOGnWrZSwXwuApn/txvGkcARXBEWV9fIAm8ugdv0s08aHzeRq3A9uVg HMwc/iwAt/Y2GbkIL1F6MBGeLCCK9qIb8cewUOr3e7a/S9HeAK8vvpbKO8hy4Wo6A0HH NZKg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APzg51CKsiybp2cOicXpJtWl9/HXJa1WreSVIQH4HExvHLXhMXRRHDi8 9BjQLaRQSmKZffRal0NGo2BzBuNa0WCyrssv7zxg2q6qWfVq1YiU9CBKsYUXjET4vapoUhxusBc KssYvrdiuxSTpY2jrif5B7cfmxl9DMcAYc0wBpeJZO9WKb2qTiW9tP3MWqZKGjOeVCg== X-Received: by 2002:aca:f189:: with SMTP id p131-v6mr1257355oih.14.1536212648109; Wed, 05 Sep 2018 22:44:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZYzV9smdFeuna7hsQE6bHHqd/b10Hh+SBfAwXjyXbv4INva/kdMNaWaUFRbcfC5JANPyXQ X-Received: by 2002:aca:f189:: with SMTP id p131-v6mr1257323oih.14.1536212647500; Wed, 05 Sep 2018 22:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536212647; cv=none; d=google.com; s=arc-20160816; b=n03dyrjl1rCFJhfkj2ksRS9A4pXgpLS/AoY2WdftibRSm2iuIhhQqkNAIuDV8Vjnmn R7AMd45q4c/iTM6xFJtkFYC0x0pHPdZnawTAGoechf558z4QwpS21vgVxjXL2/4cooKa iRbyRtGxG2gmASxWFSeGXGFmoKDZ12Qar8/2e8e7RK+DAXhNbkmbAkpwJGNZiylTRZr9 iRX3MfZREabnNJKGzb05j4e8s6rdpnlPE/a2mnjUipAY7IWkK3XuCi4GN17AC7GeseNQ R5yIGyKO5VOx2e3J3mGqBByzQ45Vjm5sLApqENnMHxgHOa9Ug7c1MhlOnSxcv9Bl49RP F4vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from; bh=aZ52QrJ34AqFpIq4fFrVUelgxTADQ3L8kCte64iUIeI=; b=t2nd9Z2B/wmvn/wEMQ+YB5UXEernbSgjn6J9NE/L4f9uZ6ykudrTiPA/krJ4oPZGB/ KMDaMXT+3NfSX1KOSCVcWsJsRc/vZgIyrIfSleXpbPvPo6K2Y25j3DDmuDHhYYcYWzaG NilPY8v9lHoi0VZQ6qNZWDbFg7C/W9a5MhUdXiVdbZPXTol6LqieGqAZJT5Ga/7ASOEN Du6OTX/2QLCdlZXeGLuHgooSz1Rho305g+oy5rLoVmm6t5F3rlUsE6DWQxCysn4JeBFq GckdvzfV+Xu3dQccHthvz5Vxb9UB6Ftdi/BgR54DXnNrZH4AbIBXETp028wOMwK16pgr ceNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id u4-v6si2627558oif.129.2018.09.05.22.44.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Sep 2018 22:44:07 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w865hiZi146248 for ; Thu, 6 Sep 2018 01:44:06 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0b-001b2d01.pphosted.com with ESMTP id 2mathwfss1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 06 Sep 2018 01:44:06 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Sep 2018 01:44:06 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 6 Sep 2018 01:44:03 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w865i2rD19857656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Sep 2018 05:44:02 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8D40124053; Thu, 6 Sep 2018 02:44:31 -0400 (EDT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5A911124054; Thu, 6 Sep 2018 02:44:29 -0400 (EDT) Received: from skywalker.ibmuc.com (unknown [9.102.0.183]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 6 Sep 2018 02:44:29 -0400 (EDT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, Alexey Kardashevskiy , mpe@ellerman.id.au Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [RFC PATCH V2 3/4] powerpc/mm/iommu: Allow large IOMMU page size only for hugetlb backing Date: Thu, 6 Sep 2018 11:13:41 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180906054342.25094-1-aneesh.kumar@linux.ibm.com> References: <20180906054342.25094-1-aneesh.kumar@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18090605-0040-0000-0000-0000046B12F9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009676; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01084227; UDB=6.00559595; IPR=6.00864226; MB=3.00023138; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-06 05:44:05 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18090605-0041-0000-0000-00000872352B Message-Id: <20180906054342.25094-3-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-06_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809060061 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP THP pages can get split during different code paths. An incremented reference count do imply we will not split the compound page. But the pmd entry can be converted to level 4 pte entries. Keep the code simpler by allowing large IOMMU page size only if the guest ram is backed by hugetlb pages. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/mmu_context_iommu.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c index c9ee9e23845f..f472965f7638 100644 --- a/arch/powerpc/mm/mmu_context_iommu.c +++ b/arch/powerpc/mm/mmu_context_iommu.c @@ -212,21 +212,9 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries, } populate: pageshift = PAGE_SHIFT; - if (mem->pageshift > PAGE_SHIFT && PageCompound(page)) { - pte_t *pte; + if (mem->pageshift > PAGE_SHIFT && PageHuge(page)) { struct page *head = compound_head(page); - unsigned int compshift = compound_order(head); - unsigned int pteshift; - - local_irq_save(flags); /* disables as well */ - pte = find_linux_pte(mm->pgd, cur_ua, NULL, &pteshift); - - /* Double check it is still the same pinned page */ - if (pte && pte_page(*pte) == head && - pteshift == compshift + PAGE_SHIFT) - pageshift = max_t(unsigned int, pteshift, - PAGE_SHIFT); - local_irq_restore(flags); + pageshift = compound_order(head) + PAGE_SHIFT; } mem->pageshift = min(mem->pageshift, pageshift); mem->hpas[i] = page_to_pfn(page) << PAGE_SHIFT;