From patchwork Tue Mar 20 14:12:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kautuk Consul X-Patchwork-Id: 147870 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id C2274B708B for ; Wed, 21 Mar 2012 10:18:37 +1100 (EST) Received: from mail-gx0-f179.google.com (mail-gx0-f179.google.com [209.85.161.179]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 9A14EB6EE6 for ; Wed, 21 Mar 2012 01:12:24 +1100 (EST) Received: by ggni2 with SMTP id i2so78109ggn.38 for ; Tue, 20 Mar 2012 07:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=ufwHQErGRPfiGDwRzOeVNFnzt+636o84TQxm9bVGEAc=; b=FnqZHM48KlhkJrgM9NZxKKe1pud4HyLs9hLrBhfuOrEjH07zbdGY3kGvPcDuX7m3KI SP2NoRFlo8UneAtpr3DX+5GxNWOOzgTnmXXo6jSUEKKHV4YsUpGLGp7vBH/+aA+zdsIs ClPwdWwMqx0b1QaFg8enbUUBGwZIgW9xrUaHC/ic8yqpUVAwCDykDeNgbAAggwz3QMVw +mckn4pb6UPrWdJ2Rq9cqnZy4fHk1O6rPPVIZOnOJ/2Pjo6hw6shekfYR1c8JsRN/Ojs AwE11dVhRcnJVMvhWPVQXw6RFc0AbAYfZMFK2rAg8DZg3xFTSae2EcNt5u6g8c7oUKRN /9JA== Received: by 10.68.221.40 with SMTP id qb8mr1391564pbc.154.1332252740291; Tue, 20 Mar 2012 07:12:20 -0700 (PDT) Received: from localhost.localdomain ([122.176.229.161]) by mx.google.com with ESMTPS id o2sm1014590pbq.61.2012.03.20.07.12.15 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Mar 2012 07:12:19 -0700 (PDT) From: Kautuk Consul To: Benjamin Herrenschmidt , Paul Mackerras , Jimi Xenidis , Ingo Molnar , Peter Zijlstra , Christian Dietrich Subject: [PATCH 04/20 v2] powerpc/mm/fault.c: Port OOM changes to do_page_fault Date: Tue, 20 Mar 2012 10:12:02 -0400 Message-Id: <1332252722-3794-1-git-send-email-consul.kautuk@gmail.com> X-Mailer: git-send-email 1.7.5.4 X-Mailman-Approved-At: Wed, 21 Mar 2012 10:12:20 +1100 Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Mohd. Faris" , Kautuk Consul X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Commit d065bd810b6deb67d4897a14bfe21f8eb526ba99 (mm: retry page fault when blocking on disk transfer) and commit 37b23e0525d393d48a7d59f870b3bc061a30ccdb (x86,mm: make pagefault killable) The above commits introduced changes into the x86 pagefault handler for making the page fault handler retryable as well as killable. These changes reduce the mmap_sem hold time, which is crucial during OOM killer invocation. Port these changes to powerpc. Signed-off-by: Mohd. Faris Signed-off-by: Kautuk Consul --- arch/powerpc/mm/fault.c | 51 +++++++++++++++++++++++++++++++++------------- 1 files changed, 36 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 2f0d1b0..a3b1176 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -129,6 +129,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address, int is_write = 0, ret; int trap = TRAP(regs); int is_exec = trap == 0x400; + unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; #if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE)) /* @@ -212,6 +213,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address, if (!user_mode(regs) && !search_exception_tables(regs->nip)) goto bad_area_nosemaphore; +retry: down_read(&mm->mmap_sem); } @@ -313,6 +315,7 @@ good_area: } else if (is_write) { if (!(vma->vm_flags & VM_WRITE)) goto bad_area; + flags |= FAULT_FLAG_WRITE; /* a read */ } else { /* protection fault */ @@ -327,7 +330,11 @@ good_area: * make sure we exit gracefully rather than endlessly redo * the fault. */ - ret = handle_mm_fault(mm, vma, address, is_write ? FAULT_FLAG_WRITE : 0); + ret = handle_mm_fault(mm, vma, address, flags); + + if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) + return; + if (unlikely(ret & VM_FAULT_ERROR)) { if (ret & VM_FAULT_OOM) goto out_of_memory; @@ -335,22 +342,36 @@ good_area: goto do_sigbus; BUG(); } - if (ret & VM_FAULT_MAJOR) { - current->maj_flt++; - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, - regs, address); -#ifdef CONFIG_PPC_SMLPAR - if (firmware_has_feature(FW_FEATURE_CMO)) { - preempt_disable(); - get_lppaca()->page_ins += (1 << PAGE_FACTOR); - preempt_enable(); + if (flags & FAULT_FLAG_ALLOW_RETRY) { + if (ret & VM_FAULT_MAJOR) { + current->maj_flt++; + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, + regs, address); +#ifdef CONFIG_PPC_SMLPAR + if (firmware_has_feature(FW_FEATURE_CMO)) { + preempt_disable(); + get_lppaca()->page_ins += (1 << PAGE_FACTOR); + preempt_enable(); + } +#endif + } else { + current->min_flt++; + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, + regs, address); + } + if (fault & VM_FAULT_RETRY) { + flags &= ~FAULT_FLAG_ALLOW_RETRY; + + /* + * No need to up_read(&mm->mmap_sem) as we would + * have already released it in __lock_page_or_retry + * in mm/filemap.c. + */ + + goto retry; } -#endif - } else { - current->min_flt++; - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, - regs, address); } + up_read(&mm->mmap_sem); return 0;