All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH v2 2/8] mm: Rename arguments to find_subpage
Date: Thu, 19 Mar 2020 16:59:42 +0100	[thread overview]
Message-ID: <CAM9Jb+he2-U75GM1tHLcjHXrE0bVhe_yjTCDGg7OabQrUL56sQ@mail.gmail.com> (raw)
In-Reply-To: <20200318140253.6141-3-willy@infradead.org>

> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
>
> This isn't just a random struct page, it's known to be a head page,
> and calling it head makes the function better self-documenting.
> The pgoff_t is less confusing if it's named index instead of offset.
> Also add a couple of comments to explain why we're doing various things.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  include/linux/pagemap.h | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index b4ea3a5d00e5..68db0ed8535d 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -333,14 +333,19 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
>                         mapping_gfp_mask(mapping));
>  }
>
> -static inline struct page *find_subpage(struct page *page, pgoff_t offset)
> +/*
> + * Given the page we found in the page cache, return the page corresponding
> + * to this index in the file
> + */
> +static inline struct page *find_subpage(struct page *head, pgoff_t index)
>  {
> -       if (PageHuge(page))
> -               return page;
> +       /* HugeTLBfs wants the head page regardless */
> +       if (PageHuge(head))
> +               return head;
>
> -       VM_BUG_ON_PAGE(PageTail(page), page);
> +       VM_BUG_ON_PAGE(PageTail(head), head);
>
> -       return page + (offset & (compound_nr(page) - 1));
> +       return head + (index & (compound_nr(head) - 1));
>  }
>
>  struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
> --
> 2.25.1

Makes function much easier to understand. Thanks!
Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>

>
>


  parent reply	other threads:[~2020-03-19 15:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 14:02 [PATCH v2 0/8] Misc MM patches Matthew Wilcox
2020-03-18 14:02 ` [PATCH v2 1/8] mm: Use vm_fault error code directly Matthew Wilcox
2020-03-18 14:02 ` [PATCH v2 2/8] mm: Rename arguments to find_subpage Matthew Wilcox
2020-03-19 10:15   ` Christoph Hellwig
2020-03-19 14:31   ` Kirill A. Shutemov
2020-03-19 15:59   ` Pankaj Gupta [this message]
2020-03-18 14:02 ` [PATCH v2 3/8] mm: Check PageTail in hpage_nr_pages even when !THP Matthew Wilcox
2020-03-19 10:18   ` Christoph Hellwig
2020-03-19 14:33   ` Kirill A. Shutemov
2020-03-18 14:02 ` [PATCH v2 4/8] mm: Optimise find_subpage for !THP Matthew Wilcox
2020-03-19 10:18   ` Christoph Hellwig
2020-03-18 14:02 ` [PATCH v2 5/8] mm: Remove CONFIG_TRANSPARENT_HUGE_PAGECACHE Matthew Wilcox
2020-03-19 14:35   ` Kirill A. Shutemov
2020-03-18 14:02 ` [PATCH v2 6/8] mm: Use VM_BUG_ON_PAGE in clear_page_dirty_for_io Matthew Wilcox
2020-03-18 14:02 ` [PATCH v2 7/8] mm: Unexport find_get_entry Matthew Wilcox
2020-03-18 14:02 ` [PATCH v2 8/8] mm: Rewrite pagecache_get_page documentation Matthew Wilcox
2020-03-19 10:19   ` Christoph Hellwig

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=CAM9Jb+he2-U75GM1tHLcjHXrE0bVhe_yjTCDGg7OabQrUL56sQ@mail.gmail.com \
    --to=pankaj.gupta.linux@gmail.com \
    --cc=linux-mm@kvack.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.