Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp540105lql; Mon, 11 Mar 2024 09:48:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWaZVpSmF7J+x/luz9zc+GBsAcnVfvhnjcq1diXym+DP25GkJBW7ZHTYLf2rEFrHVcSTAK0eB8F4FGuCyYcOmNPnkLPlLChvDhCAb7e4A== X-Google-Smtp-Source: AGHT+IEXWD2JtbOQblX6cdEFQelJ9AJjk/RqUlDq/NcwxXuFz50Qjeal9DzJeGjEdFKAtpZl5KqG X-Received: by 2002:aca:2210:0:b0:3c2:16d5:3d53 with SMTP id b16-20020aca2210000000b003c216d53d53mr940515oic.51.1710175728296; Mon, 11 Mar 2024 09:48:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710175728; cv=pass; d=google.com; s=arc-20160816; b=rsT1BDxxDYb2vzuxgM31AMBtv5yq3UiZIqCeqFoDNEnMcvFa/W2MDx7+HUKpoNOoMh aAfncxrg/R32leX4BgfXU3iLZ55lS6jV734q42FKmBBpsUelGnB2nH+yANqcZI4RXzbe 4ujIC6UvTN1AE4o5AgxO+mcDwpMc0NJqusWy38FAEZErBjflmkNY02QIHmbvhL+H0wcQ uJGDxuYwbX40nV/LwYVHbfP3oQ0wxBheqG8PvKxlR5udagy4vhcG3rMcwYyqsbZh2Kxm 3JYxwamlCbpeIdQ8RYNZVqM4hdxhJrHxALH9gAwbDGEDifoaSqQCls1lkI16iT0fBHOt 24Ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=UUTioQgK+VFwu4bHGNUstSWJvzqUc2xbAOy5DzulCE4=; fh=kQiLOTmmTYT/RnYbETsrCCUkzAGxYfMbAVQHF5Hzuqo=; b=k7S+4qZe+52DNe7CGLjPiXqQPs2Ig4RBdMCNPct766E/8TiPywFn4PK9uMKmWXNAk6 1fB817cTrP0cJvrpYoJ9LbeBXcY1zyJq3AV6qLjkwMhyurDsU32Gpoz/f7dXvY18FSgN g8M1zZt3EAr0O9OqnbXVdWN8U9dk0Qmg/S0CbUFjsc+WJSHQ3lBijVOOoFMyjL4iFRtt 11e7JPZfz45HexAuiWyqotvGxVynUjcYeuuEITjisp5w+bAB8irF8xoR/goL7BTUQoSp q+blM0343/isB4dTqCBpvjn3PFWFj/+EQnGYDnQXBCbXoS4EjU2Mb4D3SgHqKxxNjFba l/bw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=SUzPNr44; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-99266-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i20-20020a635414000000b005d73172aca1si5237269pgb.861.2024.03.11.09.48.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:48:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99266-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=SUzPNr44; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-99266-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5C9A3B20DA2 for ; Mon, 11 Mar 2024 16:48:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C8F556B68; Mon, 11 Mar 2024 16:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b="SUzPNr44" Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5E0654FA2 for ; Mon, 11 Mar 2024 16:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710175615; cv=none; b=bxoA8lqi8AU4NaMffJL237HyFuaKpEajNVQ5pq4wmLbMfk+Cnf9KjUWxYvwX14Wt9BblSECMGooWXybPtsEuFOw3reuyNpDn/LDNZUdKKaHvXLvChjHB45Maz8VaXcsxTHCWU73JJaSV45mhswUzi/OvpE8Y8UDWN84UEMamqlI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710175615; c=relaxed/simple; bh=J5REF2bzCzAX7O0LOHW14nTnyl8YGMv3zounUf7qQr4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rrr3D6t5kuX9VikkA7oYAw55Mk0Z/VFpJ+EJfKBvzyOABDyINM/cl8n9oO7LAWDWCxBZ8maxfMh6FsNj6lNNYBQo+6qRHP1vEukDn3A+zmN9U9lJW5jyD8KFbtPAiAk10R3j/szE1oScfyC04C/gjsL1HYOvx3oaG2grMKSSnJk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b=SUzPNr44; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-78850ab4075so120664885a.1 for ; Mon, 11 Mar 2024 09:46:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1710175612; x=1710780412; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=UUTioQgK+VFwu4bHGNUstSWJvzqUc2xbAOy5DzulCE4=; b=SUzPNr44BG72fCi5CjWAI1V5z26hOG3O70z6dpgZmoI0Hie9Bb5RZ/y/i+WpfZcpDc zqn15CuFqqma3nQj2QF2/9bV/iowcKNpwOgPKZ9n4u/UP6q2Yk9n/akcXS4zbhIT9uGe nFAgmY57GPDejAT3ytqEbDRKNcfbZ3ii+D9kTwSrZlva/a02KZRvG1F9yQCU3ywJv20s j7IRWwDmDep/P6Gw7ikDRoVbq/KuauaZw+MvlY3WQS4w+RMM2omI38z2Jnsj2SKOiqL8 pVEggM2qsy1yrmgr/yOanBVLaasw0ZT6gjEEqvkK1GVbRO88DxHb1XQknFcU9g3YawRG Gq9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710175612; x=1710780412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UUTioQgK+VFwu4bHGNUstSWJvzqUc2xbAOy5DzulCE4=; b=UVdzOxkA9jPXIgkTAZ571SIhTm+4JpBEu+GnB2mzCNerWr5oxy1/QHIh/ekg6/Wo4u lakMk0sMIY06T7ldzMkj5iF42yKH9DPBxkp/dZoaxD/ra+EByw52tnld/K5ZmUlY3S4c sHzWyn3BsxxcPIGuqEujQcwsm0NDH79Wmj5SvEfyCCSRn0cIbWQ+n3MDILZCqcLH7Hkc pmjvId48GuCGTGo3J4JF7pLtnFOb5QmAjExSvwFIpgBULCOonKZ9kPseO5WTupTrfIph gMoAaWXXIm558ktBYyhpbJzz84oTGRtE1iEpZ8mtZKwZ0d/WsVQuLcgu55+Fz1DFuI3n MZqg== X-Gm-Message-State: AOJu0YxFB249T7CnbwaD3MXFWWTn2wzvYaqIU4itBsMkDFCAfrx2q11S D7oAqsltxi7kD/L2AHC3JxaC6/XHdLrsrnR8N7eDZvoen0Hbqhr8L9grIDb1QbepwBPcoA+FHjY irJE= X-Received: by 2002:a05:620a:5d9a:b0:788:5909:8ce5 with SMTP id xx26-20020a05620a5d9a00b0078859098ce5mr1085134qkn.34.1710175612342; Mon, 11 Mar 2024 09:46:52 -0700 (PDT) Received: from soleen.c.googlers.com.com (150.254.86.34.bc.googleusercontent.com. [34.86.254.150]) by smtp.gmail.com with ESMTPSA id d27-20020a05620a137b00b00788228fbe05sm2851589qkl.17.2024.03.11.09.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:46:51 -0700 (PDT) From: Pasha Tatashin To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, x86@kernel.org, bp@alien8.de, brauner@kernel.org, bristot@redhat.com, bsegall@google.com, dave.hansen@linux.intel.com, dianders@chromium.org, dietmar.eggemann@arm.com, eric.devolder@oracle.com, hca@linux.ibm.com, hch@infradead.org, hpa@zytor.com, jacob.jun.pan@linux.intel.com, jgg@ziepe.ca, jpoimboe@kernel.org, jroedel@suse.de, juri.lelli@redhat.com, kent.overstreet@linux.dev, kinseyho@google.com, kirill.shutemov@linux.intel.com, lstoakes@gmail.com, luto@kernel.org, mgorman@suse.de, mic@digikod.net, michael.christie@oracle.com, mingo@redhat.com, mjguzik@gmail.com, mst@redhat.com, npiggin@gmail.com, peterz@infradead.org, pmladek@suse.com, rick.p.edgecombe@intel.com, rostedt@goodmis.org, surenb@google.com, tglx@linutronix.de, urezki@gmail.com, vincent.guittot@linaro.org, vschneid@redhat.com, pasha.tatashin@soleen.com Subject: [RFC 09/14] mm/vmalloc: Add a get_vm_area_node() and vmap_pages_range_noflush() public functions Date: Mon, 11 Mar 2024 16:46:33 +0000 Message-ID: <20240311164638.2015063-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240311164638.2015063-1-pasha.tatashin@soleen.com> References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit get_vm_area_node() Unlike the other public get_vm_area_* variants, this one accepts node from which to allocate data structure, and also the align, which allows to create vm area with a specific alignment. This call is going to be used by dynamic stacks in order to ensure that the stack VM area of a specific alignment, and that even if there is only one page mapped, no page table allocations are going to be needed to map the other stack pages. vmap_pages_range_noflush() Is already a global function, but was exported through mm/internal.h, since we will need it from kernel/fork.c in order to map the initial stack pages, move the forward declaration of this function to the linux/vmalloc.h header. Signed-off-by: Pasha Tatashin --- include/linux/vmalloc.h | 15 +++++++++++++++ mm/internal.h | 9 --------- mm/vmalloc.c | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index c720be70c8dd..e18b6ab1584b 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -210,6 +210,9 @@ extern struct vm_struct *__get_vm_area_caller(unsigned long size, unsigned long flags, unsigned long start, unsigned long end, const void *caller); +struct vm_struct *get_vm_area_node(unsigned long size, unsigned long align, + unsigned long flags, int node, gfp_t gfp, + const void *caller); void free_vm_area(struct vm_struct *area); extern struct vm_struct *remove_vm_area(const void *addr); extern struct vm_struct *find_vm_area(const void *addr); @@ -241,10 +244,22 @@ static inline void set_vm_flush_reset_perms(void *addr) vm->flags |= VM_FLUSH_RESET_PERMS; } +int __must_check vmap_pages_range_noflush(unsigned long addr, unsigned long end, + pgprot_t prot, struct page **pages, + unsigned int page_shift); + #else static inline void set_vm_flush_reset_perms(void *addr) { } + +static inline +int __must_check vmap_pages_range_noflush(unsigned long addr, unsigned long end, + pgprot_t prot, struct page **pages, + unsigned int page_shift) +{ + return -EINVAL; +} #endif /* for /proc/kcore */ diff --git a/mm/internal.h b/mm/internal.h index f309a010d50f..ba1e2ce68157 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -969,19 +969,10 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe, */ #ifdef CONFIG_MMU void __init vmalloc_init(void); -int __must_check vmap_pages_range_noflush(unsigned long addr, unsigned long end, - pgprot_t prot, struct page **pages, unsigned int page_shift); #else static inline void vmalloc_init(void) { } - -static inline -int __must_check vmap_pages_range_noflush(unsigned long addr, unsigned long end, - pgprot_t prot, struct page **pages, unsigned int page_shift) -{ - return -EINVAL; -} #endif int __must_check __vmap_pages_range_noflush(unsigned long addr, diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d12a17fc0c17..7dcba463ff99 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2650,6 +2650,30 @@ struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags, NUMA_NO_NODE, GFP_KERNEL, caller); } +/** + * get_vm_area_node - reserve a contiguous and aligned kernel virtual area + * @size: size of the area + * @align: alignment of the start address of the area + * @flags: %VM_IOREMAP for I/O mappings + * @node: NUMA node from which to allocate the area data structure + * @gfp: Flags to pass to the allocator + * @caller: Caller to be stored in the vm area data structure + * + * Search an area of @size/align in the kernel virtual mapping area, + * and reserved it for out purposes. Returns the area descriptor + * on success or %NULL on failure. + * + * Return: the area descriptor on success or %NULL on failure. + */ +struct vm_struct *get_vm_area_node(unsigned long size, unsigned long align, + unsigned long flags, int node, gfp_t gfp, + const void *caller) +{ + return __get_vm_area_node(size, align, PAGE_SHIFT, flags, + VMALLOC_START, VMALLOC_END, + node, gfp, caller); +} + /** * find_vm_area - find a continuous kernel virtual area * @addr: base address -- 2.44.0.278.ge034bb2e1d-goog