Received: by 10.223.176.46 with SMTP id f43csp4016251wra; Tue, 23 Jan 2018 02:56:25 -0800 (PST) X-Google-Smtp-Source: AH8x227m0qJ4dgLK2Xx/rw5un5hE2h4JNrrmdOEGJhA46qz5v/2gebBYtKCf4PJGsuvhOm4WibgS X-Received: by 10.98.7.73 with SMTP id b70mr9982555pfd.39.1516704985112; Tue, 23 Jan 2018 02:56:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516704985; cv=none; d=google.com; s=arc-20160816; b=Qd9cE6PB68oJiQN4gh2I0zPxYJB9toDZGDzDlGNCXFzzQZN39cTuVY4+gs6169Ap/H QZQlNzVhDvZXnrFQOfuaW5uof7tPatF9iVzWrj8JHiKK3+DFEEH5L90PeGi4n3qJ0N/0 MwV9Xv4oMPsOy186kamXQEQYdGnZPesv99u1geaw2UUIlyuuLY9QG2TdDzX2mGF0Qgoy xTNUCShh/fJUaAavJyP8Kom/rjpD8Uxqkm91YPNHK/XYme1j0TWp1KpvtBVz2nKUqNJZ 7MHVr/Kjo52hymMZrpGorM+W+VqiiEkA5rmBnF7mecMAUVYc4mvYAIzZpmCoAXAa9Rpw VsLA== 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:message-id:date:to:from:subject:dkim-signature :arc-authentication-results; bh=QPK4fAuFPI9jrCjBnBSX5EOe7WuS/jeINTKto9XhKC0=; b=c6i05D95JTMcdFLfSVF+ZWaAzJ5hk/D+gxJoI277gY5/clX7cMjZeJ4/8aiFBunkBX WrsD8MHtXHoJTHm4sXGRtyDJEChjIYeyzYJE9C+M0WdDGl9G/I6HQ2qcZNQO2Q7ROmYj TmGZzYkPxIqSjVSgNaoQfaLg2++r0M+pNy+EEOa06no5/UtgJMKW/Lbqi7DCQrQmEh8/ GrCEnJWLFFcyYUd8jynHWIgDJGCW3ITEa7QNd0cMpQmGxLfKyWoGzGJAc3CvKS4vqRqw vSEaeLGD4OdjhYvwpFteA/QIlHNQJZffgydp/+PdGykKQsdo2g4/CCcRhRcE/hXiRDOo Ybpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=gPCT1gNn; 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 l4-v6si4589517pln.619.2018.01.23.02.56.10; Tue, 23 Jan 2018 02:56:25 -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=gPCT1gNn; 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 S1751450AbeAWKz2 (ORCPT + 99 others); Tue, 23 Jan 2018 05:55:28 -0500 Received: from forwardcorp1j.cmail.yandex.net ([5.255.227.105]:54190 "EHLO forwardcorp1j.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbeAWKz1 (ORCPT ); Tue, 23 Jan 2018 05:55:27 -0500 Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:10]) by forwardcorp1j.cmail.yandex.net (Yandex) with ESMTP id D3FE120EBC; Tue, 23 Jan 2018 13:55:24 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtpcorp1p.mail.yandex.net (Yandex) with ESMTP id D13B36E40A56; Tue, 23 Jan 2018 13:55:24 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:0:40c:b4b7:f0f3:4b10:5639]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ymjnVwPaMl-tOLmTKuk; Tue, 23 Jan 2018 13:55:24 +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=1516704924; bh=QPK4fAuFPI9jrCjBnBSX5EOe7WuS/jeINTKto9XhKC0=; h=Subject:From:To:Date:Message-ID; b=gPCT1gNnTZfoJTEYsCeqMXaS2wBdnDt5w49DlBvVKqHPb13BPD7JNjEQjH4aUrL+P L1ATDd8E1L7NO5Mis6dxxxsxIdgmDAstF0eLU/dOvrCjHadxcZUMomI2HyRE20XZXu XbEiuxvg9i8nDmd+caKcDWvcILTxw0L3GsAblQdE= Authentication-Results: smtpcorp1p.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH 1/4] vmalloc: add vm_flags argument to internal __vmalloc_node() 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:22 +0300 Message-ID: <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 allows to set VM_USERMAP in vmalloc_user() and vmalloc_32_user() directly at allocation and avoid find_vm_area() call. Signed-off-by: Konstantin Khlebnikov --- mm/vmalloc.c | 54 +++++++++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 673942094328..cece3fb33cef 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1662,7 +1662,9 @@ EXPORT_SYMBOL(vmap); static void *__vmalloc_node(unsigned long size, unsigned long align, gfp_t gfp_mask, pgprot_t prot, + unsigned long vm_flags, int node, const void *caller); + static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot, int node) { @@ -1681,7 +1683,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, /* Please note that the recursion is strictly bounded. */ if (array_size > PAGE_SIZE) { pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask, - PAGE_KERNEL, node, area->caller); + PAGE_KERNEL, 0, node, area->caller); } else { pages = kmalloc_node(array_size, nested_gfp, node); } @@ -1752,7 +1754,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, goto fail; area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | - vm_flags, start, end, node, gfp_mask, caller); + vm_flags, start, end, node, gfp_mask, caller); if (!area) goto fail; @@ -1783,6 +1785,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, * @align: desired alignment * @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 * @@ -1799,15 +1802,16 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, */ static void *__vmalloc_node(unsigned long size, unsigned long align, gfp_t gfp_mask, pgprot_t prot, + unsigned long vm_flags, int node, const void *caller) { return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END, - gfp_mask, prot, 0, node, caller); + gfp_mask, prot, vm_flags, node, caller); } void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot) { - return __vmalloc_node(size, 1, gfp_mask, prot, NUMA_NO_NODE, + return __vmalloc_node(size, 1, gfp_mask, prot, 0, NUMA_NO_NODE, __builtin_return_address(0)); } EXPORT_SYMBOL(__vmalloc); @@ -1815,15 +1819,15 @@ EXPORT_SYMBOL(__vmalloc); static inline void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags) { - return __vmalloc_node(size, 1, flags, PAGE_KERNEL, - node, __builtin_return_address(0)); + return __vmalloc_node(size, 1, flags, PAGE_KERNEL, 0, node, + __builtin_return_address(0)); } void *__vmalloc_node_flags_caller(unsigned long size, int node, gfp_t flags, void *caller) { - return __vmalloc_node(size, 1, flags, PAGE_KERNEL, node, caller); + return __vmalloc_node(size, 1, flags, PAGE_KERNEL, 0, node, caller); } /** @@ -1868,18 +1872,9 @@ EXPORT_SYMBOL(vzalloc); */ void *vmalloc_user(unsigned long size) { - struct vm_struct *area; - void *ret; - - ret = __vmalloc_node(size, SHMLBA, - GFP_KERNEL | __GFP_ZERO, - PAGE_KERNEL, NUMA_NO_NODE, - __builtin_return_address(0)); - if (ret) { - area = find_vm_area(ret); - area->flags |= VM_USERMAP; - } - return ret; + return __vmalloc_node(size, SHMLBA, GFP_KERNEL | __GFP_ZERO, + PAGE_KERNEL, VM_USERMAP, NUMA_NO_NODE, + __builtin_return_address(0)); } EXPORT_SYMBOL(vmalloc_user); @@ -1896,8 +1891,8 @@ EXPORT_SYMBOL(vmalloc_user); */ void *vmalloc_node(unsigned long size, int node) { - return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL, - node, __builtin_return_address(0)); + return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL, 0, node, + __builtin_return_address(0)); } EXPORT_SYMBOL(vmalloc_node); @@ -1938,7 +1933,7 @@ EXPORT_SYMBOL(vzalloc_node); void *vmalloc_exec(unsigned long size) { - return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL_EXEC, + return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, __builtin_return_address(0)); } @@ -1959,7 +1954,7 @@ void *vmalloc_exec(unsigned long size) */ void *vmalloc_32(unsigned long size) { - return __vmalloc_node(size, 1, GFP_VMALLOC32, PAGE_KERNEL, + return __vmalloc_node(size, 1, GFP_VMALLOC32, PAGE_KERNEL, 0, NUMA_NO_NODE, __builtin_return_address(0)); } EXPORT_SYMBOL(vmalloc_32); @@ -1973,16 +1968,9 @@ EXPORT_SYMBOL(vmalloc_32); */ void *vmalloc_32_user(unsigned long size) { - struct vm_struct *area; - void *ret; - - ret = __vmalloc_node(size, 1, GFP_VMALLOC32 | __GFP_ZERO, PAGE_KERNEL, - NUMA_NO_NODE, __builtin_return_address(0)); - if (ret) { - area = find_vm_area(ret); - area->flags |= VM_USERMAP; - } - return ret; + return __vmalloc_node(size, 1, GFP_VMALLOC32 | __GFP_ZERO, + PAGE_KERNEL, VM_USERMAP, NUMA_NO_NODE, + __builtin_return_address(0)); } EXPORT_SYMBOL(vmalloc_32_user);