From patchwork Thu Jul 5 10:45:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rabin Vincent X-Patchwork-Id: 1159491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 93CF0DFB7C for ; Thu, 5 Jul 2012 10:50:17 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmjZH-0001wx-T4; Thu, 05 Jul 2012 10:45:56 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SmjZ7-0001vi-V3 for linux-arm-kernel@lists.infradead.org; Thu, 05 Jul 2012 10:45:44 +0000 Received: by pbbrq13 with SMTP id rq13so14036417pbb.36 for ; Thu, 05 Jul 2012 03:45:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=oysiSWgrkfgeNFrOBZaww896sZMFI4dMYmW/4/jfY20=; b=xXRa8FJ21F6yCRJqszpo7fsq1mDfNzomzvlM9JGgY6phrvRP6fKFPotMKYHSFFgYUJ nSirFARUoRvBCtMYLj824vADS3V5Z+MfIZmEvv6f5UCFrDzQEvZuFw5gfThH4/O+armH 2C5Js/gksAcIzbnsQ2YjMWcgzQCWYfTJOis1Hs3Rk5S2JSgFSqvgs1j7fAxkMSFp0SCd OHCzt7KvSyCkolyqaK3m3JkLjPCXrg5sVlBdyPfGCjby/G5NA3m877lnURtbuzihJWHd 6a94+v4fvFYGviyFU3aYBd3fTIf6fX3KaDvFcA2uY7+Da9v0LHt2gKIukUbDSfAH6WS1 Q8LA== Received: by 10.68.224.225 with SMTP id rf1mr26936432pbc.55.1341485133548; Thu, 05 Jul 2012 03:45:33 -0700 (PDT) Received: from latitude ([122.181.155.58]) by mx.google.com with ESMTPS id of4sm19546812pbb.51.2012.07.05.03.45.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 03:45:32 -0700 (PDT) Date: Thu, 5 Jul 2012 16:15:20 +0530 From: Rabin Vincent To: Marek Szyprowski Subject: Re: Bad use of highmem with buffer_migrate_page? Message-ID: <20120705104520.GA6773@latitude> References: <4FAC200D.2080306@codeaurora.org> <02fc01cd2f50$5d77e4c0$1867ae40$%szyprowski@samsung.com> <4FAD89DC.2090307@codeaurora.org> <015f01cd5a95$c1525dc0$43f71940$%szyprowski@samsung.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <015f01cd5a95$c1525dc0$43f71940$%szyprowski@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rabin.vincent[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: 'Laura Abbott' , linux-arm-msm@vger.kernel.org, 'LKML' , 'Michal Nazarewicz' , linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Thu, Jul 05, 2012 at 12:05:45PM +0200, Marek Szyprowski wrote: > On Thursday, July 05, 2012 11:28 AM Rabin Vincent wrote: > > The problem is still present on latest mainline. The filesystem layer > > expects that the pages in the block device's mapping are not in highmem > > (the mapping's gfp mask is set in bdget()), but CMA replaces lowmem > > pages with highmem pages leading to the crashes. > > > > The above fix should work, but perhaps the following is preferable since > > it should allow moving highmem pages to other highmem pages? > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 4403009..4a4f921 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -5635,7 +5635,12 @@ static struct page * > > __alloc_contig_migrate_alloc(struct page *page, unsigned long private, > > int **resultp) > > { > > - return alloc_page(GFP_HIGHUSER_MOVABLE); > > + gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE; > > + > > + if (PageHighMem(page)) > > + gfp_mask |= __GFP_HIGHMEM; > > + > > + return alloc_page(gfp_mask); > > } > > > > /* [start, end) must belong to a single zone. */ > > > The patch looks fine and does it job well. Could you resend it as a complete > patch with commit message and signed-off-by/reported-by lines? I will handle > merging it to mainline then. Thanks, here it is: 8<---- From 8a94126eb3aa2824866405fb78bb0b8316f8fd00 Mon Sep 17 00:00:00 2001 From: Rabin Vincent Date: Thu, 5 Jul 2012 15:52:23 +0530 Subject: [PATCH] mm: cma: don't replace lowmem pages with highmem The filesystem layer expects pages in the block device's mapping to not be in highmem (the mapping's gfp mask is set in bdget()), but CMA can currently replace lowmem pages with highmem pages, leading to crashes in filesystem code such as the one below: Unable to handle kernel NULL pointer dereference at virtual address 00000400 pgd = c0c98000 [00000400] *pgd=00c91831, *pte=00000000, *ppte=00000000 Internal error: Oops: 817 [#1] PREEMPT SMP ARM CPU: 0 Not tainted (3.5.0-rc5+ #80) PC is at __memzero+0x24/0x80 ... Process fsstress (pid: 323, stack limit = 0xc0cbc2f0) Backtrace: [] (ext4_getblk+0x0/0x180) from [] (ext4_bread+0x1c/0x98) [] (ext4_bread+0x0/0x98) from [] (ext4_mkdir+0x160/0x3bc) r4:c15337f0 [] (ext4_mkdir+0x0/0x3bc) from [] (vfs_mkdir+0x8c/0x98) [] (vfs_mkdir+0x0/0x98) from [] (sys_mkdirat+0x74/0xac) r6:00000000 r5:c152eb40 r4:000001ff r3:c14b43f0 [] (sys_mkdirat+0x0/0xac) from [] (sys_mkdir+0x20/0x24) r6:beccdcf0 r5:00074000 r4:beccdbbc [] (sys_mkdir+0x0/0x24) from [] (ret_fast_syscall+0x0/0x30) Fix this by replacing only highmem pages with highmem. Reported-by: Laura Abbott Signed-off-by: Rabin Vincent Acked-by: Michal Nazarewicz --- mm/page_alloc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4403009..4a4f921 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5635,7 +5635,12 @@ static struct page * __alloc_contig_migrate_alloc(struct page *page, unsigned long private, int **resultp) { - return alloc_page(GFP_HIGHUSER_MOVABLE); + gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE; + + if (PageHighMem(page)) + gfp_mask |= __GFP_HIGHMEM; + + return alloc_page(gfp_mask); } /* [start, end) must belong to a single zone. */