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 354FEC433EF for ; Wed, 5 Jan 2022 15:17:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A17916B0071; Wed, 5 Jan 2022 10:17:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 978A06B0073; Wed, 5 Jan 2022 10:17:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 819876B0074; Wed, 5 Jan 2022 10:17:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id 6C5206B0071 for ; Wed, 5 Jan 2022 10:17:35 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 156FF8249980 for ; Wed, 5 Jan 2022 15:17:35 +0000 (UTC) X-FDA: 78996587670.23.172CDC8 Received: from m43-7.mailgun.net (m43-7.mailgun.net [69.72.43.7]) by imf22.hostedemail.com (Postfix) with ESMTP id 3D886C0011 for ; Wed, 5 Jan 2022 15:17:33 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1641395854; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=S9AtsjfAyxkE1VRytr2/1sWSS6u/ZAMynfW/PfWhtss=; b=EjQCbvnz8HbyfCIQBB3AY5B/lEKFcHwBEppb7NFldlF4xLOsGM5/B+Ga/ZjGSg+SqS93dpMQ nHYuOBk4h24T89RRnQXbVwiR3fijgtYfOZLAi4uENezmCTTc732x8/8h+ORfAzVV8cIj1KrL Ye24r9Np7athjpdhqZrkn1NvgPI= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyIwY2Q3OCIsICJsaW51eC1tbUBrdmFjay5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 61d5b68df41cb327b62294ca (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 05 Jan 2022 15:17:33 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id E37F2C4360D; Wed, 5 Jan 2022 15:17:32 +0000 (UTC) Received: from [192.168.29.110] (unknown [49.37.146.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: charante) by smtp.codeaurora.org (Postfix) with ESMTPSA id ED612C4338F; Wed, 5 Jan 2022 15:17:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org ED612C4338F Subject: Re: [PATCH v2] mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for shmem To: Shakeel Butt , Charan Teja Reddy Cc: hughd@google.com, akpm@linux-foundation.org, vbabka@suse.cz, rientjes@google.com, david@redhat.com, mhocko@suse.com, surenb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1638442253-1591-1-git-send-email-quic_charante@quicinc.com> <4a5cde83-c673-6af0-702f-f8b59e05a397@codeaurora.org> From: Charan Teja Kalla Message-ID: <08d3c298-1568-1ea2-8215-0dffa1c5a089@codeaurora.org> Date: Wed, 5 Jan 2022 20:47:25 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <4a5cde83-c673-6af0-702f-f8b59e05a397@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=mg.codeaurora.org header.s=smtp header.b=EjQCbvnz; spf=pass (imf22.hostedemail.com: domain of "bounce+d06763.be9e4a-linux-mm=kvack.org@mg.codeaurora.org" designates 69.72.43.7 as permitted sender) smtp.mailfrom="bounce+d06763.be9e4a-linux-mm=kvack.org@mg.codeaurora.org"; dmarc=none X-Rspamd-Queue-Id: 3D886C0011 X-Stat-Signature: oz7mcz8k6q63ejbpakb4bo5y5ibjebg7 X-Rspamd-Server: rspam04 X-HE-Tag: 1641395853-515651 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000813, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Firstly, Apologies for taking such a long time for the next spin. Posted V3 @ https://patchwork.kernel.org/project/linux-mm/patch/1641395025-7922-1-git-send-email-quic_charante@quicinc.com/ . Please provide your comments. On 12/6/2021 12:59 PM, Charan Teja Kalla wrote: > Thanks Shakeel for your valuable inputs!! > > On 12/2/2021 11:24 PM, Shakeel Butt wrote: >> On Thu, Dec 2, 2021 at 2:51 AM Charan Teja Reddy >> wrote: >>> >>> From: Charan Teja Reddy >>> >>> Currently fadvise(2) is supported only for the files that doesn't >>> associated with noop_backing_dev_info thus for the files, like shmem, >>> fadvise results into NOP. But then there is file_operations->fadvise() >>> that lets the file systems to implement their own fadvise >>> implementation. Use this support to implement some of the POSIX_FADV_XXX >>> functionality for shmem files. >>> >>> This patch aims to implement POSIX_FADV_WILLNEED and POSIX_FADV_DONTNEED >>> advices to shmem files which can be helpful for the drivers who may want >>> to manage the shmem pages of the files that are created through >>> shmem_file_setup[_with_mnt](). An example usecase may be like, driver >>> can create the shmem file of the size equal to its requirements and >>> map the pages for DMA and then pass the fd to user. The user who knows >>> well about the usage of these pages can now decide when these pages are >>> not required push them to swap through DONTNEED thus free up memory well >>> in advance rather than relying on the reclaim and use WILLNEED when it >>> decide that they are useful in the near future. IOW, it lets the clients >>> to free up/read the memory when it wants to. Another usecase is that GEM >>> objets which are currenlty allocated and managed through shmem files can >>> use vfs_fadvise(DONT|WILLNEED) on shmem fd when the driver comes to >>> know(like through some hints from user space) that GEM objects are not >>> going to use/will need in the near future. >> >> The proposed semantics of POSIX_FADV_DONTNEED is actually similar to >> MADV_PAGEOUT and different from MADV_DONTNEED. This is a user facing >> API and this difference will cause confusion. > > man pages [1] says that "POSIX_FADV_DONTNEED attempts to free cached > pages associated with the specified region." This statement, IIUC, on > issuing this FADV, it is expected to free the file cache pages. And it > is implementation defined If the dirty pages may be attempted to > writeback. And the unwritten dirty pages will not be freed. And thus > for Shmem files this is being done by dirtying the page and pushing out > to swap. > > So, Isn't the FADV_DONTNEED also covers the semantics of MADV_PAGEOUT > for file pages? IOW, what is the purpose of PAGEOUT for the file pages. > Or I am missing some trivial logic in your comment here? > > Coming to MADV_DONTNEED[2], on the mapped shmem files doesn't have any > effect as the pages of those shmem files can still be in RAM. Subsequent > accesses of pages in the range will succeed from the up-to-date contents > of the underlying mapped file. IOW, the pages are still be present in > the cache. Am I wrong here? > > [1] https://man7.org/linux/man-pages/man2/posix_fadvise.2.html > [2] https://man7.org/linux/man-pages/man2/madvise.2.html > > >> > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project