From: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>
To: Russell King <linux@armlinux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>,
Matthew Wilcox <willy@infradead.org>, <linux-mm@kvack.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
Zhaoyang Huang <huangzhaoyang@gmail.com>, <ke.wang@unisoc.com>
Subject: [PATCH] arch: arm: remove redundant clear_page when CONFIG_INIT_ON_ALLOC_DEFAULT_ON is on
Date: Tue, 12 Sep 2023 18:33:34 +0800 [thread overview]
Message-ID: <20230912103334.2074140-1-zhaoyang.huang@unisoc.com> (raw)
From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
Double times of clear_page observed in an arm SOC(A55) when
CONFIG_INIT_ON_ALLOC_DEFAULT_ON is on, which introduced by
vma_alloc_zeroed_movable_folio within do_anonymous_pages.
Since there is no D-cache operation within v6's clear_user_highpage,
I would like to suggest to remove the redundant clear_page.
struct folio *vma_alloc_zeroed_movable_folio(struct vm_area_struct *vma,
unsigned long vaddr)
{
struct folio *folio;
//first clear_page invoked by vma_alloc_folio==>alloc_page==>post_alloc_hook
folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr, false);
if (folio)
//second clear_page which is meaningless since it do nothing to D-cache in armv6
clear_user_highpage(&folio->page, vaddr);
return folio;
}
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
arch/arm/mm/copypage-v6.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
index a1a71f36d850..6f8bee1b3203 100644
--- a/arch/arm/mm/copypage-v6.c
+++ b/arch/arm/mm/copypage-v6.c
@@ -9,6 +9,7 @@
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
+#include <linux/gfp.h>
#include <asm/shmparam.h>
#include <asm/tlbflush.h>
@@ -45,6 +46,13 @@ static void v6_copy_user_highpage_nonaliasing(struct page *to,
*/
static void v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long vaddr)
{
+ /*
+ * This criteria only help bailing out when CONFIG_INIT_ON_ALLOC_DEFAULT_ON
+ * is on. The page has been memset to zero when it allocated and the
+ * bellowing clear_page will do it again.
+ */
+ if (want_init_on_alloc(GFP_HIGHUSER_MOVABLE))
+ return;
void *kaddr = kmap_atomic(page);
clear_page(kaddr);
kunmap_atomic(kaddr);
--
2.25.1
next reply other threads:[~2023-09-12 10:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 10:33 zhaoyang.huang [this message]
2023-09-12 12:17 ` Matthew Wilcox
2023-09-13 1:13 ` Zhaoyang Huang
2023-09-13 8:16 ` Russell King (Oracle)
2023-09-13 8:53 ` Zhaoyang Huang
2023-09-15 5:47 ` Zhaoyang Huang
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=20230912103334.2074140-1-zhaoyang.huang@unisoc.com \
--to=zhaoyang.huang@unisoc.com \
--cc=akpm@linux-foundation.org \
--cc=huangzhaoyang@gmail.com \
--cc=ke.wang@unisoc.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=rppt@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox