From patchwork Tue Jan 8 04:51:06 2019 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: 10751397 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 E997891E for ; Tue, 8 Jan 2019 04:51:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D661928A2D for ; Tue, 8 Jan 2019 04:51:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C882A28B20; Tue, 8 Jan 2019 04:51:29 +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 9A97E28A2D for ; Tue, 8 Jan 2019 04:51:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C5648E0051; Mon, 7 Jan 2019 23:51:27 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 54BE08E0038; Mon, 7 Jan 2019 23:51:27 -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 3C5F08E0051; Mon, 7 Jan 2019 23:51:27 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id E80628E0038 for ; Mon, 7 Jan 2019 23:51:26 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id a18so1363469pga.16 for ; Mon, 07 Jan 2019 20:51:26 -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:mime-version:content-transfer-encoding:message-id; bh=gVTaV3tpIBiESn6+ZG0iItHArjg6M3t6FGAh0QXUO+M=; b=A6B8HvVue3F/Y4D4UhJASGi2F4EMl4OCJAzvbb5f9boigj5pxuO/s1SdWGHMxYBZps UhbEkWjoU2jNkHpEryPK+QuJG1h//Eb0jfbsRdfcPSkdEB2l/zbdrKXYwYME+4tysFwW UH6WVV8xsgScQ1F987fy0NMlXwPJCrGcFUCCBghai2u11OE89kZX4nrz23ZRDV3mwhXX Z1ZUv1pellPSecWBUiX96rlVha41QEl7fXu6Ks2/HhYWNwm/QN7e+vU/a1Qc9Y5zroMX o6/KX3dT+lpqNDXGw8S0XMV5KU17h1tYqjjwCExezL2kbK0rPVSwZRal1CsZbHppVvzR dctw== 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: AJcUukeK3EMngqrNtKLWBZJi701FntnF0H2Vm7TxsWnbdp9BEfPlgWVd SNF3YeWCBrErVkSO84/jfCQDYWfMyjeSlJXWG2q7341IKRkSXObdCnN3SLDr3wOqdD4JnnXgfaM plT3u/TsSgBFMrt2WMe9euXXbNLdN1h9f//zgbf9C2AZNuFdhmu3SjtIXi+BGK15LzQ== X-Received: by 2002:a17:902:9691:: with SMTP id n17mr303173plp.9.1546923086557; Mon, 07 Jan 2019 20:51:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN5WUt0mX5bQwube+L9zcy+YTrt7xLCAlOzWMHWxiV81NGpedmyJn4s2zxfDI6+uhdjqNI36 X-Received: by 2002:a17:902:9691:: with SMTP id n17mr303143plp.9.1546923085675; Mon, 07 Jan 2019 20:51:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546923085; cv=none; d=google.com; s=arc-20160816; b=J68ybclHQHPUxB9P2Esyqj01GZxSA7trnu0mLFGxFVL7SPcMSZiAtSlAjRgCc4AKIU cBhbsCTA1E97BNCSxQMXQjdVAzWfqT7zu/Ek4Ef8G6yUHdXWFAUfjRgEjHKCYpOMP+/R iWE24uQnXVbwWLlGp36akztWQawpVuPVAtQ8hw9IPAGvmRrA//sfNMn5Eaj7b9IG9Jtg B4tQLIRM8e7spBBT4jez6q6yVOp6OKWdfNr75DleESg8e8z0Fi0/aSTrV2pzlsgrY6Mh k5+oM9I3gdvesv79oOrai1IaOhFxzLJkLOHZzeKiDenD50L4p/4H+W2/hFJIQqyWMvJZ kavA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:content-transfer-encoding:mime-version:date:subject:cc :to:from; bh=gVTaV3tpIBiESn6+ZG0iItHArjg6M3t6FGAh0QXUO+M=; b=gVgbd4UIw+HKsoBTNO/RWSrRbgQ5NbGZhM5Heh/glRbAZgLbwMKcNgYzwgyAx2Nk4T /zBbC59KcmrFjiAJPPFksAkFX3mKo6B7KChmE7GBlFHj0g+bi14qzcqDwhXMB+EGIUwO IKBhRmf/yUKLkGE70fzsHXWo8YoJ7IKqXHbQLrmNyQGmc7KPv2qqQGjqSnC1S9Oj88Gm tFFNR6AV+tL16Ui+4wO8yJJ+x3+kc2VWpNNpyyFy6Xc6+9GJJ/qWLvtP7K8/ejsOrhd2 fIC6MeWatZHQ6BIdD7dt79BDZV/nu7AkVe9nKJ3dBLJ4TjKCb7J9fyRWCbOQMBep4qGX T9cA== 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 p4si10628351pli.432.2019.01.07.20.51.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 20:51:25 -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 (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x084mt3k089755 for ; Mon, 7 Jan 2019 23:51:25 -0500 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2pvf8kqr4m-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 07 Jan 2019 23:51:24 -0500 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Jan 2019 04:51:23 -0000 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 8 Jan 2019 04:51:20 -0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x084pJ7717760430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Jan 2019 04:51:19 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E0DCB205F; Tue, 8 Jan 2019 04:51:19 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8E80B2065; Tue, 8 Jan 2019 04:51:15 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.85.75.199]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 8 Jan 2019 04:51:15 +0000 (GMT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, Michal Hocko , Alexey Kardashevskiy , David Gibson , Andrea Arcangeli , mpe@ellerman.id.au Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH V6 0/4] mm/kvm/vfio/ppc64: Migrate compound pages out of CMA region Date: Tue, 8 Jan 2019 10:21:06 +0530 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19010804-0064-0000-0000-000003923AFD X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010364; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000273; SDB=6.01143337; UDB=6.00595222; IPR=6.00923595; MB=3.00025025; MTD=3.00000008; XFM=3.00000015; UTC=2019-01-08 04:51:22 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19010804-0065-0000-0000-00003BF2E2C6 Message-Id: <20190108045110.28597-1-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-08_03:,, 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=699 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901080036 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 ppc64 use CMA area for the allocation of guest page table (hash page table). We won't be able to start guest if we fail to allocate hash page table. We have observed hash table allocation failure because we failed to migrate pages out of CMA region because they were pinned. This happen when we are using VFIO. VFIO on ppc64 pins the entire guest RAM. If the guest RAM pages get allocated out of CMA region, we won't be able to migrate those pages. The pages are also pinned for the lifetime of the guest. Currently we support migration of non-compound pages. With THP and with the addition of hugetlb migration we can end up allocating compound pages from CMA region. This patch series add support for migrating compound pages. The first path adds the helper get_user_pages_cma_migrate() which pin the page making sure we migrate them out of CMA region before incrementing the reference count. Changes from V5: * Add PF_MEMALLOC_NOCMA * remote __GFP_THISNODE when allocating target page for migration Changes from V4: * use __GFP_NOWARN when allocating pages to avoid page allocation failure warnings. Changes from V3: * Move the hugetlb check before transhuge check * Use compound head page when isolating hugetlb page Aneesh Kumar K.V (4): mm/cma: Add PF flag to force non cma alloc mm: Add get_user_pages_cma_migrate powerpc/mm/iommu: Allow migration of cma allocated pages during mm_iommu_get powerpc/mm/iommu: Allow large IOMMU page size only for hugetlb backing arch/powerpc/mm/mmu_context_iommu.c | 144 ++++++++------------------- include/linux/hugetlb.h | 2 + include/linux/migrate.h | 3 + include/linux/sched.h | 1 + include/linux/sched/mm.h | 36 +++++-- mm/hugetlb.c | 4 +- mm/migrate.c | 149 ++++++++++++++++++++++++++++ 7 files changed, 227 insertions(+), 112 deletions(-) Reviewed-by: Andrea Arcangeli