Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp908115pxb; Thu, 5 Nov 2020 16:55:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRMqYYvQyldnxgD4t7/LuPXq3/jZrRYXbb0ZtROfax16t1WIGT8XeEQinTXDa3OqzBKt/Y X-Received: by 2002:a17:906:fcdb:: with SMTP id qx27mr5185428ejb.470.1604624115507; Thu, 05 Nov 2020 16:55:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604624115; cv=none; d=google.com; s=arc-20160816; b=CvF5oGa5s301Qi6G3VNE12FAjfs1V7PkQF3sKYgqiG2eoHWRovchu1xYd1gt77SAbC rLhzc0qqh+g2ecdjywerSgoXjHIDwpV8Zo0GINSWajbbEVC82Ed6pzr455oG/yDnouSQ MOj9tkqqR0eawjzQWftphK5fIp6nuhWHN3kX4iekTVvUrCcDlvZzDCUAj/b3IGndNuBt 1DagK5gBnDBqWLQe5JkFwN8IYg/j4HmPQ+DR4VeT7RMxmVeKr5Wma9jOjCjtoJpZRw3E nSjZ6wPT5bZDE9Uy6YQi8LbuJyhDluML/yeiV1H9JXcHGMTXgIjGVaMs1TyTpWk5DNgf XyMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=gT6gepnrM1WtFwSGyIYxXIn+WYLudok2qxIca0Wj42k=; b=IYrPqza8joHKzLNOEGCDzQvkqA4Hzy99T11PxrPn+87EcCtDRFIGQI8h1NkRm5HnkK Wyk5tj6MDTbC/pPQF+Tj0xDYRrCRAviZk+/pUSkA3rnzrePZzUeetoquvkCX4u+NAqYY SH6VeHJo/rM9UUH+xZfs9B7gDg6oWBcMi/m8HIb8oGrQtd4RaXpfR7OHK4bFtEBbeE4x 4wdoiGesXqGzTYbPZQD9LZbPAHJrKe5cJwn5wy/S5Wl3Iv7kyHH/mRWZh2aMkbZPYI1r ztgNKYhOeO2jdyDbAqR2vBGSPCN9p7SS6v8Z0cM/6ECHS9PEfTmeJnRvhBa+CvtNskpR 24cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=oZL2f7tF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si2413171edh.71.2020.11.05.16.54.53; Thu, 05 Nov 2020 16:55:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=oZL2f7tF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732860AbgKFAwG (ORCPT + 99 others); Thu, 5 Nov 2020 19:52:06 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:8446 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgKFAwG (ORCPT ); Thu, 5 Nov 2020 19:52:06 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 05 Nov 2020 16:52:06 -0800 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 6 Nov 2020 00:52:00 +0000 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Fri, 6 Nov 2020 00:52:00 +0000 From: Ralph Campbell To: , , , CC: Jerome Glisse , John Hubbard , Alistair Popple , Christoph Hellwig , "Jason Gunthorpe" , Bharata B Rao , Zi Yan , "Kirill A . Shutemov" , Yang Shi , Ben Skeggs , Shuah Khan , Andrew Morton , Ralph Campbell Subject: [PATCH v3 4/6] mm/thp: add THP allocation helper Date: Thu, 5 Nov 2020 16:51:45 -0800 Message-ID: <20201106005147.20113-5-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106005147.20113-1-rcampbell@nvidia.com> References: <20201106005147.20113-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1604623926; bh=gT6gepnrM1WtFwSGyIYxXIn+WYLudok2qxIca0Wj42k=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=oZL2f7tFL6dXZy+k8i6jnnkaHUca7aBBFsVgDXAnb4xvEFYgpyFvCQ4YaxNbZ6XBq Wh3SlS7/fv42muBRoi1mZaQOpgVO3BO8z/HeoEc9Toj7kpKD7QD4Pin5rIkU0Rz1WI KNjgQYRTE2ltAGYmOTHDxGsM/jVB9zEcazwVpq0/aEz1cazc2NumdDnvTde16pxwlS p5ws5rm7fIGbvfDlIrUloSZYuY2u3FCJ8SxzgbiwISqxujHl3S2LsCwwJt9A5Jiles 53AbVNbPVeFZNC8i9zbIt0/rsNliFLXQ1leUZ+aMu21sHMWwznYbxAhybb5rXHxd18 pPpFN+3TyGtNg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Transparent huge page allocation policy is controlled by several sysfs variables. Rather than expose these to each device driver that needs to allocate THPs, provide a helper function. Signed-off-by: Ralph Campbell --- include/linux/gfp.h | 10 ++++++++++ mm/huge_memory.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index c603237e006c..242398c4b556 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -564,6 +564,16 @@ static inline struct page *alloc_pages(gfp_t gfp_mask,= unsigned int order) #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) #define alloc_page_vma(gfp_mask, vma, addr) \ alloc_pages_vma(gfp_mask, 0, vma, addr, numa_node_id(), false) +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +extern struct page *alloc_transhugepage(struct vm_area_struct *vma, + unsigned long addr); +#else +static inline struct page *alloc_transhugepage(struct vm_area_struct *vma, + unsigned long addr) +{ + return NULL; +} +#endif =20 extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); extern unsigned long get_zeroed_page(gfp_t gfp_mask); diff --git a/mm/huge_memory.c b/mm/huge_memory.c index a073e66d0ee2..c2c1d3e7c35f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -765,6 +765,20 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault = *vmf) return __do_huge_pmd_anonymous_page(vmf, page, gfp); } =20 +struct page *alloc_transhugepage(struct vm_area_struct *vma, + unsigned long haddr) +{ + gfp_t gfp; + struct page *page; + + gfp =3D alloc_hugepage_direct_gfpmask(vma); + page =3D alloc_hugepage_vma(gfp, vma, haddr, HPAGE_PMD_ORDER); + if (page) + prep_transhuge_page(page); + return page; +} +EXPORT_SYMBOL_GPL(alloc_transhugepage); + static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd, pfn_t pfn, pgprot_t prot, bool write, pgtable_t pgtable) --=20 2.20.1