public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: Russell King <rmk@arm.linux.org.uk>, linux-kernel@vger.kernel.org
Subject: Re: Bug: Discontigmem virt_to_page() [Alpha,ARM,Mips64?]
Date: Tue, 30 Apr 2002 02:43:54 +0200	[thread overview]
Message-ID: <20020430024354.C26174@dualathlon.random> (raw)
In-Reply-To: <20020427004641.L19278@dualathlon.random> <Pine.LNX.4.21.0204292349330.23113-100000@serv>

On Tue, Apr 30, 2002 at 12:00:50AM +0200, Roman Zippel wrote:
> Hi,
> 
> On Sat, 27 Apr 2002, Andrea Arcangeli wrote:
> 
> > correct. This should fix it:
> > 
> > --- 2.4.19pre7aa2/include/asm-alpha/mmzone.h.~1~	Fri Apr 26 10:28:28 2002
> > +++ 2.4.19pre7aa2/include/asm-alpha/mmzone.h	Sat Apr 27 00:30:02 2002
> > @@ -106,8 +106,8 @@
> >  #define kern_addr_valid(kaddr)	test_bit(LOCAL_MAP_NR(kaddr), \
> >  					 NODE_DATA(KVADDR_TO_NID(kaddr))->valid_addr_bitmap)
> >  
> > -#define virt_to_page(kaddr)	(ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr))
> > -#define VALID_PAGE(page)	(((page) - mem_map) < max_mapnr)
> > +#define virt_to_page(kaddr)	(KVADDR_TO_NID((unsigned long) kaddr) < MAX_NUMNODES ? ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr) : 0)
> > +#define VALID_PAGE(page)	((page) != NULL)
> >  
> >  #ifdef CONFIG_NUMA
> >  #ifdef CONFIG_NUMA_SCHED
> 
> I'd prefer if VALID_PAGE would go away completely, that test was almost
> always to late. What about the patch below, it even reduces the code size

it is _always_ too late indeed, I definitely agree with your proposal to
change the common code API, yours is a much saner API. But that's a
common code change call, my object was to fix the arch part without
changing the common code, and after all my patch will work exactly the
same as yours, it's just that you put the page != NULL check explicit
and I still use VALID_PAGE instead. You can skip the overflow-check when
we know the vaddr or the pte to match with a valid ram page, so it's a
bit faster than my fix with discontigmem enabled. I'm not sure if for
2.4 it worth to change that given that my two liner arch-contained patch
will also work flawlessy. I've just quite a lots of stuff pending in 2.4
that makes some huge difference to users, so I tend to prefer to left
the stuff that doesn't make difference to users for 2.5 only (it's a
cleanup plus a minor discontigmem optimization after all). So I
recommend you to push it to Linus after fixing the below bugs.

> --- include/asm-i386/page.h	24 Feb 2002 23:11:41 -0000	1.1.1.3
> +++ include/asm-i386/page.h	29 Apr 2002 21:09:09 -0000
> @@ -132,7 +132,10 @@ static __inline__ int get_order(unsigned
>  #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
>  #define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
>  #define virt_to_page(kaddr)	(mem_map + (__pa(kaddr) >> PAGE_SHIFT))
> -#define VALID_PAGE(page)	((page - mem_map) < max_mapnr)
> +#define virt_to_valid_page(kaddr) ({ \
> +	unsigned long __paddr = __pa(kaddr); \
> +	__paddr < max_mapnr ? mem_map + (__paddr >> PAGE_SHIFT) : NULL; \
> +})
>  
>  #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
>  				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
> Index: include/asm-i386/pgtable-2level.h
> ===================================================================
> RCS file: /usr/src/cvsroot/linux-2.5/include/asm-i386/pgtable-2level.h,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 pgtable-2level.h
> --- include/asm-i386/pgtable-2level.h	26 Nov 2001 19:29:55 -0000	1.1.1.1
> +++ include/asm-i386/pgtable-2level.h	29 Apr 2002 21:13:29 -0000
> @@ -57,6 +57,7 @@ static inline pmd_t * pmd_offset(pgd_t *
>  #define ptep_get_and_clear(xp)	__pte(xchg(&(xp)->pte_low, 0))
>  #define pte_same(a, b)		((a).pte_low == (b).pte_low)
>  #define pte_page(x)		(mem_map+((unsigned long)(((x).pte_low >> PAGE_SHIFT))))
> +#define pte_valid_page(x)	(pte_val(x) < max_mapnr ? pte_page(x) : NULL)
>  #define pte_none(x)		(!(x).pte_low)
>  #define __mk_pte(page_nr,pgprot) __pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
>  
> Index: include/asm-i386/pgtable-3level.h
> ===================================================================
> RCS file: /usr/src/cvsroot/linux-2.5/include/asm-i386/pgtable-3level.h,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 pgtable-3level.h
> --- include/asm-i386/pgtable-3level.h	26 Nov 2001 19:29:55 -0000	1.1.1.1
> +++ include/asm-i386/pgtable-3level.h	29 Apr 2002 21:13:08 -0000
> @@ -87,6 +87,7 @@ static inline int pte_same(pte_t a, pte_
>  }
>  
>  #define pte_page(x)	(mem_map+(((x).pte_low >> PAGE_SHIFT) | ((x).pte_high << (32 - PAGE_SHIFT))))
> +#define pte_valid_page(x) (pte_val(x) < max_mapnr ? pte_page(x) : NULL)
>  #define pte_none(x)	(!(x).pte_low && !(x).pte_high)
>  

map_mapnr is a pfn, not a physaddr, you're off of 2^PAGE_SHIFT, fix is
trivial of course.

Andrea

  reply	other threads:[~2002-04-30  0:44 UTC|newest]

Thread overview: 152+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-26 18:27 Bug: Discontigmem virt_to_page() [Alpha,ARM,Mips64?] Russell King
2002-04-26 22:46 ` Andrea Arcangeli
2002-04-29 17:50   ` Martin J. Bligh
2002-04-29 22:00   ` Roman Zippel
2002-04-30  0:43     ` Andrea Arcangeli [this message]
2002-04-27 22:10 ` Daniel Phillips
2002-04-29 13:35   ` Andrea Arcangeli
2002-04-29 23:02     ` Daniel Phillips
2002-05-01  2:23       ` Andrea Arcangeli
2002-04-30 23:12         ` Daniel Phillips
2002-05-01  1:05           ` Daniel Phillips
2002-05-02  0:47           ` Andrea Arcangeli
2002-05-01  1:26             ` Daniel Phillips
2002-05-02  1:43               ` Andrea Arcangeli
2002-05-01  2:41                 ` Daniel Phillips
2002-05-02 13:34                   ` Andrea Arcangeli
2002-05-02 15:18                     ` Martin J. Bligh
2002-05-02 15:35                       ` Andrea Arcangeli
2002-05-01 15:42                         ` Daniel Phillips
2002-05-02 16:06                           ` Andrea Arcangeli
2002-05-02 16:10                             ` Martin J. Bligh
2002-05-02 16:40                               ` Andrea Arcangeli
2002-05-02 17:16                                 ` William Lee Irwin III
2002-05-02 18:41                                   ` Andrea Arcangeli
2002-05-02 19:19                                     ` William Lee Irwin III
2002-05-02 19:27                                       ` Daniel Phillips
2002-05-02 19:38                                         ` William Lee Irwin III
2002-05-02 19:58                                           ` Daniel Phillips
2002-05-03  6:28                                           ` Andrea Arcangeli
2002-05-03  6:10                                         ` Andrea Arcangeli
2002-05-02 22:20                                       ` Martin J. Bligh
2002-05-02 21:28                                         ` William Lee Irwin III
2002-05-02 21:52                                           ` Kurt Ferreira
2002-05-02 21:55                                             ` William Lee Irwin III
2002-05-03  6:38                                         ` Andrea Arcangeli
2002-05-03  6:58                                           ` Martin J. Bligh
2002-05-03  6:04                                       ` Andrea Arcangeli
2002-05-03  6:33                                         ` Martin J. Bligh
2002-05-03  8:38                                           ` Andrea Arcangeli
2002-05-03  9:26                                             ` William Lee Irwin III
2002-05-03 15:38                                               ` Martin J. Bligh
2002-05-03 15:17                                             ` Virtual address space exhaustion (was Discontigmem virt_to_page() ) Martin J. Bligh
2002-05-03 15:58                                               ` Andrea Arcangeli
2002-05-03 16:10                                                 ` Martin J. Bligh
2002-05-03 16:25                                                   ` Andrea Arcangeli
2002-05-03 16:02                                               ` Daniel Phillips
2002-05-03 16:20                                                 ` Andrea Arcangeli
2002-05-03 16:41                                                   ` Daniel Phillips
2002-05-03 16:58                                                     ` Andrea Arcangeli
2002-05-03 18:08                                                       ` Daniel Phillips
2002-05-03  9:24                                         ` Bug: Discontigmem virt_to_page() [Alpha,ARM,Mips64?] William Lee Irwin III
2002-05-03 10:30                                           ` Andrea Arcangeli
2002-05-03 11:09                                             ` William Lee Irwin III
2002-05-03 11:27                                               ` Andrea Arcangeli
2002-05-03 15:42                                             ` Martin J. Bligh
2002-05-03 15:32                                           ` Martin J. Bligh
2002-05-02 19:22                                     ` Daniel Phillips
2002-05-03  6:06                                       ` Andrea Arcangeli
2002-05-02 18:25                                 ` Daniel Phillips
2002-05-02 18:44                                   ` Andrea Arcangeli
2002-05-02 19:31                                 ` Martin J. Bligh
2002-05-02 18:57                                   ` Andrea Arcangeli
2002-05-02 19:08                                     ` Daniel Phillips
2002-05-03  5:15                                       ` Andrea Arcangeli
2002-05-05 23:54                                         ` Daniel Phillips
2002-05-06  0:28                                           ` Andrea Arcangeli
2002-05-06  0:34                                             ` Daniel Phillips
2002-05-06  1:01                                               ` Andrea Arcangeli
2002-05-06  0:55                                           ` Russell King
2002-05-06  1:07                                             ` Daniel Phillips
2002-05-06  1:20                                               ` Andrea Arcangeli
2002-05-06  1:24                                                 ` Daniel Phillips
2002-05-06  1:42                                                   ` Andrea Arcangeli
2002-05-06  1:48                                                     ` Daniel Phillips
2002-05-06  2:06                                                       ` Andrea Arcangeli
2002-05-06 17:40                                                         ` Daniel Phillips
2002-05-06 19:09                                                           ` Martin J. Bligh
2002-05-06  1:09                                             ` Andrea Arcangeli
2002-05-06  1:13                                             ` Daniel Phillips
2002-05-06  2:03                                             ` Daniel Phillips
2002-05-06  2:31                                               ` Andrea Arcangeli
2002-05-06  8:57                                               ` Russell King
2002-05-06  8:54                                           ` Roman Zippel
2002-05-06 15:26                                             ` Daniel Phillips
2002-05-06 19:07                                               ` Roman Zippel
2002-05-08 15:57                                                 ` Daniel Phillips
2002-05-08 23:11                                                   ` Roman Zippel
2002-05-09 16:08                                                     ` Daniel Phillips
2002-05-09 22:06                                                       ` Roman Zippel
2002-05-09 22:22                                                         ` Daniel Phillips
2002-05-09 23:00                                                           ` Roman Zippel
2002-05-09 23:22                                                             ` Daniel Phillips
2002-05-10  0:13                                                               ` Roman Zippel
2002-05-02 22:39                                     ` Martin J. Bligh
2002-05-03  7:04                                       ` Andrea Arcangeli
2002-05-02 23:42                             ` Daniel Phillips
2002-05-03  7:45                               ` Andrea Arcangeli
2002-05-02 16:07                         ` Martin J. Bligh
2002-05-02 16:58                           ` Gerrit Huizenga
2002-05-02 18:10                             ` Andrea Arcangeli
2002-05-02 19:28                               ` Gerrit Huizenga
2002-05-02 22:23                                 ` Martin J. Bligh
2002-05-03  6:20                                 ` Andrea Arcangeli
2002-05-03  6:39                                   ` Martin J. Bligh
2002-05-02 16:00                     ` William Lee Irwin III
2002-05-02  2:37             ` William Lee Irwin III
2002-05-02 15:59               ` Andrea Arcangeli
2002-05-02 16:06                 ` William Lee Irwin III
2002-05-01 18:05         ` Jesse Barnes
2002-05-01 23:17           ` Andrea Arcangeli
2002-05-01 23:23             ` discontiguous memory platforms Jesse Barnes
2002-05-02  0:51               ` Ralf Baechle
2002-05-02  1:27                 ` Andrea Arcangeli
2002-05-02  1:32                   ` Ralf Baechle
2002-05-02  8:50                   ` Roman Zippel
2002-05-01 13:21                     ` Daniel Phillips
2002-05-02 14:00                       ` Roman Zippel
2002-05-01 14:08                         ` Daniel Phillips
2002-05-02 17:56                           ` Roman Zippel
2002-05-01 17:59                             ` Daniel Phillips
2002-05-02 18:26                               ` Roman Zippel
2002-05-02 18:32                                 ` Daniel Phillips
2002-05-02 19:40                                   ` Roman Zippel
2002-05-02 20:14                                     ` Daniel Phillips
2002-05-03  6:34                                       ` Andrea Arcangeli
2002-05-03  9:33                                       ` Roman Zippel
2002-05-03  6:30                                     ` Andrea Arcangeli
2002-05-02 18:35                     ` Geert Uytterhoeven
2002-05-02 18:39                       ` Daniel Phillips
2002-05-02  0:20             ` Bug: Discontigmem virt_to_page() [Alpha,ARM,Mips64?] Anton Blanchard
2002-05-01  1:35               ` Daniel Phillips
2002-05-02  1:45                 ` William Lee Irwin III
2002-05-01  2:02                   ` Daniel Phillips
2002-05-02  2:33                     ` William Lee Irwin III
2002-05-01  2:44                       ` Daniel Phillips
2002-05-02  1:46                 ` Andrea Arcangeli
2002-05-01  1:56                   ` Daniel Phillips
2002-05-02  1:01               ` Andrea Arcangeli
2002-05-02 15:28                 ` Anton Blanchard
2002-05-01 16:10                   ` Daniel Phillips
2002-05-02 15:59                   ` Dave Engebretsen
2002-05-01 17:24                     ` Daniel Phillips
2002-05-02 16:44                       ` Dave Engebretsen
2002-05-02 16:31                   ` William Lee Irwin III
2002-05-02 16:21                     ` Dave Engebretsen
2002-05-02 17:28                       ` William Lee Irwin III
2002-05-02 23:05               ` Daniel Phillips
2002-05-03  0:05                 ` William Lee Irwin III
2002-05-03  1:19                   ` Daniel Phillips
2002-05-03 19:47                     ` Dave Engebretsen
2002-05-03 22:06                       ` Daniel Phillips
2002-05-03 23:52               ` David Mosberger

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=20020430024354.C26174@dualathlon.random \
    --to=andrea@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=zippel@linux-m68k.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