linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Suren Baghdasaryan <surenb@google.com>
To: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: akpm@linux-foundation.org, hughd@google.com, willy@infradead.org,
	 markhemm@googlemail.com, rientjes@google.com,
	shakeelb@google.com,  mhocko@suse.com, vbabka@suse.cz,
	quic_pkondeti@quicinc.com,  linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V6 2/2] mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for shmem
Date: Wed, 8 Feb 2023 14:51:56 -0800	[thread overview]
Message-ID: <CAJuCfpE35_8JBq4DAqHZh0eJ3cynxkZXxqV32L_7xJn9uB7Jbw@mail.gmail.com> (raw)
In-Reply-To: <8f40873d-8a9c-bcec-6742-885478365e4c@quicinc.com>

On Wed, Feb 8, 2023 at 6:55 AM Charan Teja Kalla
<quic_charante@quicinc.com> wrote:
>
> Thanks Suren!!
>
> On 2/8/2023 4:18 AM, Suren Baghdasaryan wrote:
> >> +static int shmem_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
> >> +{
> >> +       loff_t endbyte;
> >> +       pgoff_t start_index;
> >> +       pgoff_t end_index;
> >> +       struct address_space *mapping;
> >> +       struct inode *inode = file_inode(file);
> >> +       int ret = 0;
> >> +
> >> +       if (S_ISFIFO(inode->i_mode))
> >> +               return -ESPIPE;
> >> +
> >> +       mapping = file->f_mapping;
> >> +       if (!mapping || len < 0 || !shmem_mapping(mapping))
> >> +               return -EINVAL;
> >> +
> >> +       endbyte = fadvise_calc_endbyte(offset, len);
> >> +
> >> +       start_index = offset >> PAGE_SHIFT;
> >> +       end_index   = endbyte >> PAGE_SHIFT;
> >> +       switch (advice) {
> >> +       case POSIX_FADV_DONTNEED:
> > Should (SHMEM_I(inode)->flags & VM_LOCKED) be checked here too?
> >
> Is this w.r.t context from shmem_lock() perspective which does set this
> flag?  If so, Isn't the PageUnevictable check cover this part? And to
> avoid unnecessary Unevictable check later on the locked shmem file, How
> about just checking mapping_unevictable() before performing
> shmem_fadvise_dontneed)()? Please let me know If I failed to get your point.

Yes, you got my point and checking for mapping_unevictable() should
work fine I think.

>
> >> +               ret = shmem_fadvise_dontneed(mapping, start_index, end_index);
> >> +               break;
> >> +       case POSIX_FADV_WILLNEED:
> >> +               ret = shmem_fadvise_willneed(mapping, start_index, end_index);
> >> +               break;
> >> +       case POSIX_FADV_NORMAL:
> >> +       case POSIX_FADV_RANDOM:
> >> +       case POSIX_FADV_SEQUENTIAL:
> >> +       case POSIX_FADV_NOREUSE:
>
> --Charan


      reply	other threads:[~2023-02-08 22:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 14:21 [PATCH V6 0/2] mm: shmem: support POSIX_FADV_[WILL|DONT]NEED for shmem files Charan Teja Kalla
2023-02-06 14:21 ` [PATCH V6 1/2] mm: fadvise: move 'endbyte' calculations to helper function Charan Teja Kalla
2023-02-06 14:21 ` [PATCH V6 2/2] mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for shmem Charan Teja Kalla
2023-02-06 16:18   ` Matthew Wilcox
2023-02-07  4:46     ` Charan Teja Kalla
2023-02-07 22:48   ` Suren Baghdasaryan
2023-02-08 14:54     ` Charan Teja Kalla
2023-02-08 22:51       ` Suren Baghdasaryan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJuCfpE35_8JBq4DAqHZh0eJ3cynxkZXxqV32L_7xJn9uB7Jbw@mail.gmail.com \
    --to=surenb@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=markhemm@googlemail.com \
    --cc=mhocko@suse.com \
    --cc=quic_charante@quicinc.com \
    --cc=quic_pkondeti@quicinc.com \
    --cc=rientjes@google.com \
    --cc=shakeelb@google.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox