All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] mips, mm: avoid using HPAGE constants without CONFIG_HUGETLB_PAGE
@ 2011-11-20  2:56 David Rientjes
  2011-11-20  5:27 ` Hillf Danton
  0 siblings, 1 reply; 4+ messages in thread
From: David Rientjes @ 2011-11-20  2:56 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Hillf Danton, linux-mips

HPAGE_{MASK,SHIFT,SIZE} are only defined with CONFIG_HUGETLB_PAGE, so
make sure to never use them unless that option is enabled.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 arch/mips/mm/tlb-r4k.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -124,9 +124,11 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 
 		ENTER_CRITICAL(flags);
 		if (huge) {
+#ifdef CONFIG_HUGETLB_PAGE
 			start = round_down(start, HPAGE_SIZE);
 			end = round_up(end, HPAGE_SIZE);
 			size = (end - start) >> HPAGE_SHIFT;
+#endif
 		} else {
 			start = round_down(start, PAGE_SIZE << 1);
 			end = round_up(end, PAGE_SIZE << 1);
@@ -135,15 +137,16 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 		if (size <= current_cpu_data.tlbsize/2) {
 			int oldpid = read_c0_entryhi();
 			int newpid = cpu_asid(cpu, mm);
+			unsigned long incr = PAGE_SIZE << 1;
 
-			while (start < end) {
+#ifdef CONFIG_HUGETLB_PAGE
+			if (huge)
+				incr = HPAGE_SIZE;
+#endif
+			for (; start < end; start += incr) {
 				int idx;
 
 				write_c0_entryhi(start | newpid);
-				if (huge)
-					start += HPAGE_SIZE;
-				else
-					start += (PAGE_SIZE << 1);
 				mtc0_tlbw_hazard();
 				tlb_probe();
 				tlb_probe_hazard();

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] mips, mm: avoid using HPAGE constants without CONFIG_HUGETLB_PAGE
  2011-11-20  2:56 [patch] mips, mm: avoid using HPAGE constants without CONFIG_HUGETLB_PAGE David Rientjes
@ 2011-11-20  5:27 ` Hillf Danton
  2011-11-21 19:25   ` David Daney
  0 siblings, 1 reply; 4+ messages in thread
From: Hillf Danton @ 2011-11-20  5:27 UTC (permalink / raw)
  To: David Rientjes; +Cc: Ralf Baechle, linux-mips, David Daney

with David Daney Cced

On Sun, Nov 20, 2011 at 10:56 AM, David Rientjes <rientjes@google.com> wrote:
> HPAGE_{MASK,SHIFT,SIZE} are only defined with CONFIG_HUGETLB_PAGE, so
> make sure to never use them unless that option is enabled.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  arch/mips/mm/tlb-r4k.c |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
> --- a/arch/mips/mm/tlb-r4k.c
> +++ b/arch/mips/mm/tlb-r4k.c
> @@ -124,9 +124,11 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
>
>                ENTER_CRITICAL(flags);
>                if (huge) {
> +#ifdef CONFIG_HUGETLB_PAGE
>                        start = round_down(start, HPAGE_SIZE);
>                        end = round_up(end, HPAGE_SIZE);
>                        size = (end - start) >> HPAGE_SHIFT;
> +#endif
>                } else {
>                        start = round_down(start, PAGE_SIZE << 1);
>                        end = round_up(end, PAGE_SIZE << 1);
> @@ -135,15 +137,16 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
>                if (size <= current_cpu_data.tlbsize/2) {
>                        int oldpid = read_c0_entryhi();
>                        int newpid = cpu_asid(cpu, mm);
> +                       unsigned long incr = PAGE_SIZE << 1;
>
> -                       while (start < end) {
> +#ifdef CONFIG_HUGETLB_PAGE
> +                       if (huge)
> +                               incr = HPAGE_SIZE;
> +#endif
> +                       for (; start < end; start += incr) {

Here huge is included in #ifdef, but not the above huge, so readers a bit
confused. The following diff is what I mean.

Best regards
Hillf
---

--- a/arch/mips/include/asm/page.h	Sun Nov 20 13:08:44 2011
+++ b/arch/mips/include/asm/page.h	Sun Nov 20 13:17:43 2011
@@ -38,6 +38,11 @@
 #define HPAGE_SIZE	(_AC(1,UL) << HPAGE_SHIFT)
 #define HPAGE_MASK	(~(HPAGE_SIZE - 1))
 #define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
+#else
+#define HPAGE_SHIFT	({ BUG(); 0; })
+#define HPAGE_SIZE	({ BUG(); 0; })
+#define HPAGE_MASK	({ BUG(); 0; })
+#define HUGETLB_PAGE_ORDER	({ BUG(); 0; })
 #endif /* CONFIG_HUGETLB_PAGE */

 #ifndef __ASSEMBLY__

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] mips, mm: avoid using HPAGE constants without CONFIG_HUGETLB_PAGE
  2011-11-20  5:27 ` Hillf Danton
@ 2011-11-21 19:25   ` David Daney
  2011-11-21 22:31     ` David Rientjes
  0 siblings, 1 reply; 4+ messages in thread
From: David Daney @ 2011-11-21 19:25 UTC (permalink / raw)
  To: Hillf Danton; +Cc: David Rientjes, Ralf Baechle, linux-mips, Andrew Morton

On 11/19/2011 09:27 PM, Hillf Danton wrote:
[...]
>
> --- a/arch/mips/include/asm/page.h	Sun Nov 20 13:08:44 2011
> +++ b/arch/mips/include/asm/page.h	Sun Nov 20 13:17:43 2011
> @@ -38,6 +38,11 @@
>   #define HPAGE_SIZE	(_AC(1,UL)<<  HPAGE_SHIFT)
>   #define HPAGE_MASK	(~(HPAGE_SIZE - 1))
>   #define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
> +#else
> +#define HPAGE_SHIFT	({ BUG(); 0; })
> +#define HPAGE_SIZE	({ BUG(); 0; })
> +#define HPAGE_MASK	({ BUG(); 0; })

These three are taken care of in linux/hugetlb.h by the patches that 
Andrew Morton has in his tree, the full discussion starts at:

http://www.linux-mips.org/archives/linux-mips/2011-11/msg00412.html

> +#define HUGETLB_PAGE_ORDER	({ BUG(); 0; })

This value doesn't appear to be necessary at this point.

David Daney

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] mips, mm: avoid using HPAGE constants without CONFIG_HUGETLB_PAGE
  2011-11-21 19:25   ` David Daney
@ 2011-11-21 22:31     ` David Rientjes
  0 siblings, 0 replies; 4+ messages in thread
From: David Rientjes @ 2011-11-21 22:31 UTC (permalink / raw)
  To: David Daney; +Cc: Hillf Danton, Ralf Baechle, linux-mips, Andrew Morton

On Mon, 21 Nov 2011, David Daney wrote:

> > --- a/arch/mips/include/asm/page.h	Sun Nov 20 13:08:44 2011
> > +++ b/arch/mips/include/asm/page.h	Sun Nov 20 13:17:43 2011
> > @@ -38,6 +38,11 @@
> >   #define HPAGE_SIZE	(_AC(1,UL)<<  HPAGE_SHIFT)
> >   #define HPAGE_MASK	(~(HPAGE_SIZE - 1))
> >   #define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
> > +#else
> > +#define HPAGE_SHIFT	({ BUG(); 0; })
> > +#define HPAGE_SIZE	({ BUG(); 0; })
> > +#define HPAGE_MASK	({ BUG(); 0; })
> 
> These three are taken care of in linux/hugetlb.h by the patches that Andrew
> Morton has in his tree, the full discussion starts at:
> 
> http://www.linux-mips.org/archives/linux-mips/2011-11/msg00412.html
> 

Those patches were removed since Linus picked up my patch instead, so I 
think you'll want the patch I'm proposing here.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-21 22:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-20  2:56 [patch] mips, mm: avoid using HPAGE constants without CONFIG_HUGETLB_PAGE David Rientjes
2011-11-20  5:27 ` Hillf Danton
2011-11-21 19:25   ` David Daney
2011-11-21 22:31     ` David Rientjes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.