From patchwork Wed Nov 21 09:22:59 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: 10692171 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 2E53A13BB for ; Wed, 21 Nov 2018 09:23:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C22A2B7F4 for ; Wed, 21 Nov 2018 09:23:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 100822B7FD; Wed, 21 Nov 2018 09:23:27 +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 93FF72B7F4 for ; Wed, 21 Nov 2018 09:23:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 487A36B2574; Wed, 21 Nov 2018 04:23:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4370D6B2576; Wed, 21 Nov 2018 04:23:25 -0500 (EST) 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 2B1B76B2577; Wed, 21 Nov 2018 04:23:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id D2D8B6B2574 for ; Wed, 21 Nov 2018 04:23:24 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id o23so7270651pll.0 for ; Wed, 21 Nov 2018 01:23:24 -0800 (PST) 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=DeCFWKP++ruHsAMRCwDW1v2uov9MK4zya+3krSps6Jw=; b=L7bpChnXf4zuE+FhjsYaWm5IGG1ys8xp0C4oDb3QlmC02eBHT4dn0mqwkL2eNXG4uk oCA/AwbePfWTghYqTVQI4IrW8mCB1LgRUrPVCUUo6NMNOzVFor7aFRtxC0/3bFpHGJS3 E5Z4+OSSxmFmuNEFE0TdB5bjbJrGn1UlSGGT5Luk3R8yc6Ce96GTIOzi2bZlei+3tTmd /Dx2FTV1akCLSb0qBOa7uvVtS8kKjdexxVahEaqZeHhZWLWOgs/+eJU9uZL2XBJPo6gB WbHxdnVosxsnqEoalJvou61002V6OPr7UMOdLYGZ1uBe2medcWJeUSaA5K4PYuamAFKs pNRA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 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: AA+aEWamOA1JldXlLckognCICzryeUmD25w1kmzKUbNztqCLEJPBzCxB eeR0AOdS64F36DKBOW+c6yVoRlkgX2m8P+BMKSzY/kG2FSeY5GDTvPaeVBNvBltr5Sf3MO1RS2U CTibkW2cmBrHk6Q4OhfnkwOm9JafTtZ1gEd6PogkCie9SMEQLN+H1T0eKljDQM1l4Ow== X-Received: by 2002:a65:5a4c:: with SMTP id z12mr5288467pgs.188.1542792204512; Wed, 21 Nov 2018 01:23:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/VmIhk5kw5tzX8hDc5QROkh94zeN08TzhV6MKg/uHe12GEr0jqti/GmX9A5gOmqUYPN7XkS X-Received: by 2002:a65:5a4c:: with SMTP id z12mr5288437pgs.188.1542792203797; Wed, 21 Nov 2018 01:23:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542792203; cv=none; d=google.com; s=arc-20160816; b=u7Hdn7hpYB1UxtBhFCpXosxhNsb/s2wd0Caw+95byTH8epR0DB6mp0HvlECbZpkpJP eP5IrmrtZ9PHrOfvbc7yEAwF+yHk3rUlWc1MW29IzVWDtAF0jooOcYiWPOfNHBFr+OQl 0/fg0Jc5u3kN74HSaYK2xjcW+XP4yVKQnHfqFReTsdYl2iCJObEm6oL55aYYtTZmGgew jRoJZTUjCsrHJtIiiaWzhQeLGum0UteZbT2YJEsJpJjv6O+dFNK0lGm/pbUZ8QgVfM+5 x9Hh4xZeECwLuFRRWE0DKC8vSZhymEUaHqclSlPf+vTpoedje2BexY3xGCHrmZrMa2eI PN+g== 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=DeCFWKP++ruHsAMRCwDW1v2uov9MK4zya+3krSps6Jw=; b=caOt8C2n8zaQpSDAbd5iFfb42nVvN/VjUbO7icHOQQxHQjDQirzOVjD6B++on8S24O X2J5ORgsrUKj/oSWaIkgIDTeUD0rxZlVhJehL72vpw3WiLxCdUSIffMReTjSfpkwJ7Id jjh8wlemszopen/Az7gLhYb6j4OjY1DDlAAUZ/HxSAUea3RBS20wHMZ+YwrNAH3yKX7e wPs5QTwnOjXg/u+WFfCkp3rjUbnpk9pfeVgZKYORG8ZGk/aaLzlVKsIhT/ZDm+0vtSFk X8eKUuBAxseLgrvhDAKn6GVsuipAfRwhJd8fXrzbk391o6vfosm1NSv929/LvEN7CSC1 KsVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 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 (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id x1si25766639pfn.111.2018.11.21.01.23.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 01:23:23 -0800 (PST) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 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 (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAL9J9fi088616 for ; Wed, 21 Nov 2018 04:23:23 -0500 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nw4c313ju-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 21 Nov 2018 04:23:23 -0500 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Nov 2018 09:23:21 -0000 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 21 Nov 2018 09:23:18 -0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAL9NHw033620034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 21 Nov 2018 09:23:17 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79DF5124058; Wed, 21 Nov 2018 09:23:17 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0708124052; Wed, 21 Nov 2018 09:23:14 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.31.179]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 21 Nov 2018 09:23:14 +0000 (GMT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, Michal Hocko , Alexey Kardashevskiy , mpe@ellerman.id.au, paulus@samba.org, David Gibson Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH V4 3/3] powerpc/mm/iommu: Allow large IOMMU page size only for hugetlb backing Date: Wed, 21 Nov 2018 14:52:59 +0530 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181121092259.16482-1-aneesh.kumar@linux.ibm.com> References: <20181121092259.16482-1-aneesh.kumar@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112109-2213-0000-0000-0000031C1871 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010091; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01120588; UDB=6.00581487; IPR=6.00900709; MB=3.00024261; MTD=3.00000008; XFM=3.00000015; UTC=2018-11-21 09:23:21 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112109-2214-0000-0000-00005C549DF4 Message-Id: <20181121092259.16482-4-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-21_04:,, 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-1810050000 definitions=main-1811210085 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 | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c index 1d5161f93ce6..0741d905ed04 100644 --- a/arch/powerpc/mm/mmu_context_iommu.c +++ b/arch/powerpc/mm/mmu_context_iommu.c @@ -95,8 +95,6 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries, struct mm_iommu_table_group_mem_t *mem; long i, ret = 0, locked_entries = 0; unsigned int pageshift; - unsigned long flags; - unsigned long cur_ua; mutex_lock(&mem_list_mutex); @@ -159,23 +157,15 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries, pageshift = PAGE_SHIFT; for (i = 0; i < entries; ++i) { struct page *page = mem->hpages[i]; - cur_ua = ua + (i << PAGE_SHIFT); - if (mem->pageshift > PAGE_SHIFT && PageCompound(page)) { - pte_t *pte; + /* + * Allow to use larger than 64k IOMMU pages. Only do that + * if we are backed by hugetlb. + */ + 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); /*