linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NOMMU: support SMP dynamic percpu_alloc
@ 2011-03-22 20:41 Mike Frysinger
  2011-03-23 12:37 ` Paul Mundt
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Mike Frysinger @ 2011-03-22 20:41 UTC (permalink / raw)
  To: uclinux-dev, David Howells, Greg Ungerer, Paul Mundt
  Cc: uclinux-dist-devel, linux-kernel

From: Graf Yang <graf.yang@analog.com>

The percpu code requires more functions to be implemented in the mm core
which nommu currently does not provide.  So add inline implementations
since these are largely meaningless on nommu systems.

Signed-off-by: Graf Yang <graf.yang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 include/linux/vmalloc.h |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 81f8622..01bbeb4 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -98,10 +98,27 @@ extern struct vm_struct *remove_vm_area(const void *addr);
 
 extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
 			struct page ***pages);
+#ifdef CONFIG_MMU
 extern int map_kernel_range_noflush(unsigned long start, unsigned long size,
 				    pgprot_t prot, struct page **pages);
 extern void unmap_kernel_range_noflush(unsigned long addr, unsigned long size);
 extern void unmap_kernel_range(unsigned long addr, unsigned long size);
+#else
+static inline int
+map_kernel_range_noflush(unsigned long start, unsigned long size,
+			pgprot_t prot, struct page **pages)
+{
+	return size >> PAGE_SHIFT;
+}
+static inline void
+unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
+{
+}
+static inline void
+unmap_kernel_range(unsigned long addr, unsigned long size)
+{
+}
+#endif
 
 /* Allocate/destroy a 'vmalloc' VM area. */
 extern struct vm_struct *alloc_vm_area(size_t size);
@@ -119,11 +136,26 @@ extern struct vm_struct *vmlist;
 extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
 
 #ifdef CONFIG_SMP
+# ifdef CONFIG_MMU
 struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
 				     const size_t *sizes, int nr_vms,
 				     size_t align);
 
 void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms);
+# else
+static inline struct vm_struct **
+pcpu_get_vm_areas(const unsigned long *offsets,
+		const size_t *sizes, int nr_vms,
+		size_t align)
+{
+	return NULL;
+}
+
+static inline void
+pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
+{
+}
+# endif
 #endif
 
 #endif /* _LINUX_VMALLOC_H */
-- 
1.7.4.1


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

* Re: [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-22 20:41 [PATCH] NOMMU: support SMP dynamic percpu_alloc Mike Frysinger
@ 2011-03-23 12:37 ` Paul Mundt
  2011-03-23 23:09   ` [uclinux-dist-devel] " Mike Frysinger
  2011-03-24  0:06   ` David Howells
  2011-03-23 13:30 ` Greg Ungerer
  2011-03-24  0:20 ` David Howells
  2 siblings, 2 replies; 10+ messages in thread
From: Paul Mundt @ 2011-03-23 12:37 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: uclinux-dev, David Howells, Greg Ungerer, uclinux-dist-devel,
	linux-kernel

On Tue, Mar 22, 2011 at 04:41:46PM -0400, Mike Frysinger wrote:
> From: Graf Yang <graf.yang@analog.com>
> 
> The percpu code requires more functions to be implemented in the mm core
> which nommu currently does not provide.  So add inline implementations
> since these are largely meaningless on nommu systems.
> 
> Signed-off-by: Graf Yang <graf.yang@analog.com>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Looks ok to me. I've got a couple other fixes I'm working on at the
moment, so I'll roll this in to my nommu tree and send it along.

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

* Re: [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-22 20:41 [PATCH] NOMMU: support SMP dynamic percpu_alloc Mike Frysinger
  2011-03-23 12:37 ` Paul Mundt
@ 2011-03-23 13:30 ` Greg Ungerer
  2011-03-24  0:20 ` David Howells
  2 siblings, 0 replies; 10+ messages in thread
From: Greg Ungerer @ 2011-03-23 13:30 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: uclinux-dev, David Howells, Paul Mundt, uclinux-dist-devel, linux-kernel

On 23/03/11 06:41, Mike Frysinger wrote:
> From: Graf Yang<graf.yang@analog.com>
>
> The percpu code requires more functions to be implemented in the mm core
> which nommu currently does not provide.  So add inline implementations
> since these are largely meaningless on nommu systems.
>
> Signed-off-by: Graf Yang<graf.yang@analog.com>
> Signed-off-by: Mike Frysinger<vapier@gentoo.org>

Acked-by: Greg Ungerer <gerg@uclinux.org>


> ---
>   include/linux/vmalloc.h |   32 ++++++++++++++++++++++++++++++++
>   1 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 81f8622..01bbeb4 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -98,10 +98,27 @@ extern struct vm_struct *remove_vm_area(const void *addr);
>
>   extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
>   			struct page ***pages);
> +#ifdef CONFIG_MMU
>   extern int map_kernel_range_noflush(unsigned long start, unsigned long size,
>   				    pgprot_t prot, struct page **pages);
>   extern void unmap_kernel_range_noflush(unsigned long addr, unsigned long size);
>   extern void unmap_kernel_range(unsigned long addr, unsigned long size);
> +#else
> +static inline int
> +map_kernel_range_noflush(unsigned long start, unsigned long size,
> +			pgprot_t prot, struct page **pages)
> +{
> +	return size>>  PAGE_SHIFT;
> +}
> +static inline void
> +unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
> +{
> +}
> +static inline void
> +unmap_kernel_range(unsigned long addr, unsigned long size)
> +{
> +}
> +#endif
>
>   /* Allocate/destroy a 'vmalloc' VM area. */
>   extern struct vm_struct *alloc_vm_area(size_t size);
> @@ -119,11 +136,26 @@ extern struct vm_struct *vmlist;
>   extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
>
>   #ifdef CONFIG_SMP
> +# ifdef CONFIG_MMU
>   struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
>   				     const size_t *sizes, int nr_vms,
>   				     size_t align);
>
>   void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms);
> +# else
> +static inline struct vm_struct **
> +pcpu_get_vm_areas(const unsigned long *offsets,
> +		const size_t *sizes, int nr_vms,
> +		size_t align)
> +{
> +	return NULL;
> +}
> +
> +static inline void
> +pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
> +{
> +}
> +# endif
>   #endif
>
>   #endif /* _LINUX_VMALLOC_H */


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

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

* Re: [uclinux-dist-devel] [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-23 12:37 ` Paul Mundt
@ 2011-03-23 23:09   ` Mike Frysinger
  2011-03-24  0:06   ` David Howells
  1 sibling, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2011-03-23 23:09 UTC (permalink / raw)
  To: Paul Mundt
  Cc: David Howells, uclinux-dist-devel, uclinux-dev, linux-kernel,
	Greg Ungerer

On Wed, Mar 23, 2011 at 08:37, Paul Mundt wrote:
> Looks ok to me. I've got a couple other fixes I'm working on at the
> moment, so I'll roll this in to my nommu tree and send it along.

are you picking up nommu fixes in general now ?  there's a long
standing issue of the firmware subdir not working on nommu due to its
usage of vmap() and i wrote a patch for it, but David seems to be afk
for a while ?
-mike

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

* Re: [uclinux-dist-devel] [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-23 12:37 ` Paul Mundt
  2011-03-23 23:09   ` [uclinux-dist-devel] " Mike Frysinger
@ 2011-03-24  0:06   ` David Howells
  2011-03-24  0:13     ` Mike Frysinger
  2011-03-24  0:20     ` David Howells
  1 sibling, 2 replies; 10+ messages in thread
From: David Howells @ 2011-03-24  0:06 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: dhowells, Paul Mundt, uclinux-dist-devel, uclinux-dev,
	linux-kernel, Greg Ungerer

Mike Frysinger <vapier@gentoo.org> wrote:

> but David seems to be afk for a while ?

Yeah...  I moved house and then we had to redecorate and stuff, and whilst all
that was going on, my FRV board has been locked away in storage.

David

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

* Re: [uclinux-dist-devel] [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-24  0:06   ` David Howells
@ 2011-03-24  0:13     ` Mike Frysinger
  2011-03-24  0:20     ` David Howells
  1 sibling, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2011-03-24  0:13 UTC (permalink / raw)
  To: David Howells
  Cc: Paul Mundt, uclinux-dist-devel, uclinux-dev, linux-kernel, Greg Ungerer

On Wed, Mar 23, 2011 at 8:06 PM, David Howells wrote:
> Mike Frysinger <vapier@gentoo.org> wrote:
>> but David seems to be afk for a while ?
>
> Yeah...  I moved house and then we had to redecorate and stuff, and whilst all

ah, np

> that was going on, my FRV board has been locked away in storage.

i can send you a free Blackfin board :)
-mike

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

* Re: [uclinux-dist-devel] [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-24  0:06   ` David Howells
  2011-03-24  0:13     ` Mike Frysinger
@ 2011-03-24  0:20     ` David Howells
  1 sibling, 0 replies; 10+ messages in thread
From: David Howells @ 2011-03-24  0:20 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: dhowells, Paul Mundt, uclinux-dist-devel, uclinux-dev,
	linux-kernel, Greg Ungerer

Mike Frysinger <vapier@gentoo.org> wrote:

> > that was going on, my FRV board has been locked away in storage.
> 
> i can send you a free Blackfin board :)

I never say no to stuff - which is part of the reason my office is a mess -
but I have my FRV board connected back up now.

David

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

* Re: [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-22 20:41 [PATCH] NOMMU: support SMP dynamic percpu_alloc Mike Frysinger
  2011-03-23 12:37 ` Paul Mundt
  2011-03-23 13:30 ` Greg Ungerer
@ 2011-03-24  0:20 ` David Howells
  2011-03-24  0:31   ` Mike Frysinger
  2011-03-24  9:40   ` David Howells
  2 siblings, 2 replies; 10+ messages in thread
From: David Howells @ 2011-03-24  0:20 UTC (permalink / raw)
  To: Mike Frysinger, graf.yang
  Cc: dhowells, uclinux-dev, Greg Ungerer, Paul Mundt,
	uclinux-dist-devel, linux-kernel

Mike Frysinger <vapier@gentoo.org> wrote:

> The percpu code requires more functions to be implemented in the mm core
> which nommu currently does not provide.  So add inline implementations
> since these are largely meaningless on nommu systems.

Under what conditions are these required?

I've seen one percpu compilation bug that I've made a patch for (see
attached), but none of these.  Is SMP required to trigger them?

David
---
From: David Howells <dhowells@redhat.com>
Subject: [PATCH] NOMMU: percpu should use is_vmalloc_addr().

per_cpu_ptr_to_phys() uses VMALLOC_START and VMALLOC_END to determine if an
address is in the vmalloc() region or not.  This is incorrect on NOMMU as
there is no real vmalloc() capability (vmalloc() is emulated by kmalloc()).

The correct way to do this is to use is_vmalloc_addr().  This encapsulates the
vmalloc() region test in MMU mode and just returns 0 in NOMMU mode.

On FRV in NOMMU mode, the percpu compilation fails without this patch:

mm/percpu.c: In function 'per_cpu_ptr_to_phys':
mm/percpu.c:1011: error: 'VMALLOC_START' undeclared (first use in this function)
mm/percpu.c:1011: error: (Each undeclared identifier is reported only once
mm/percpu.c:1011: error: for each function it appears in.)
mm/percpu.c:1012: error: 'VMALLOC_END' undeclared (first use in this function)
mm/percpu.c:1018: warning: control reaches end of non-void function

Signed-off-by: David Howells <dhowells@redhat.com>
---

 mm/percpu.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)


diff --git a/mm/percpu.c b/mm/percpu.c
index 3f93001..55d4d11 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1008,8 +1008,7 @@ phys_addr_t per_cpu_ptr_to_phys(void *addr)
 	}
 
 	if (in_first_chunk) {
-		if ((unsigned long)addr < VMALLOC_START ||
-		    (unsigned long)addr >= VMALLOC_END)
+		if (!is_vmalloc_addr(addr))
 			return __pa(addr);
 		else
 			return page_to_phys(vmalloc_to_page(addr));

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

* Re: [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-24  0:20 ` David Howells
@ 2011-03-24  0:31   ` Mike Frysinger
  2011-03-24  9:40   ` David Howells
  1 sibling, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2011-03-24  0:31 UTC (permalink / raw)
  To: David Howells
  Cc: graf.yang, uclinux-dev, Greg Ungerer, Paul Mundt,
	uclinux-dist-devel, linux-kernel

On Wed, Mar 23, 2011 at 8:20 PM, David Howells wrote:
> Mike Frysinger wrote:
>> The percpu code requires more functions to be implemented in the mm core
>> which nommu currently does not provide.  So add inline implementations
>> since these are largely meaningless on nommu systems.
>
> Under what conditions are these required?
>
> I've seen one percpu compilation bug that I've made a patch for (see
> attached), but none of these.  Is SMP required to trigger them?

yes, it only occurs in SMP builds.

i havent seen the build error you mention below, but i think that's
because in a past discussion we determined that NOMMU ports should be
setting VMALLOC_START to 0 and VMALLOC_END to -1.  is that no longer
the case ?

there are bunch more places where things would fail if
VMALLOC_{START,END} werent defined ...
-mike

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

* Re: [PATCH] NOMMU: support SMP dynamic percpu_alloc
  2011-03-24  0:20 ` David Howells
  2011-03-24  0:31   ` Mike Frysinger
@ 2011-03-24  9:40   ` David Howells
  1 sibling, 0 replies; 10+ messages in thread
From: David Howells @ 2011-03-24  9:40 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: dhowells, graf.yang, uclinux-dev, Greg Ungerer, Paul Mundt,
	uclinux-dist-devel, linux-kernel

Mike Frysinger <vapier@gentoo.org> wrote:

> i havent seen the build error you mention below, but i think that's
> because in a past discussion we determined that NOMMU ports should be
> setting VMALLOC_START to 0 and VMALLOC_END to -1.  is that no longer
> the case ?

Given that there's an explicit test now, I feel we should use it where
appropriate.  I'll have a look to see what else might be renderable to that
test.

David

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

end of thread, other threads:[~2011-03-24  9:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-22 20:41 [PATCH] NOMMU: support SMP dynamic percpu_alloc Mike Frysinger
2011-03-23 12:37 ` Paul Mundt
2011-03-23 23:09   ` [uclinux-dist-devel] " Mike Frysinger
2011-03-24  0:06   ` David Howells
2011-03-24  0:13     ` Mike Frysinger
2011-03-24  0:20     ` David Howells
2011-03-23 13:30 ` Greg Ungerer
2011-03-24  0:20 ` David Howells
2011-03-24  0:31   ` Mike Frysinger
2011-03-24  9:40   ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).