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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3903CFC50A for ; Fri, 21 Nov 2025 21:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:In-Reply-To:MIME-Version:References: Message-ID:To:Date:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AayZiY21hL6qSsLEVfcgiw2z7k4JzQC+kpMJ/TISfes=; b=A3KTUcAwqHQIu/BYNv+bBfPShm 7OsQyyNL7DZoFtvKi54Vm7ZJvzqDfM5apO6yg+tKvivlQzM8SCb5ARscEmORQhdt2i0Bhd6VxZldu uo2qCmGZITwd2A9+AMadsg+ONcQBvqNpJHft5BNbliGAQEdoDwlOr4WZfhw2A0sY+y4M=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vMYjy-00028A-Bx; Fri, 21 Nov 2025 21:32:26 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vMYjx-000284-P4 for linux-f2fs-devel@lists.sourceforge.net; Fri, 21 Nov 2025 21:32:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lYoE+OlaecIlilZnJdX1xXHAW+IvyDep4xnmyFkZFSQ=; b=QvHSy/whnERiekGWt2KXBc1aRC jdgFLARnO3+gCAGf+hFgbb1+YpMAvZliToOgbx4BDOa+3ixIN95qTMuOdsZw5tyPf0Cv36bUByoEE WogMwoYEehqPryvAJxw6v/549YqU3S2CBPbe0lZMyI6GdI32HjgCd1vpW2CgCvTDVThw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lYoE+OlaecIlilZnJdX1xXHAW+IvyDep4xnmyFkZFSQ=; b=GjziUZuKtmtPwq55fE4qkrCBaX DzGTfkcf2dx4905O5r3VSnXBhVjB/at7vVO8RmhaYtla8GsfZMgdzyMYH8GPEHe/zgLzBFj2+a3XP HtcQ5K4dmzMb3CEXXDiEDZlUHZDiQijq+h16pARax6IVVV7xNdXVAXWn7E7YCqMk/V8Q=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vMYjx-0005Uc-9r for linux-f2fs-devel@lists.sourceforge.net; Fri, 21 Nov 2025 21:32:25 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id E5380416CF; Fri, 21 Nov 2025 21:32:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97986C116C6; Fri, 21 Nov 2025 21:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763760734; bh=9CXYMqrOIm+Q10uDMB/uyJplbeY1MEE5pftnNW81HpY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nMjYo/daf/v/pGj0zjIz0yC1qxreOE5r1ZeyyiYlLQdzropLyAJ+/yphoLIMuv6TJ BhAP7mLvOh7w+8zluIiEo6BXH6fGDEm4vhqfy1PBRhHQ8/JFiSsAMD2QKR1NiXUFSR Hudl6H6y91ltl/SzecKQRISdewodQrHyUhPxoYFFyFAp5Qwl3F8akL63ZNMlaaynfh 3ZPiz4q+DyPSwD7A+uzmjRnF+d7hMor4x+nFinc9hzvHFYsSTW63+turuEU7tDK5H5 Jjw2NxFk1Fg6gN8m3E5Gcflh9I1Mq2kNOqIx/ZtH9Oyb2gtDIpX7+cwWjN8CI9fdIm 97xU5Kq4GIQSA== Date: Fri, 21 Nov 2025 21:32:12 +0000 To: Matthew Wilcox Message-ID: References: <20251121032718.1993528-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1vMYjx-0005Uc-9r Subject: Re: [f2fs-dev] [PATCH] [RFC] mm/fadvise: introduce POSIX_FADV_MLOCK X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jaegeuk Kim via Linux-f2fs-devel Reply-To: Jaegeuk Kim Cc: Christian Brauner , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 11/21, Matthew Wilcox wrote: > On Fri, Nov 21, 2025 at 07:52:02PM +0000, Jaegeuk Kim wrote: > > On 11/21, Jaegeuk Kim wrote: > > > On 11/21, Matthew Wilcox wrote: > > > > On Fri, Nov 21, 2025 at 04:46:14AM +0000, Jaegeuk Kim wrote: > > > > > On 11/21, Matthew Wilcox wrote: > > > > > > On Fri, Nov 21, 2025 at 03:27:18AM +0000, Jaegeuk Kim wrote: > > > > > > > This patch introduces a new POSIX_FADV_MLOCK which 1) invalidates the range of > > > > > > > cached pages, 2) sets the mapping as inaccessible, 3) POSIX_FADV_WILLNEED loads > > > > > > > pages directly to the inaccessible mapping. > > > > > > > > > > > > ... what? > > > > > > > > > > > > This seems like something which is completely different from mlock(). > > > > > > So it needs a different name. > > > > > > > > > > > > But I don't understand the point of this, whatever it's called. Need > > > > > > more information. > > > > > > > > > > So, the sequence that I'd like to optimize is mmap(MAP_POPULATE) followed > > > > > by mlock(). For example, mmap() takes 1 second to load 4GB data, and mlock() > > > > > takes 330ms additionally in order to migrate all the pages into inaccessible > > > > > map, IIUC. > > > > > > > > Oh, so the MLOCK part is right, but the inaccessible() part is wrong. > > > > Inaccessible is special weird guest_memfd crap that has all kinds of > > > > side-effects that you don't want. > > > > > > > > Wouldn't you get the same effect by calling mlock2(MLOCK_ONFAULT) and > > > > then calling readahead() for the desired range? > > > > > > Oh, thank you. Let me try. > > > > After checking the code and experiment, I don't think that gives what we need. > > That flag skips populate_vma_page_range only, but we need to allocate pages > > in the inaccessible mapping and fill the pages afterwards. > > Then either I don't understand what you're trying to do, or you don't > understand what the inaccessible mapping is for. Is this just for > speeding up mlock() as you suggested earlier, or are you genuinely > trying to do something with the inaccessible mapping? The latter. I'd like to propose a new read flow with the inaccessible mapping. As-Is: mmap() -> fadvise(fd, POSIX_FADV_WILLNEED) -> mlock() 1. fadvise() proposal mmap() -> fadvise(fd, POSIX_FADV_MLOCK) : all the pages will be loaded into inaccessible page cache directly 2. mlock2() proposal mmap() -> mlock2(MLOCK_ONFAULT) -> madvise(MADV_POPULATE_READ) If you mean #2, I need to find whether we can get the space for madvise, since we have only fd when reading the pages. And, also I need to find a way to handle the folio order directly instead of starging from 0 in madvise() path. Let me think about it. _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A54B4315A for ; Fri, 21 Nov 2025 21:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763760735; cv=none; b=bUlo09w3hdDWFLMfYB0D2Ut2pPfnWHKlQBnz+9S3x275G9TAXk3wtL9gL5PxYoLCKldEPPOBf5mNtebejWh80CsDDd3V4MdNwi2MqmZlsew5F8/O0JBM8KkhsxG6d5yIs/bCqhuua4zD2QAP38n0zA/mVQM4bRpB1/Fohai8DW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763760735; c=relaxed/simple; bh=9CXYMqrOIm+Q10uDMB/uyJplbeY1MEE5pftnNW81HpY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SwlZqw9turW2VhYLVQ4L2uDDo17oz7uDki7/KhYzvi+jYGSzl98/mD4r3qn7AwBfTR172CetRMRkJ3KT3C51hW9I2oxKOH0CYUtduuFav0pkxmaJkxgN8ysB7CY/gH1Er5WBdiQkZGB3RJvbcTKKaRJgjFCBsRAvshsw2Ptm/tA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nMjYo/da; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nMjYo/da" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97986C116C6; Fri, 21 Nov 2025 21:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763760734; bh=9CXYMqrOIm+Q10uDMB/uyJplbeY1MEE5pftnNW81HpY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nMjYo/daf/v/pGj0zjIz0yC1qxreOE5r1ZeyyiYlLQdzropLyAJ+/yphoLIMuv6TJ BhAP7mLvOh7w+8zluIiEo6BXH6fGDEm4vhqfy1PBRhHQ8/JFiSsAMD2QKR1NiXUFSR Hudl6H6y91ltl/SzecKQRISdewodQrHyUhPxoYFFyFAp5Qwl3F8akL63ZNMlaaynfh 3ZPiz4q+DyPSwD7A+uzmjRnF+d7hMor4x+nFinc9hzvHFYsSTW63+turuEU7tDK5H5 Jjw2NxFk1Fg6gN8m3E5Gcflh9I1Mq2kNOqIx/ZtH9Oyb2gtDIpX7+cwWjN8CI9fdIm 97xU5Kq4GIQSA== Date: Fri, 21 Nov 2025 21:32:12 +0000 From: Jaegeuk Kim To: Matthew Wilcox Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Christian Brauner Subject: Re: [PATCH] [RFC] mm/fadvise: introduce POSIX_FADV_MLOCK Message-ID: References: <20251121032718.1993528-1-jaegeuk@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On 11/21, Matthew Wilcox wrote: > On Fri, Nov 21, 2025 at 07:52:02PM +0000, Jaegeuk Kim wrote: > > On 11/21, Jaegeuk Kim wrote: > > > On 11/21, Matthew Wilcox wrote: > > > > On Fri, Nov 21, 2025 at 04:46:14AM +0000, Jaegeuk Kim wrote: > > > > > On 11/21, Matthew Wilcox wrote: > > > > > > On Fri, Nov 21, 2025 at 03:27:18AM +0000, Jaegeuk Kim wrote: > > > > > > > This patch introduces a new POSIX_FADV_MLOCK which 1) invalidates the range of > > > > > > > cached pages, 2) sets the mapping as inaccessible, 3) POSIX_FADV_WILLNEED loads > > > > > > > pages directly to the inaccessible mapping. > > > > > > > > > > > > ... what? > > > > > > > > > > > > This seems like something which is completely different from mlock(). > > > > > > So it needs a different name. > > > > > > > > > > > > But I don't understand the point of this, whatever it's called. Need > > > > > > more information. > > > > > > > > > > So, the sequence that I'd like to optimize is mmap(MAP_POPULATE) followed > > > > > by mlock(). For example, mmap() takes 1 second to load 4GB data, and mlock() > > > > > takes 330ms additionally in order to migrate all the pages into inaccessible > > > > > map, IIUC. > > > > > > > > Oh, so the MLOCK part is right, but the inaccessible() part is wrong. > > > > Inaccessible is special weird guest_memfd crap that has all kinds of > > > > side-effects that you don't want. > > > > > > > > Wouldn't you get the same effect by calling mlock2(MLOCK_ONFAULT) and > > > > then calling readahead() for the desired range? > > > > > > Oh, thank you. Let me try. > > > > After checking the code and experiment, I don't think that gives what we need. > > That flag skips populate_vma_page_range only, but we need to allocate pages > > in the inaccessible mapping and fill the pages afterwards. > > Then either I don't understand what you're trying to do, or you don't > understand what the inaccessible mapping is for. Is this just for > speeding up mlock() as you suggested earlier, or are you genuinely > trying to do something with the inaccessible mapping? The latter. I'd like to propose a new read flow with the inaccessible mapping. As-Is: mmap() -> fadvise(fd, POSIX_FADV_WILLNEED) -> mlock() 1. fadvise() proposal mmap() -> fadvise(fd, POSIX_FADV_MLOCK) : all the pages will be loaded into inaccessible page cache directly 2. mlock2() proposal mmap() -> mlock2(MLOCK_ONFAULT) -> madvise(MADV_POPULATE_READ) If you mean #2, I need to find whether we can get the space for madvise, since we have only fd when reading the pages. And, also I need to find a way to handle the folio order directly instead of starging from 0 in madvise() path. Let me think about it.