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 A91EEC433F5 for ; Thu, 2 Dec 2021 17:55:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CF4E6B0075; Thu, 2 Dec 2021 12:54:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 27F396B0078; Thu, 2 Dec 2021 12:54:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16EB66B007B; Thu, 2 Dec 2021 12:54:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 09A9F6B0075 for ; Thu, 2 Dec 2021 12:54:56 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BC4E98249980 for ; Thu, 2 Dec 2021 17:54:45 +0000 (UTC) X-FDA: 78873604530.18.7B16870 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by imf08.hostedemail.com (Postfix) with ESMTP id 4656830000AE for ; Thu, 2 Dec 2021 17:54:47 +0000 (UTC) Received: by mail-lj1-f179.google.com with SMTP id e11so1147916ljo.13 for ; Thu, 02 Dec 2021 09:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Z/5CaB/JOnj2/PdHRvEBg8gddLmclzjwsO9uOQPQZ8w=; b=aepYSYgZOghDLfIMvYjbSFwP5Ikh1Fd3AfTMr697r/nMkcCt6o95aRullAhBTEy/M1 vbg7dqznfFdf/L3qP/YpxJj4H1Am27WlEswYXePYXMYonpnIb3cvfBcr/3EeCTIjYcwC yqI8p8g5hf8vqRnEsFnWE6pyV32OwxQoX/iwN6zFF9OIXt/QnT5kZr151ueZwjuiEkxc nKchis7J53AqjYnbI51dLyamTdv6OZ4Mh0cd2ZYU4UCNw5atsZole3MTz4hxTm4CP6Hd obfm56QA78ttGrq3+Lq351Z+CjoyqC8IUfONSCZWv89iENpBtvVolJjFKFKxj7tMvjIy g9AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Z/5CaB/JOnj2/PdHRvEBg8gddLmclzjwsO9uOQPQZ8w=; b=0BlYRVLJX3Mg0S1WGxrB++RXUEgv9qbB/6OTiGw7oJaDY02RqrXAmjYKsPcXgRNqwp CxdC4r9u+ga66lf3ewCMbaHdlOnwXlJaQYkL+oRgFD0qDO01lnF7HZGgijEmsYDZ4ax1 bEFmoLhSG4YLLknczF0bzvJrsMHq8KuO7P86Jl/RzYT9oz4Y96rX3aQQi0gyaDlEQyAJ Xb9QgCpme9xFCzzruKQC8sCo08eYdKlMJ9LAvouonqObZbIeJl/nGlq+DwjuQfJtwRpa LJ4orhLg7M1hTZnI9MAn62wf2rwwP/KX229J1AQOd+VZg/4FdEjE6LUQkDI3s5zsqSje tcWw== X-Gm-Message-State: AOAM531vB1QqnYcV2CeabrB/g+rHRIcXv9be1BHbVR9woFD/izR1OOt8 wDJq26mlrRtOOeNXc+zfTtZY7uY33yCws5s9JDfDckvvJb+g5Q== X-Google-Smtp-Source: ABdhPJwtm1Em6Qxewazf3czKyIw8Z9a4Mnz3R3PHy25qBUYQxrTVQxrDhLo9ANTlZBfxw0YVO/uuMZjSPZZ1M/kN+O4= X-Received: by 2002:a05:651c:545:: with SMTP id q5mr12755493ljp.202.1638467683082; Thu, 02 Dec 2021 09:54:43 -0800 (PST) MIME-Version: 1.0 References: <1638442253-1591-1-git-send-email-quic_charante@quicinc.com> In-Reply-To: <1638442253-1591-1-git-send-email-quic_charante@quicinc.com> From: Shakeel Butt Date: Thu, 2 Dec 2021 09:54:31 -0800 Message-ID: Subject: Re: [PATCH v2] mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for shmem To: 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, Charan Teja Reddy Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 4656830000AE X-Stat-Signature: t7wfdhjjqz134xqyacwqy1wmbjbyaf13 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=aepYSYgZ; spf=pass (imf08.hostedemail.com: domain of shakeelb@google.com designates 209.85.208.179 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1638467687-778091 X-Bogosity: Ham, tests=bogofilter, spamicity=0.062886, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.