linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jglisse@redhat.com
To: linux-kernel@vger.kernel.org
Cc: "Jérôme Glisse" <jglisse@redhat.com>,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Tejun Heo" <tj@kernel.org>, "Jan Kara" <jack@suse.cz>,
	"Josef Bacik" <josef@toxicpanda.com>,
	"Andrew Morton" <akpm@linux-foundation.org>
Subject: [PATCH 03/14] fs: directly use a_ops->freepage() instead of a local copy of it.
Date: Tue,  6 Oct 2020 21:05:52 -0400	[thread overview]
Message-ID: <20201007010603.3452458-4-jglisse@redhat.com> (raw)
In-Reply-To: <20201007010603.3452458-1-jglisse@redhat.com>

From: Jérôme Glisse <jglisse@redhat.com>

Coccinelle is confuse with function pointer, convert to directly
use a_ops->freepage() to be nice to coccinelle.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 mm/filemap.c | 12 ++++--------
 mm/vmscan.c  |  7 ++-----
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 2cdbbffc55522..ba892599a2717 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -242,11 +242,8 @@ void __delete_from_page_cache(struct page *page, void *shadow)
 static void page_cache_free_page(struct address_space *mapping,
 				struct page *page)
 {
-	void (*freepage)(struct page *);
-
-	freepage = mapping->a_ops->freepage;
-	if (freepage)
-		freepage(page);
+	if (mapping->a_ops->freepage)
+		mapping->a_ops->freepage(page);
 
 	if (PageTransHuge(page) && !PageHuge(page)) {
 		page_ref_sub(page, HPAGE_PMD_NR);
@@ -790,7 +787,6 @@ EXPORT_SYMBOL(file_write_and_wait_range);
 int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 {
 	struct address_space *mapping = old->mapping;
-	void (*freepage)(struct page *) = mapping->a_ops->freepage;
 	pgoff_t offset = old->index;
 	XA_STATE(xas, &mapping->i_pages, offset);
 	unsigned long flags;
@@ -819,8 +815,8 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 	if (PageSwapBacked(new))
 		__inc_lruvec_page_state(new, NR_SHMEM);
 	xas_unlock_irqrestore(&xas, flags);
-	if (freepage)
-		freepage(old);
+	if (mapping->a_ops->freepage)
+		mapping->a_ops->freepage(old);
 	put_page(old);
 
 	return 0;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 466fc3144fffc..6db869339073d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -903,9 +903,6 @@ static int __remove_mapping(struct address_space *mapping, struct page *page,
 		xa_unlock_irqrestore(&mapping->i_pages, flags);
 		put_swap_page(page, swap);
 	} else {
-		void (*freepage)(struct page *);
-
-		freepage = mapping->a_ops->freepage;
 		/*
 		 * Remember a shadow entry for reclaimed file cache in
 		 * order to detect refaults, thus thrashing, later on.
@@ -928,8 +925,8 @@ static int __remove_mapping(struct address_space *mapping, struct page *page,
 		__delete_from_page_cache(page, shadow);
 		xa_unlock_irqrestore(&mapping->i_pages, flags);
 
-		if (freepage != NULL)
-			freepage(page);
+		if (mapping->a_ops->freepage != NULL)
+			mapping->a_ops->freepage(page);
 	}
 
 	return 1;
-- 
2.26.2


  parent reply	other threads:[~2020-10-07  1:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  1:05 [PATCH 00/14] Small step toward KSM for file back page jglisse
2020-10-07  1:05 ` [PATCH 01/14] mm/pxa: page exclusive access add header file for all helpers jglisse
2020-10-07  1:05 ` [PATCH 02/14] fs: define filler_t as a function pointer type jglisse
2020-10-07  1:05 ` jglisse [this message]
2020-10-07  1:05 ` [PATCH 04/14] mm: add struct address_space to readpage() callback jglisse
2020-10-07  1:05 ` [PATCH 05/14] mm: add struct address_space to writepage() callback jglisse
2020-10-07  1:05 ` [PATCH 06/14] mm: add struct address_space to set_page_dirty() callback jglisse
2020-10-07  1:05 ` [PATCH 07/14] mm: add struct address_space to invalidatepage() callback jglisse
2020-10-07  1:05 ` [PATCH 08/14] mm: add struct address_space to releasepage() callback jglisse
2020-10-07  1:05 ` [PATCH 09/14] mm: add struct address_space to freepage() callback jglisse
2020-10-07  1:05 ` [PATCH 10/14] mm: add struct address_space to putback_page() callback jglisse
2020-10-07  1:06 ` [PATCH 11/14] mm: add struct address_space to launder_page() callback jglisse
2020-10-07  1:06 ` [PATCH 12/14] mm: add struct address_space to is_partially_uptodate() callback jglisse
2020-10-07  1:06 ` [PATCH 13/14] mm: add struct address_space to isolate_page() callback jglisse
2020-10-07  1:06 ` [PATCH 14/14] mm: add struct address_space to is_dirty_writeback() callback jglisse
2020-10-07  3:20 ` [PATCH 00/14] Small step toward KSM for file back page Matthew Wilcox
2020-10-07 14:48   ` Jerome Glisse
2020-10-07 17:05     ` Matthew Wilcox
2020-10-07 17:54       ` Jerome Glisse
2020-10-07 18:33         ` Matthew Wilcox
2020-10-07 21:45           ` Jerome Glisse
2020-10-07 22:09         ` Matthew Wilcox
2020-10-08 15:30           ` Jerome Glisse
2020-10-08 15:43             ` Matthew Wilcox
2020-10-08 18:48               ` Jerome Glisse

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=20201007010603.3452458-4-jglisse@redhat.com \
    --to=jglisse@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).