linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	David Rientjes <rientjes@google.com>,
	Michal Hocko <mhocko@suse.cz>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Tejun Heo <tj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [Patch] x86,mm: check freeze request in page fault handler
Date: Mon, 11 Aug 2014 17:53:55 -0700	[thread overview]
Message-ID: <1407804835-24763-2-git-send-email-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <1407804835-24763-1-git-send-email-xiyou.wangcong@gmail.com>

When a process triggers a page fault and kernel keeps
trying to retry the fault, there is no chance for this process
to be frozen, so the freeze request will always be pending.

This patch lets the page fault handler check pending
freeze request and freeze current process if so.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 arch/x86/mm/fault.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index a241946..ad9728a 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -14,6 +14,7 @@
 #include <linux/hugetlb.h>		/* hstate_index_to_shift	*/
 #include <linux/prefetch.h>		/* prefetchw			*/
 #include <linux/context_tracking.h>	/* exception_enter(), ...	*/
+#include <linux/freezer.h>		/* try_to_freeze()		*/
 
 #include <asm/traps.h>			/* dotraplinkage, ...		*/
 #include <asm/pgalloc.h>		/* pgd_*(), ...			*/
@@ -885,6 +886,9 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
 		up_read(&current->mm->mmap_sem);
 		no_context(regs, error_code, address, 0, 0);
 		return;
+	} else if (signal_pending(current) && (error_code & PF_USER)) {
+		if (try_to_freeze())
+			return;
 	}
 
 	if (fault & VM_FAULT_OOM) {
-- 
1.8.3.1


  reply	other threads:[~2014-08-12  0:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12  0:53 [Patch v2] freezer: check OOM kill while being frozen Cong Wang
2014-08-12  0:53 ` Cong Wang [this message]
2014-08-12 12:09   ` [Patch] x86,mm: check freeze request in page fault handler Michal Hocko
2014-08-13  0:47     ` Cong Wang
2014-08-13  9:36       ` Michal Hocko
2014-08-14  0:26         ` Cong Wang
2014-08-15  8:36           ` Michal Hocko
2014-08-12 11:44 ` [Patch v2] freezer: check OOM kill while being frozen Michal Hocko
2014-08-13  0:53   ` Cong Wang
2014-08-13  9:26     ` Michal Hocko
2014-08-14  0:16       ` Cong 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=1407804835-24763-2-git-send-email-xiyou.wangcong@gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --cc=mingo@redhat.com \
    --cc=rientjes@google.com \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.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;
as well as URLs for NNTP newsgroup(s).