public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Coywolf Qi Hunt <coywolf@greatcn.org>
To: Russell King <rmk+lkml@arm.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: [BUG FIX] [ARM/ARM26] find_memend_and_nodes bug fix
Date: Wed, 30 Jun 2004 17:56:18 +0800	[thread overview]
Message-ID: <40E28E42.3030408@greatcn.org> (raw)
In-Reply-To: <20040629115830.A24951@flint.arm.linux.org.uk>

Russell King wrote:

>On Tue, Jun 29, 2004 at 06:48:14PM +0800, Coywolf Qi Hunt wrote:
>  
>
>>Russell King wrote:
>>Actually there's physical DRAM offset: PHY_OFFSET, defined on ARM only. 
>>max_low_pfn happens to be the same as `num_lowpages'.
>>These assignments seems illogical in naming. But just happen to let this 
>>patch work.  Other platforms may still break.
>>    
>>
>
>That may be a bug actually.  Looking at ll_rw_blk.c:
>
>        unsigned long bounce_pfn = dma_addr >> PAGE_SHIFT;
>        if (bounce_pfn < blk_max_low_pfn) {
>
>        blk_max_low_pfn = max_low_pfn;
>
>dma_addr are physical addresses, so bounce_pfn is referenced to a PFN0
>equal to physical address 0.  This implies that blk_max_low_pfn is
>likewise, as is max_low_pfn.
>
>  
>
>>[coywolf@everest ~/linux-2.6.7/arch]$ grep max_low_pfn arm* -rn
>>arm/mm/init.c:235:      max_low_pfn = memend_pfn - O_PFN_DOWN(PHYS_OFFSET);
>>    
>>
>
>However, here, max_low_pfn of zero corresponds with the PFN of
>PHYS_OFFSET.  We have something with two different origins being
>compared, which is nonsense.  So something is wrong somewhere,
>and my money is on max_low_pfn.
>
>  
>
The bug may get into panic when there's still enough memory for block i/o.
Here's the patch with also a BUG_ON improvement.


=======================================================================

diff -Nrup linux-2.6.7/arch/arm/mm/init.c linux-2.6.7-cy2/arch/arm/mm/init.c
--- linux-2.6.7/arch/arm/mm/init.c	2004-06-29 23:03:30.000000000 -0500
+++ linux-2.6.7-cy2/arch/arm/mm/init.c	2004-06-30 04:32:42.215999091 -0500
@@ -231,9 +231,10 @@ find_memend_and_nodes(struct meminfo *mi
 	 * This doesn't seem to be used by the Linux memory
 	 * manager any more.  If we can get rid of it, we
 	 * also get rid of some of the stuff above as well.
+	 *
+	 * blk_max_low_pfn depends on this. -- coywolf
 	 */
-	max_low_pfn = memend_pfn - O_PFN_DOWN(PHYS_OFFSET);
-	max_pfn = memend_pfn - O_PFN_DOWN(PHYS_OFFSET);
+	max_low_pfn = max_pfn = memend_pfn;
 
 	return bootmem_pages;
 }
diff -Nrup linux-2.6.7/arch/arm26/mm/init.c linux-2.6.7-cy2/arch/arm26/mm/init.c
--- linux-2.6.7/arch/arm26/mm/init.c	2004-05-09 21:33:20.000000000 -0500
+++ linux-2.6.7-cy2/arch/arm26/mm/init.c	2004-06-30 03:59:51.000000000 -0500
@@ -160,9 +160,7 @@ find_memend_and_nodes(struct meminfo *mi
 
 	np->bootmap_pages = 0;
 
-	if (mi->bank->size == 0) {
-		BUG();
-	}
+	BUG_ON(mi->bank->size == 0)
 
 	/*
 	 * Get the start and end pfns for this bank
@@ -183,9 +181,10 @@ find_memend_and_nodes(struct meminfo *mi
 	 * This doesn't seem to be used by the Linux memory
 	 * manager any more.  If we can get rid of it, we
 	 * also get rid of some of the stuff above as well.
+	 *
+	 * blk_max_low_pfn depends on this. -- coywolf
 	 */
-	max_low_pfn = memend_pfn - PFN_DOWN(PHYS_OFFSET);
-	max_pfn = memend_pfn - PFN_DOWN(PHYS_OFFSET);
+	max_low_pfn = max_pfn = memend_pfn;
 	mi->end = memend_pfn << PAGE_SHIFT;
 
 }

-- 

Coywolf Qi Hunt
Admin of http://GreatCN.org and http://LoveCN.org


  reply	other threads:[~2004-06-30  9:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-28 15:55 [BUG FIX] [PATCH] fork_init() max_low_pfn fixes potential OOM bug on big highmem machine Coywolf Qi Hunt
2004-06-28 16:53 ` Russell King
2004-06-29 10:48   ` Coywolf Qi Hunt
2004-06-29 10:58     ` Russell King
2004-06-30  9:56       ` Coywolf Qi Hunt [this message]
2004-06-29 11:11   ` Chris Wedgwood
2004-06-30 10:43 ` [BUG FIX] fork_init() " Coywolf Qi Hunt

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=40E28E42.3030408@greatcn.org \
    --to=coywolf@greatcn.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@arm.linux.org.uk \
    /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