Received: by 10.223.176.46 with SMTP id f43csp4017547wra; Tue, 23 Jan 2018 02:57:59 -0800 (PST) X-Google-Smtp-Source: AH8x226317zjIQK/BTliRwHkOZLDwsde2PAhXfLrOd8BGNTvBKmsZyeJy6GRZO15dIOMgFPz1pj6 X-Received: by 10.99.137.195 with SMTP id v186mr8757138pgd.25.1516705079016; Tue, 23 Jan 2018 02:57:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516705078; cv=none; d=google.com; s=arc-20160816; b=kDC5Ma/b9y4BszlGLOsrp/DfkPlpScIjPzWB/s64SN03Q0QzB9mc1ViVF3wcBAY35O T4Fn3D+U7RdHzmWvoFl81qfiBk2ZGVdeVh/LZZakhaAXDMrJhCNkFToXPdywgrAuMoYJ H0F38At9FQ3LTxdLnQVU+t0D0QoHvJGbktdV82qa5OHi0NvtY+TXwNSNfKYR+q/6/3/U TSeQ5WkwAFyaIOchkq5xxhO/Fbs9BY1dSLvblK2rA8tKy6qIJApDvVTr+9cK94gVqEp8 BU3cAEi6or/HfAhvt8Fn5zmxxBkMnDgjmuGHG0hWjIKsYyTtC7asDDNavKHMX24MHav5 9SoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject :dkim-signature:arc-authentication-results; bh=k0E/8amoHpCjb4DxQ8Opd0Z/OayXfg2S4dCcGJQiES4=; b=AaIl4j/ZVTtQ+2nzK3Z6d9e+wEol+9iejwgcCL6Ea1bDqofDz3zZnNDiHgQjIkmFLF XKyvGuZc+gUOrudU+9pYiNsbsKAfLSiMhLfjE8h5eKyMrWbKz2GkDAUjRvRr0Hrd3ZAV 8oEgX8WNH0Yu4T3QJKNPSsgb0QFB3tLccbR9ImTmyfMHmT158l0qSjCYzpbbxUASq700 xYlKSZRMRERwj0Eo+jx1oZq5dY7GQYUkbEa95lkFF6Vzz7Gqf4H0cIGsRCfmfpT/epN7 Ripmj+x2X7dhieH4V0dp1Bkw16qYpS5R2jCIZPeldnGhAc2AiPhKFNyWglcMNdNQR55S PNiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=UJbNsho9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si8603139pgo.502.2018.01.23.02.57.44; Tue, 23 Jan 2018 02:57:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=UJbNsho9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751486AbeAWKzf (ORCPT + 99 others); Tue, 23 Jan 2018 05:55:35 -0500 Received: from forwardcorp1g.cmail.yandex.net ([87.250.241.190]:59401 "EHLO forwardcorp1g.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbeAWKza (ORCPT ); Tue, 23 Jan 2018 05:55:30 -0500 Received: from smtpcorp1o.mail.yandex.net (smtpcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::30]) by forwardcorp1g.cmail.yandex.net (Yandex) with ESMTP id 1A84820747; Tue, 23 Jan 2018 13:55:28 +0300 (MSK) Received: from smtpcorp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtpcorp1o.mail.yandex.net (Yandex) with ESMTP id 12F762440DAB; Tue, 23 Jan 2018 13:55:28 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:0:40c:b4b7:f0f3:4b10:5639]) by smtpcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id rJiDSErFYg-tRGauRBD; Tue, 23 Jan 2018 13:55:27 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1516704928; bh=k0E/8amoHpCjb4DxQ8Opd0Z/OayXfg2S4dCcGJQiES4=; h=Subject:From:To:Date:Message-ID:In-Reply-To:References; b=UJbNsho9CZF/4WaomWRRWQ1ubM45QHSF0yb3fCHv6lBEYVT+45/n+0WR1NRl6AL7z hbvCj4H/+EDnayaeakx1vmDA8QL16Wz9LvE+ghhc6/orQUxg2vPFvGAJVYif1ML1m1 +Jh7+7097+kJ23Vhdu2RcwXfMtie9uLkN5/agYNU= Authentication-Results: smtpcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH 2/4] vmalloc: add __vmalloc_area() From: Konstantin Khlebnikov To: Dave Hansen , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-mm@kvack.org, Andy Lutomirski , Andrew Morton Date: Tue, 23 Jan 2018 13:55:26 +0300 Message-ID: <151670492590.658225.1645504673972109236.stgit@buzz> In-Reply-To: <151670492223.658225.4605377710524021456.stgit@buzz> References: <151670492223.658225.4605377710524021456.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function it the same as __vmalloc_node_range() but returns pointer to vm_struct rather than virtual address. Signed-off-by: Konstantin Khlebnikov --- include/linux/vmalloc.h | 5 +++++ mm/vmalloc.c | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 1e5d8c392f15..f772346a506e 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -81,6 +81,11 @@ extern void *__vmalloc_node_range(unsigned long size, unsigned long align, unsigned long start, unsigned long end, gfp_t gfp_mask, pgprot_t prot, unsigned long vm_flags, int node, const void *caller); +extern struct vm_struct *__vmalloc_area(unsigned long size, unsigned long align, + unsigned long start, unsigned long end, + gfp_t gfp_mask, pgprot_t prot, + unsigned long vm_flags, int node, + const void *caller); #ifndef CONFIG_MMU extern void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags); static inline void *__vmalloc_node_flags_caller(unsigned long size, int node, diff --git a/mm/vmalloc.c b/mm/vmalloc.c index cece3fb33cef..ad962be74d53 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1725,7 +1725,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, } /** - * __vmalloc_node_range - allocate virtually contiguous memory + * __vmalloc_area - allocate virtually contiguous memory * @size: allocation size * @align: desired alignment * @start: vm area range start @@ -1738,9 +1738,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, * * Allocate enough pages to cover @size from the page level * allocator with @gfp_mask flags. Map them into contiguous - * kernel virtual space, using a pagetable protection of @prot. + * kernel virtual space, using a pagetable protection of @prot + * + * Returns the area descriptor on success or %NULL on failure. */ -void *__vmalloc_node_range(unsigned long size, unsigned long align, +struct vm_struct *__vmalloc_area(unsigned long size, unsigned long align, unsigned long start, unsigned long end, gfp_t gfp_mask, pgprot_t prot, unsigned long vm_flags, int node, const void *caller) @@ -1771,7 +1773,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, kmemleak_vmalloc(area, size, gfp_mask); - return addr; + return area; fail: warn_alloc(gfp_mask, NULL, @@ -1780,6 +1782,35 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, } /** + * __vmalloc_node_range - allocate virtually contiguous memory + * @size: allocation size + * @align: desired alignment + * @start: vm area range start + * @end: vm area range end + * @gfp_mask: flags for the page level allocator + * @prot: protection mask for the allocated pages + * @vm_flags: additional vm area flags (e.g. %VM_NO_GUARD) + * @node: node to use for allocation or NUMA_NO_NODE + * @caller: caller's return address + * + * Allocate enough pages to cover @size from the page level + * allocator with @gfp_mask flags. Map them into contiguous + * kernel virtual space, using a pagetable protection of @prot. + */ +void *__vmalloc_node_range(unsigned long size, unsigned long align, + unsigned long start, unsigned long end, gfp_t gfp_mask, + pgprot_t prot, unsigned long vm_flags, int node, + const void *caller) +{ + struct vm_struct *area; + + area = __vmalloc_area(size, align, start, end, gfp_mask, + prot, vm_flags, node, caller); + + return area ? area->addr : NULL; +} + +/** * __vmalloc_node - allocate virtually contiguous memory * @size: allocation size * @align: desired alignment