All of lore.kernel.org
 help / color / mirror / Atom feed
* + mm-remove-redundant-compound_head-calling.patch added to -mm tree
@ 2021-08-12 21:54 akpm
  2021-08-13 10:17 ` David Howells
  0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2021-08-12 21:54 UTC (permalink / raw)
  To: mm-commits, willy, william.kucharski, kirill.shutemov, hannes,
	dhowells, songmuchun


The patch titled
     Subject: mm: remove redundant compound_head() calling
has been added to the -mm tree.  Its filename is
     mm-remove-redundant-compound_head-calling.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/mm-remove-redundant-compound_head-calling.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/mm-remove-redundant-compound_head-calling.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Muchun Song <songmuchun@bytedance.com>
Subject: mm: remove redundant compound_head() calling

There is a READ_ONCE() in the macro of compound_head(), which will prevent
compiler from optimizing the code when there are more than once calling of
it in a function.  Remove the redundant calling of compound_head() from
page_to_index() and page_add_file_rmap() for better code generation.

Link: https://lkml.kernel.org/r/20210811101431.83940-1-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/pagemap.h |    7 +++----
 mm/rmap.c               |    6 ++++--
 2 files changed, 7 insertions(+), 6 deletions(-)

--- a/include/linux/pagemap.h~mm-remove-redundant-compound_head-calling
+++ a/include/linux/pagemap.h
@@ -571,18 +571,17 @@ static inline struct page *read_mapping_
  */
 static inline pgoff_t page_to_index(struct page *page)
 {
-	pgoff_t pgoff;
+	struct page *head;
 
 	if (likely(!PageTransTail(page)))
 		return page->index;
 
+	head = compound_head(page);
 	/*
 	 *  We don't initialize ->index for tail pages: calculate based on
 	 *  head page
 	 */
-	pgoff = compound_head(page)->index;
-	pgoff += page - compound_head(page);
-	return pgoff;
+	return head->index + page - head;
 }
 
 extern pgoff_t hugetlb_basepage_index(struct page *page);
--- a/mm/rmap.c~mm-remove-redundant-compound_head-calling
+++ a/mm/rmap.c
@@ -1230,11 +1230,13 @@ void page_add_file_rmap(struct page *pag
 						nr_pages);
 	} else {
 		if (PageTransCompound(page) && page_mapping(page)) {
+			struct page *head = compound_head(page);
+
 			VM_WARN_ON_ONCE(!PageLocked(page));
 
-			SetPageDoubleMap(compound_head(page));
+			SetPageDoubleMap(head);
 			if (PageMlocked(page))
-				clear_page_mlock(compound_head(page));
+				clear_page_mlock(head);
 		}
 		if (!atomic_inc_and_test(&page->_mapcount))
 			goto out;
_

Patches currently in -mm which might be from songmuchun@bytedance.com are

mm-remove-redundant-compound_head-calling.patch


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: + mm-remove-redundant-compound_head-calling.patch added to -mm tree
  2021-08-12 21:54 + mm-remove-redundant-compound_head-calling.patch added to -mm tree akpm
@ 2021-08-13 10:17 ` David Howells
  0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2021-08-13 10:17 UTC (permalink / raw)
  To: akpm
  Cc: dhowells, mm-commits, willy, william.kucharski, kirill.shutemov,
	hannes, songmuchun

akpm@linux-foundation.org wrote:

> There is a READ_ONCE() in the macro of compound_head(), which will prevent
> compiler from optimizing the code when there are more than once calling of
> it in a function.  Remove the redundant calling of compound_head() from
> page_to_index() and page_add_file_rmap() for better code generation.
> 
> Link: https://lkml.kernel.org/r/20210811101431.83940-1-songmuchun@bytedance.com
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
> Cc: William Kucharski <william.kucharski@oracle.com>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: David Howells <dhowells@redhat.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Seems reasonable, but will it conflict with Willy's folio patchset?

Reviewed-by: David Howells <dhowells@redhat.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-13 10:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 21:54 + mm-remove-redundant-compound_head-calling.patch added to -mm tree akpm
2021-08-13 10:17 ` David Howells

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.