From: Aaron Lu <aaron.lu@intel•com>
To: linux-mm@kvack•org, linux-kernel@vger•kernel.org, netdev@vger•kernel.org
Cc: "Andrew Morton" <akpm@linux-foundation•org>,
"Paweł Staszewski" <pstaszewski@itcare•pl>,
"Jesper Dangaard Brouer" <brouer@redhat•com>,
"Eric Dumazet" <eric.dumazet@gmail•com>,
"Tariq Toukan" <tariqt@mellanox•com>,
"Ilias Apalodimas" <ilias.apalodimas@linaro•org>,
"Yoel Caspersen" <yoel@kviknet•dk>,
"Mel Gorman" <mgorman@techsingularity•net>,
"Saeed Mahameed" <saeedm@mellanox•com>,
"Michal Hocko" <mhocko@suse•com>,
"Vlastimil Babka" <vbabka@suse•cz>,
"Dave Hansen" <dave.hansen@linux•intel.com>,
"Alexander Duyck" <alexander.h.duyck@linux•intel.com>,
"Ian Kumlien" <ian.kumlien@gmail•com>
Subject: [PATCH v3 RESEND 2/2] mm/page_alloc: use a single function to free page
Date: Mon, 19 Nov 2018 21:48:34 +0800 [thread overview]
Message-ID: <20181119134834.17765-3-aaron.lu@intel.com> (raw)
In-Reply-To: <20181119134834.17765-1-aaron.lu@intel.com>
There are multiple places of freeing a page, they all do the same
things so a common function can be used to reduce code duplicate.
It also avoids bug fixed in one function but left in another.
Acked-by: Vlastimil Babka <vbabka@suse•cz>
Signed-off-by: Aaron Lu <aaron.lu@intel•com>
---
mm/page_alloc.c | 37 ++++++++++++++-----------------------
1 file changed, 14 insertions(+), 23 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8f8c6b33b637..93cc8e686eca 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4547,16 +4547,19 @@ unsigned long get_zeroed_page(gfp_t gfp_mask)
}
EXPORT_SYMBOL(get_zeroed_page);
-void __free_pages(struct page *page, unsigned int order)
+static inline void free_the_page(struct page *page, unsigned int order)
{
- if (put_page_testzero(page)) {
- if (order == 0)
- free_unref_page(page);
- else
- __free_pages_ok(page, order);
- }
+ if (order == 0)
+ free_unref_page(page);
+ else
+ __free_pages_ok(page, order);
}
+void __free_pages(struct page *page, unsigned int order)
+{
+ if (put_page_testzero(page))
+ free_the_page(page, order);
+}
EXPORT_SYMBOL(__free_pages);
void free_pages(unsigned long addr, unsigned int order)
@@ -4605,14 +4608,8 @@ void __page_frag_cache_drain(struct page *page, unsigned int count)
{
VM_BUG_ON_PAGE(page_ref_count(page) == 0, page);
- if (page_ref_sub_and_test(page, count)) {
- unsigned int order = compound_order(page);
-
- if (order == 0)
- free_unref_page(page);
- else
- __free_pages_ok(page, order);
- }
+ if (page_ref_sub_and_test(page, count))
+ free_the_page(page, compound_order(page));
}
EXPORT_SYMBOL(__page_frag_cache_drain);
@@ -4677,14 +4674,8 @@ void page_frag_free(void *addr)
{
struct page *page = virt_to_head_page(addr);
- if (unlikely(put_page_testzero(page))) {
- unsigned int order = compound_order(page);
-
- if (order == 0)
- free_unref_page(page);
- else
- __free_pages_ok(page, order);
- }
+ if (unlikely(put_page_testzero(page)))
+ free_the_page(page, compound_order(page));
}
EXPORT_SYMBOL(page_frag_free);
--
2.17.2
prev parent reply other threads:[~2018-11-20 0:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 13:48 [PATCH RESEND 0/2] free order-0 pages through PCP in page_frag_free() and cleanup Aaron Lu
2018-11-19 13:48 ` [PATCH v2 RESEND 1/2] mm/page_alloc: free order-0 pages through PCP in page_frag_free() Aaron Lu
2018-11-19 15:00 ` Tariq Toukan
2018-11-20 1:43 ` Aaron Lu
2018-11-20 1:45 ` [PATCH v2 RESEND update " Aaron Lu
2018-11-20 9:42 ` Pankaj Gupta
2018-11-22 3:15 ` Andrew Morton
2018-11-19 13:48 ` Aaron Lu [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=20181119134834.17765-3-aaron.lu@intel.com \
--to=aaron.lu@intel$(echo .)com \
--cc=akpm@linux-foundation$(echo .)org \
--cc=alexander.h.duyck@linux$(echo .)intel.com \
--cc=brouer@redhat$(echo .)com \
--cc=dave.hansen@linux$(echo .)intel.com \
--cc=eric.dumazet@gmail$(echo .)com \
--cc=ian.kumlien@gmail$(echo .)com \
--cc=ilias.apalodimas@linaro$(echo .)org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-mm@kvack$(echo .)org \
--cc=mgorman@techsingularity$(echo .)net \
--cc=mhocko@suse$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pstaszewski@itcare$(echo .)pl \
--cc=saeedm@mellanox$(echo .)com \
--cc=tariqt@mellanox$(echo .)com \
--cc=vbabka@suse$(echo .)cz \
--cc=yoel@kviknet$(echo .)dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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