From: liusongtang <liusongtang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Nixiaoming <nixiaoming@huawei.com>,
"Liuyang (Young,C)" <young.liuyang@huawei.com>,
liusongtang <liusongtang@huawei.com>,
"mgorman@suse.de" <mgorman@suse.de>
Subject:
Date: Fri, 22 Apr 2022 08:57:21 +0000 [thread overview]
Message-ID: <388eaecb1ceb46bf8eb861055e64d399@huawei.com> (raw)
From: liusongtang <liusongtang@huawei.com>
Date: Thu, 21 Apr 2022 17:44:07 +0800
Subject: [PATCH] mm: reduce Committed_AS if memory protection is changed to
PROT_NONE
If PROT_WRITE is set, the size of vm area will be added to Committed_AS.
However, if memory protection is changed to PROT_NONE,
the corresponding physical memory will not be used, but Committed_AS still
count the size of the PROT_NONE memory.
This patch reduce Committed_AS and free the corresponding memory if
memory protection is changed to PROT_NONE.
Signed-off-by: liusongtang <liusongtang@huawei.com>
---
mm/mprotect.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/mprotect.c b/mm/mprotect.c
index b69ce7a..c3121e6 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -497,6 +497,12 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
}
success:
+ if ((newflags & (VM_READ | VM_WRITE | VM_EXEC | VM_LOCKED | VM_ACCOUNT)) == VM_ACCOUNT) {
+ zap_page_range(vma, start, end - start);
+ newflags &= ~VM_ACCOUNT;
+ vm_unacct_memory((end - start) >> PAGE_SHIFT);
+ }
+
/*
* vm_flags and vm_page_prot are protected by the mmap_lock
* held in write mode.
--
2.12.3
reply other threads:[~2022-04-22 8:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=388eaecb1ceb46bf8eb861055e64d399@huawei.com \
--to=liusongtang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=nixiaoming@huawei.com \
--cc=young.liuyang@huawei.com \
/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