All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tong Tiangen <tongtiangen@huawei.com>
To: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Palmer Dabbelt <palmerdabbelt@google.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Cc: <linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	"Tong Tiangen" <tongtiangen@huawei.com>
Subject: [PATCH -next v2 3/3] riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable
Date: Fri, 20 Aug 2021 12:50:42 +0000	[thread overview]
Message-ID: <20210820125042.1844629-4-tongtiangen@huawei.com> (raw)
In-Reply-To: <20210820125042.1844629-1-tongtiangen@huawei.com>

riscv architectures relying on mmap_sem for write in their
arch_setup_additional_pages. If the waiting task gets killed by the oom killer
it would block oom_reaper from asynchronous address space reclaim and reduce
the chances of timely OOM resolving.  Wait for the lock in the killable mode
and return with EINTR if the task got killed while waiting.

Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
---
 arch/riscv/kernel/vdso.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c
index e7bd92d8749b..b70956d80408 100644
--- a/arch/riscv/kernel/vdso.c
+++ b/arch/riscv/kernel/vdso.c
@@ -77,7 +77,9 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 	vdso_len = (vdso_pages + VVAR_NR_PAGES) << PAGE_SHIFT;
 
-	mmap_write_lock(mm);
+	if (mmap_write_lock_killable(mm))
+		return -EINTR;
+
 	vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0);
 	if (IS_ERR_VALUE(vdso_base)) {
 		ret = vdso_base;
-- 
2.18.0.huawei.25


WARNING: multiple messages have this Message-ID (diff)
From: Tong Tiangen <tongtiangen@huawei.com>
To: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Palmer Dabbelt <palmerdabbelt@google.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Cc: <linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	"Tong Tiangen" <tongtiangen@huawei.com>
Subject: [PATCH -next v2 3/3] riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable
Date: Fri, 20 Aug 2021 12:50:42 +0000	[thread overview]
Message-ID: <20210820125042.1844629-4-tongtiangen@huawei.com> (raw)
In-Reply-To: <20210820125042.1844629-1-tongtiangen@huawei.com>

riscv architectures relying on mmap_sem for write in their
arch_setup_additional_pages. If the waiting task gets killed by the oom killer
it would block oom_reaper from asynchronous address space reclaim and reduce
the chances of timely OOM resolving.  Wait for the lock in the killable mode
and return with EINTR if the task got killed while waiting.

Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
---
 arch/riscv/kernel/vdso.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c
index e7bd92d8749b..b70956d80408 100644
--- a/arch/riscv/kernel/vdso.c
+++ b/arch/riscv/kernel/vdso.c
@@ -77,7 +77,9 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
 
 	vdso_len = (vdso_pages + VVAR_NR_PAGES) << PAGE_SHIFT;
 
-	mmap_write_lock(mm);
+	if (mmap_write_lock_killable(mm))
+		return -EINTR;
+
 	vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0);
 	if (IS_ERR_VALUE(vdso_base)) {
 		ret = vdso_base;
-- 
2.18.0.huawei.25


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2021-08-20 12:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 12:50 [PATCH -next v2 0/3] riscv: Fix two vdso issue Tong Tiangen
2021-08-20 12:50 ` Tong Tiangen
2021-08-20 12:50 ` [PATCH -next v2 1/3] riscv/vdso: Refactor asm/vdso.h Tong Tiangen
2021-08-20 12:50   ` Tong Tiangen
2021-08-20 12:50 ` [PATCH -next v2 2/3] riscv/vdso: Move vdso data page up front Tong Tiangen
2021-08-20 12:50   ` Tong Tiangen
2021-08-20 12:50 ` Tong Tiangen [this message]
2021-08-20 12:50   ` [PATCH -next v2 3/3] riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable Tong Tiangen
2021-08-23  2:02 ` [PATCH -next v2 0/3] riscv: Fix two vdso issue Kefeng Wang
2021-08-23  2:02   ` Kefeng Wang

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=20210820125042.1844629-4-tongtiangen@huawei.com \
    --to=tongtiangen@huawei.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=palmerdabbelt@google.com \
    --cc=paul.walmsley@sifive.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 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.