From mboxrd@z Thu Jan 1 00:00:00 1970 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 B5B8BC36008 for ; Tue, 1 Apr 2025 03:19:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17B5E280002; Mon, 31 Mar 2025 23:19:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10DBC280001; Mon, 31 Mar 2025 23:19:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBFF7280002; Mon, 31 Mar 2025 23:19:46 -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 CA15F280001 for ; Mon, 31 Mar 2025 23:19:46 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CD0BE1405F7 for ; Tue, 1 Apr 2025 03:19:47 +0000 (UTC) X-FDA: 83284020414.23.13CA553 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf09.hostedemail.com (Postfix) with ESMTP id 0321F140009 for ; Tue, 1 Apr 2025 03:19:45 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dlypRRK7; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743477586; a=rsa-sha256; cv=none; b=bxLKj6MdcIend/4BhSUBH7sLB+l2dWi8kw+jI74hLBVtSBmUpOpV8bwRYlAmOmC3LkJAfX Ui8vE8bXEh7sPrm9bOlP1ftnbshl+qwbUW83b5kSkBUp2LZRmMLe9ykRlUoHinQs/4mowf 9f0TIhObMAyITF2OSr6poDOVORqd1Ro= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dlypRRK7; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743477586; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qSA6nscHvUXLIy2KiUBnTSjJSsojlhHgxKPamJIxqA4=; b=H+3VfzhBtivt3OVGIu2Ekzs4Esc9kNnjwFnF/v3I8x5M8C/uAaNDy/GqiVZ+kHyOY6XjiF VKrXnA8mgR3y9XecQDprL1UWf6PRFmIK90eR2Wp8e6Ykvau13+e6Qxm6OfwbFv37qjfqBB aYZfFyuBcNKeuBZVjw8MYBiqIBSLbJQ= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-223f4c06e9fso93156175ad.1 for ; Mon, 31 Mar 2025 20:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743477585; x=1744082385; darn=kvack.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=qSA6nscHvUXLIy2KiUBnTSjJSsojlhHgxKPamJIxqA4=; b=dlypRRK736QctKFtMGnY40XMfa7qL2E0R1zmqZZN4pE/QykVeyzU21aynzZDpFe2PC 0b8OzzW04jO4dBtklDCsavnG/6mN5KZL1BvlcQusSLkcn1jYKqpZEqDBSYrS2aIynsAj eeujglu6dJngfQ4LylsRJNxE30gqI6R/wbxhXkBomLL+mVhT7b1gLfIc2QYxoGQNKEbl Wusq6HEEDmD75yXl5cWzq6zrK1diuK9UQLYDVdc0A9LNhX0tB2xXgSdIcVWMxLlsPvXy FHGH3nHvXVugNf4FzjMe62u1oT+k+i5hmrnXH/7Yi88J7LgRZBbxAFaZfAeLuqUyGjxn pdxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743477585; x=1744082385; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qSA6nscHvUXLIy2KiUBnTSjJSsojlhHgxKPamJIxqA4=; b=M/biAST1duWJQuucaiXOshAMi7GkMB6wv0ag3+55h8ZMIfI1uQYQRtlZ7W+xfT1Ccm hkeeB1dSMOFghdYKOVbfqZJR6AMT/SXuym+lQcb7Q05hs1mFZLqISIANYDUzFe58+4// nOThDieLRj8yEkQnsA7oYtgIuUr1Q9If/DkEYBd69P03yNLdzWgemoOye9TIM1gxkWBQ 5ty0cOJ3pCWl8HcPxyKM4wC9TNEyUHrC+Zwk8XASlmWZQjcr1Fo9HcxAy2Jv1MQxVtwf lJKHP1UrCRJTv4J//RuNzx7BCZuTStASIDCdBB8G6YSyKLT4VX6XizKuGukVAFdoBtwF Q5Pw== X-Gm-Message-State: AOJu0YyjCP9bgZnWyivkYC2hLUUC80axa7CLyqb9uCZVi5ZcJpG4y5C8 6/xY4Oi/qAK7rCzw5a47CYejOGQFlfBisXW7auAvQTUf6ASMDav7 X-Gm-Gg: ASbGncuhk16q72thyXiPsvrjz986TD3jK2LUAfD7AyQF1mIRc1SYLY1cFXgNwGX+yfA XT8s8iuvDQFPRPtKAbIN4TNySO/pIgUDP7oVb+k5K5XG5G4LlDa6CMMEpRFku53BjpwWGQNmqKU XflhuG6PwFepodmYkBcn+HRWFYZCKRudToRVQWJdfXOUMotMUEhu6Gsc6RXEZsZkbu4Z0GnWy1a oaZs9p2ck5LQqEA32kAgzNX04e5kzM0yDq9aLEfGjWX0ekTUX3MUk2lfWF9yH9xhxOVOhaf/Y4g j71oRPZDzteUmJrcajNyDTFUhAF/MXkpGYhN3bJIDBt539JfDKnsfj3s23hEOtuXpuAV6v1tfe/ I X-Google-Smtp-Source: AGHT+IFevRgm143Sh1HSPNR922oPs6dlDmwWjnJnb+QfW2hFF1JlgS0mnFU402xbbOW30lgePWVVAQ== X-Received: by 2002:a17:903:178b:b0:21f:58fd:d215 with SMTP id d9443c01a7336-22921ccc028mr224889835ad.11.1743477584671; Mon, 31 Mar 2025 20:19:44 -0700 (PDT) Received: from fedora (c-67-164-59-41.hsd1.ca.comcast.net. [67.164.59.41]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1f572dsm77200525ad.232.2025.03.31.20.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Mar 2025 20:19:44 -0700 (PDT) Date: Mon, 31 Mar 2025 20:19:41 -0700 From: "Vishal Moola (Oracle)" To: Huan Yang Cc: linux-mm@kvack.org, Andrew Morton , Brendan Jackman , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 0/1] Introduce vmap_file() Message-ID: References: <20250328211349.845857-1-vishal.moola@gmail.com> <02ba63ed-ef1c-426d-b469-09878c5f03d7@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0321F140009 X-Stat-Signature: gi5axmk83t4awg5jmy3n9myf95beg98w X-Rspam-User: X-HE-Tag: 1743477585-327140 X-HE-Meta: U2FsdGVkX1/fv/yoGmQ6/2AoTKo4n1LrKwXsVPGDnpWCQ6KBLYr2sSZlBn+ZsyEL/e4y7phsllIryGp0M7Ko2XOqoL9NO3TA10QkR+GjpBACyWCgUWM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NrI/EKhmlNZALzd9WGrkzTbJlC1Yzh3LUJUsd272+aOCHl9y4ZTFehwlt6cE+CswLTzYRVwwjE7lSv7COeUgm6S2SurHogKXif75K3fkto2pLxHKO9WzyyOAXbbzPpaiX3ufJziU5Er5faaZzV+TeWmbIlHVD/KDQu/y43QfNVir/MdVED5Zxam69ESr8FjAClJ4DknGqeBFWlzyTnQ/ydzyl4QtWD/5/CZTN0ddJxq62VIMZto0vuvmyDfGy5EGwRJM5wnX7klB+Ohqme5zRgiWFWOZtlIORbpWIoXVz5495N/kns502xuETmTtBIzN6/d8ru9nsyklrn1K 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: On Tue, Apr 01, 2025 at 10:21:46AM +0800, Huan Yang wrote: > > 在 2025/4/1 09:50, Vishal Moola (Oracle) 写道: > > On Mon, Mar 31, 2025 at 10:05:53AM +0800, Huan Yang wrote: > > > HI Vishal, > > > > > > 在 2025/3/29 05:13, Vishal Moola (Oracle) 写道: > > > > 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. > > > You mention vmap_file can support range folio vmap, but when I look code, I can't figure out > > > > > > how to use, maybe I missed something? :) > > I took a look at the udma-buf code. Rather than iterating through the > > folios using pfns, you can calculate the corresponding file offsets > > (maybe you already have them?) to map the desired folios. > > Currently udmabuf folio's not simple based on file(even each memory from memfd). User can provide > > random range of memfd  to udmabuf to use. For example: > > We get a memfd maybe 4M, user split it into [0, 2M), [1M, 2M), [2M, 4M), so you can see 1M-2M range repeat. > > This range can gathered by udmabuf_create_list, then udmabuf use it. So, udmabuf record it by folio array+offset array. I was thinking you could call vmap_file() on every sub-range and use those addresses. It should work, we'd have to look at making udmabuf api's support it. > I think vmap_file based on address_space's range can't help. I'm not familiar with the memfd/gup code yet, but I'm fairly confident those memfds will have associated ->f_mappings that would suffice. They are file descriptors after all. > > > > > And this API still aim to file vmap, Maybe not suitable for the problem I mentioned in: > > > > > > https://lore.kernel.org/lkml/20250312061513.1126496-1-link@vivo.com/ > > I'm not sure which problem you're referring to, could you be more > > specific? > > 1. udmabuf not same to file vmap usage > > 2. udmabuf can't use page struct if HVO hugetlb enabled and use. vmap_file() doesn't depend on tail page structs. > It still need pfn based vmap or folio's offset based range vmap.(Or, just simple reject HVO folio use vmap) :) > > > > > > Thanks, > > > Huan Yang > > > > > > > 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(+) > > > >