From patchwork Mon Mar 11 16:46:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13589084 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A28C5C5475B for ; Mon, 11 Mar 2024 16:47:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A28596B00D4; Mon, 11 Mar 2024 12:46:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 947906B00D5; Mon, 11 Mar 2024 12:46:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78CF46B00D6; Mon, 11 Mar 2024 12:46:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5B2EE6B00D4 for ; Mon, 11 Mar 2024 12:46:55 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 330CE14054E for ; Mon, 11 Mar 2024 16:46:55 +0000 (UTC) X-FDA: 81885337590.01.6A0ED25 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by imf01.hostedemail.com (Postfix) with ESMTP id 4DC974001D for ; Mon, 11 Mar 2024 16:46:53 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=O3SlzjZl; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.177 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710175613; a=rsa-sha256; cv=none; b=y+cWuWCbRaLRnJhLY471lcbEjGzdqdEvMzMGVpT2LbMdrg3srpwmrIqvok6X1Sr0twOdAN MSb3L4oZKOGZX61mmmyjMO0sQNRsaS5jV/u5JKiYYjl18N89ssMpQibicFQH23duY4jYZY 3QpBJUXlm8QLbJ3wUGwSdX6r0QGAROI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=O3SlzjZl; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.177 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710175613; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UUTioQgK+VFwu4bHGNUstSWJvzqUc2xbAOy5DzulCE4=; b=nmbjFpk4L3INmfz6QyXqKFWyCWlp67N3ZB4HtgyDGz1lsMwiX2zazEHM1Ki4Hn1WQy6d+Y ABD/nuMHHKX/4/x2ieIy4dtJ9ApSVXMqFCLNhyX6jOn/rzePtr7YcSteGrVrV2Ged6caUE 2DakMI5w3r8xZ0OpVpkETqD6+xoG5Y4= Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-78822adc835so198828285a.3 for ; Mon, 11 Mar 2024 09:46:52 -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=kvack.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=O3SlzjZl3EXLglHISO3vKH91NRgKUNmhysBrPi+uAmgFKrJWYle4ELbXVudb5/rRkg 16xJkYsHhtzTVOwxk8E2d1hbrznDoNDcU5mSyL7M/TMzcomCc8Dwi2zorPG/DJqmy5+H rS6PyUwS1TuIzJrRS2iBo9VaIoVigEamtWdRfom41zaA4UfpRx6lgFrnLQFB0Sx760sY T1OA2XY5d49yT7ORjRHLj6q3nGj7qa/XnLmvNf3KlYtFOnsZ1Bz62C593/V5GjrSqnL+ PLV9myVQyo4kYr+vt7PxQuZePYu44fi7X5JE7L4nxSUOQf9n049BiAc9JnJv7ibvhqZb N6wg== 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=XmB6WjW26IW9VusS5Q6vm7cd63rZVZDi+fgO7Sc7CCdIjTMGwuFsT1rbIcVJvIimo+ 1zIL/L+zsmeLiUX1aIh9TJcYlJMmnPIHNSrojtWtQJAyAMwv40OvVM11XL6c59QBjm5F AfXca12SHUshcPgd2E+Z2MPJgtb8zI9pvU4H7RT4vSNrvUuc3ohb3n2IOUc5hmdDLGFA bdhCBkf/7KQLfzFkjDNtLjpRYEh1X5j6yx4uBblYs6TPqrhcjUHCy620Z2YtplBMtUMK otRGlqdEZA2rc6AnMI5JdsSNQac5rftmx2soe1evMloWDXJQ3iw1LUtXq6Vjcld+P6zk C+7Q== X-Forwarded-Encrypted: i=1; AJvYcCV3Jg/85BbtoD7rDhLUYIxRbVmUggreVN9azfF7N/yISjEMViWknvlLbCJ/1RnoDsfSqR/UZCNgjiSGWyvJt0jMmFM= X-Gm-Message-State: AOJu0Yz6mkq5FZHrsw3DJVm7AP1vGPp+HnpFq6ERcKA/No97RPVGjpvS UmAciupZLJJKT1orgy2sBFIT7BAKOcIMRXS6QfjBrWi40IbVsOIPPhVlkZ4/RNg= X-Google-Smtp-Source: AGHT+IF4clsrNYnhAmKVCQ5b1CkyUTVuvR4XaNSojXhA81ENz+LMIfO1rJKaTKEeTeVkpkuetWxx/w== 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> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4DC974001D X-Stat-Signature: 74611hjz8taic1bg7eecr5az51fz87te X-Rspam-User: X-HE-Tag: 1710175613-386306 X-HE-Meta: U2FsdGVkX1+E0pKzfKl3ydverKDc0Ich7bnxzXzf63uhiYsHDhAsI+ucbYVr7tR3xciHNYhnp5NZ80kg4kPHQ5s9CWi+fgnxuXK1Rf0MTzsty9WWYavQXL2DHQlriT/U89/UbZ+36HYEbCj5uLZwNUUErQxzH4Lklkedo/DMdgvpBS/GC+xxzlHHv3Eu2Lb6blNI09UKVFrNWGLAZzHCXroIcX2WZyY6XNw5BvTF7CJwHv9Qs7rXZ/SbBNxFzxmSfjJ9ArtBQfpJizeVD74uxVBlck27+C53Ftp5Ju+xNlRpPFGFn+k7o3NCwhN/OvNBHpGN2mu2yf2Wns9+sAr0Hj0yY3/mZrefw5dG2BaYH3lOKclvPRxDUVdTnpj+HYnLOZsSK+XE7KCfXS39o1WTSYNXoio2pHd5meoCn3S9Yrjohs6EFZaUyMzotG96akzfV+s98JpWwwZW2lEtrEA4ypy6ECwbPdjN7eIXuE3PUFM6HYTYsDGD8b9f8m0G2xDbwP339SOSBh7lZ+lO0BosN+EANaveud4oZ3YEn0JEQfbttEcgbZrC1Q74/R7PWmWPbyxecwhr1uN395k8+yDvllPv6wncSm0DCh81dvhRjbz0XSUwCrZKwTFVTnp+RZn891dmP+Htaq/nZDJjt7GkhrhkHs3M6LIDTL7FHsLgeTrm9N1WWoz5KjQruPD3P7/Wmp1lVERbgaNdqv3+yBATq57Uz7xfejCwsVtJmzNE+xSB1Xzt5Gez7Wm3NENVIyzbpvh0kVWfjtwW7N7R4Wel3snv2TmR1XMpXyeivPU4nbGy+7ew8HuAai3JswP0PDCXTDzsXeR6G7pBSXAuBacNafJqp8rpXDKkkIpbMyQZMUjUrD12Bqd6B2Xc2ymMhaO/31bo538uuQHqs2JBVmcgwo8P5fuPNjEx+GYaJeu99OxhcCSaHMVA3I3wK+febw36guEUwzFjxFZTRJYZ/Ib fijk/CId EuHR2mu1TFMuU1sE4QkMZcbGD8xQI8Y4R7bDRwyYHsNwlEfX+AVtYNnAZvU3syLzJSihxVFYnoOMXYyGbAfIqCM6IAaLzGVOMH6eFz+yFRlG2V24/H9tA2DUxSXloydnd3pQ71MTDWQWr7a4e5XUdQWlYvZ5JybASyngTLn8VeDq+Fp5MRgxxYvNylp0AOi41hzprF9E3ldhIYuvkMSslSAva/D/6XKoYwUwr8A4Fhpt1rNsc1XVN1i4gV19gQJ+8ew+mMM3Tp6gPUfnoYNcASR31pxtBM/VJNYLSnNxNsUSsWhuORV9bWkfmpmnoMC8xbjLzbmbGyULnZ0ryi8xKnpumHamw5BXGl81NPU6RI2pHjRI+EO+B2DjO/hF8O/UTjJpCGZgcvUKejeXw3qO8ury+boV6We0askMGVppFimHzGhsULW/dSaJyiqt0U5EuESuw8Es2aZkJyLALLJTNQiNKyRfUcim++FIoIoygTdv/GATuD+zQtEFsQ3PqKVPCg5M6 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: List-Subscribe: List-Unsubscribe: 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