From patchwork Fri Mar 28 21:13:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vishal Moola (Oracle)" X-Patchwork-Id: 14032464 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 4AD72C28B20 for ; Fri, 28 Mar 2025 21:15:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61199280168; Fri, 28 Mar 2025 17:15:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C1C5280165; Fri, 28 Mar 2025 17:15:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48A42280168; Fri, 28 Mar 2025 17:15:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 29565280165 for ; Fri, 28 Mar 2025 17:15:39 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2B7C0C0789 for ; Fri, 28 Mar 2025 21:15:40 +0000 (UTC) X-FDA: 83272216440.22.E08F2F1 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf12.hostedemail.com (Postfix) with ESMTP id 558344000F for ; Fri, 28 Mar 2025 21:15:38 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BrSdgo11; spf=pass (imf12.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743196538; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=gTx9PeQwT1X+9gbRyds53dDZ2KW8HvFTaNsAU0bFORY=; b=EB2o7acW0yrp3bmmzto7fGoklLjIAywUB+iOzBxr8XyJhoVt0lsOi52pUmdK8b5DY8aM1R WZCaj7c8mdzDq9UHFrEQzVVuu9VhFnPTfxh/XbIk6aSH2W+LpcHbPkficGun2N0Um3/fnf 2uMekAws7shSOFB6v2HHG46mh5lBM5Y= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BrSdgo11; spf=pass (imf12.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743196538; a=rsa-sha256; cv=none; b=5+YLgZxxP/15lok1pu01Fy+pApmdOXnOxh1AQvigjy2mak0mx1K9zgaI4/Ofyi9Qtd5bUt FeDy8XPedMbhVj3Omw4yBqkWxvVZqrR02VPaEhpFHLujxg/y5JiThKj4t1hU0qb+W9tIxJ TwOj6cvFrVscq5eNzXl22q/gxTCcfvo= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2240b4de12bso17766345ad.2 for ; Fri, 28 Mar 2025 14:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743196537; x=1743801337; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gTx9PeQwT1X+9gbRyds53dDZ2KW8HvFTaNsAU0bFORY=; b=BrSdgo11nnfis4dhO/ypvj7B7G+Xl6OlBz3N+1xzISywE0QZWOrT+u59EFQQPUHB7b fcE3IZ+ngHMNk1sCcXVTjFkBDa5pDZ4J6Ew8PEt7cnxiXwu0J6elg/OQAfnKf8ThnZgF P8CDHPqai3BxIFHuWwHGMdIXEYC4xlbb+dakpw1aPMuQraWds5lu5KWd0Zcebw/qJJhW gLGt1K39N3NldEpyExNSb2hi20IxbcoLkJ/17P7Ab9r7buy2k/I0pDsV9d/x57+YdVkR bQ9Y3+RIENR50tKRDvS6noxx5GPHQmiboshkIt8Cn5yI0IpluvxdUwD67fMeEQkOMLDb B90Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743196537; x=1743801337; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gTx9PeQwT1X+9gbRyds53dDZ2KW8HvFTaNsAU0bFORY=; b=rH2JeRsj+1tA8Hid+WaF2fZgvGsYiMcG6+shYvVfvYy+rrHYp2YFNVLsWYucUKch++ 5WM3IxqcfQWMuJRr22DWIZdWxtX9sdvRvofaz+6vL8nsmiIDlUfsAWNOX59iEwI5WYMy 2f/li5/cqfPf5mr/qTiAvqPrYc81cRLksUCyMHMKrcrd7btVg1xdaeiifUQc2KWnAvvq LFkn9DZLFxkbNtyk+00aWWp+HBg11S5eB3K6+nFstrikH181mYIgEkmDB5lD72JsUeqJ b/3AVCOJeXjw+8WJvwE80vtgGcLUKCk5OJR45u1FWC21CFPLN8epCCvcBw1nA4UxzBa6 QlJQ== X-Gm-Message-State: AOJu0YzDY/m4eYF8VQh+KR8dogm4nI5GO8XyjWCL1RgPn+5jhfrNOpDt yeelrJOLKF9ZKFGLYtNoSNHUISvNGlBNEo3w+UVcQgYNcnAjZICMzT2s0piFocQ= X-Gm-Gg: ASbGncvtr8NPX/tyRIgI83EJdsDBoRyDQf+ej3CGyovwYulIXAGrKz30nIMlVoXCKkt HXHBVkLE2rD2BTXvh3pPlzCBsNLZ5kimIhFbJxgSC5wE/f8YDdFZQlbw0aweqe7gXzSbaQ1Pz/C 9ywUVMn/vZM1M4urBX6T/YsxU9qP1Tg6DKAf32JSak/84s0ntcuMVW0AyHMbF8OkJ6BomB1/oUv eITo7TKf0Nztkp24m8kuO4BGaUiauHiQy/1J3uyuhY0OQeR3G3K6F4A5oPNEQAM3vnPKqKb6GCa 8WalWPhBCBd5RX6DJyzObAAkJcztaLl9HsuD/noHwaIRND+4b14wAv8tKrgWnx3RuUQNlWRBAHi Ag5I= X-Google-Smtp-Source: AGHT+IGs70dKNinSk6xs+uKvlizZG0H7CFgDVfANoOBzIG3JipqlW0vixNHgt2NVbKGh++aSVmSFfQ== X-Received: by 2002:a17:902:d4ce:b0:223:6180:1bf7 with SMTP id d9443c01a7336-2292f9efbcbmr8893855ad.42.1743196536540; Fri, 28 Mar 2025 14:15:36 -0700 (PDT) Received: from fedora.. (c-67-164-59-41.hsd1.ca.comcast.net. [67.164.59.41]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-30516d55fbasm2407137a91.15.2025.03.28.14.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Mar 2025 14:15:36 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: Andrew Morton , Brendan Jackman , Huan Yang , linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [RFC PATCH v2 0/1] Introduce vmap_file() Date: Fri, 28 Mar 2025 14:13:48 -0700 Message-ID: <20250328211349.845857-1-vishal.moola@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 558344000F X-Stat-Signature: yfbsdpq5y667767jb7856mosz83eifkk X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1743196538-180244 X-HE-Meta: U2FsdGVkX19Y7PbvpN2IjaPKpTm9bdihYXVIp3PWSQlgebTXlNrpnByrwC8Dml/YCBEHU6cMOnV+nCURKBlEurTk7l+CyLM/iSQJN7X5qkCDcs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ZxQI+sl6djyZr5CRXGMiy3Ny7xVv8NsTZ4spIwzt0iFCthfWZJhzaJV71UiuV2ZRCt1S0zxBqtNJiGCRHcurffS03XqpcjQD3Cwu9vt5S9e3KHELVTMI1C4GVo4GirKfV2v3mWtwBjPVXETdOn3bK2+p8eN65tx8sTurjh5PMVKcVMgyOXqs3g6bLu4ud8HVcN2i/4+ae0Xk5AWz4sUSt7XcC4WQdSmPsi3D6m1ixkjQ6tN9rK9AaGz4YfFRffl6lkChK+TAnrWkc9UsEG+fo8nrG0ar0zVeulAF7aoQ2WST0Q== 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: Currently, users have to call vmap() or vmap_pfn() to map pages to kernel virtual space. vmap_pfn() is for special pages (i.e. pfns without struct page). vmap() handles normal pages. With large folios, we may want to map ranges that only span part of a folio (i.e. mapping half of a 2Mb folio). vmap_file() will allow us to do so. Create a function, vmap_file(), to map a specified range of a given file to kernel virtual space. vmap_file() is an in-kernel equivalent to mmap(), and can be useful for filesystems. --- v2: - Reword cover letter to provide a clearer overview of the current vmalloc APIs, and usefulness of vmap_file() - EXPORT_SYMBOL_GPL() instead of EXPORT_SYMBOL() - Provide support to partially map file folios - Demote this to RFC while we look for users -- I don't have a user for this function right now, but it will be useful as users start converting to using large folios. I'm just putting it out here for anyone that may find a use for it. This seems like the sensible way to implement it, but I'm open to tweaking the functions semantics. I've Cc-ed a couple people that mentioned they might be interested in using it. Vishal Moola (Oracle) (1): mm/vmalloc: Introduce vmap_file() include/linux/vmalloc.h | 2 + mm/vmalloc.c | 113 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+)