Skip to contentSkip to conversation

introduce static_vm for ARM-specific static mapped area

RFC PATCH Superseded Joonsoo Kim 2 participants 6 messages Nov 14, 2012 – Nov 15, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover introduce static_vm for ARM-specific static mapped area

In current implementation, we used ARM-specific flag, that is, VM_ARM_STATIC_MAPPING, for distinguishing ARM specific static mapped area. The purpose of static mapped area is to re-use static mapped area when entire physical address range of the ioremap request can be covered by this area.

This implementation causes needless overhead for some cases. We unnecessarily iterate vmlist for finding matched area even if there is no static mapped area. And if there are some static mapped areas, iterating whole vmlist is not preferable.
In fact, it is not a critical problem, because ioremap is not frequently used. But reducing overhead is better idea.

Another reason for doing this work is for removing architecture dependency on vmalloc layer. I think that vmlist and vmlist_lock is internal data structure for vmalloc layer. Some codes for debugging and stat inevitably use vmlist and vmlist_lock. But it is preferable that they are used outside of vmalloc.c as least as possible.

In the near future, I will try to remove other architecture dependency on vmalloc layer.

This is just RFC patch and I did compile-test only. If you have any good suggestion, please let me know.

These are based on v3.7-rc5.

Thanks.

Joonsoo Kim (3):
ARM: vmregion: remove vmregion code entirely
ARM: static_vm: introduce an infrastructure for static mapped area
ARM: mm: use static_vm for managing static mapped areas

 arch/arm/include/asm/mach/static_vm.h |   51 ++++++++
 arch/arm/mm/Makefile                  |    2 +-
 arch/arm/mm/ioremap.c                 |   69 ++++-------
 arch/arm/mm/mm.h                      |   10 --
 arch/arm/mm/mmu.c                     |   55 +++++----
 arch/arm/mm/static_vm.c               |   97 ++++++++++++++++
 arch/arm/mm/vmregion.c                |  205 ---------------------------------
 arch/arm/mm/vmregion.h                |   31 -----
 8 files changed, 208 insertions(+), 312 deletions(-)
 create mode 100644 arch/arm/include/asm/mach/static_vm.h
 create mode 100644 arch/arm/mm/static_vm.c
 delete mode 100644 arch/arm/mm/vmregion.c
 delete mode 100644 arch/arm/mm/vmregion.h
Signature · 1 line
1.7.9.5
#1 lore raw

RFC PATCH 1/3 ARM: vmregion: remove vmregion code entirely

Now, there is no user for vmregion.
So remove it.

arch/arm/mm/Makefile +1 -1
index 8a9c4cb..4e333fa 100644
@@ -6,7 +6,7 @@ obj-y				:= dma-mapping.o extable.o fault.o init.o \
 				   iomap.o
 
 obj-$(CONFIG_MMU)		+= fault-armv.o flush.o idmap.o ioremap.o \
-				   mmap.o pgd.o mmu.o vmregion.o
+				   mmap.o pgd.o mmu.o
 
 ifneq ($(CONFIG_MMU),y)
 obj-y				+= nommu.o
arch/arm/mm/vmregion.c deleted +0 -205

205 lines not on this page · raw message

arch/arm/mm/vmregion.h deleted +0 -31
deleted file mode 100644
index 0f5a5f2..0000000
@@ -1,31 +0,0 @@
-#ifndef VMREGION_H
-#define VMREGION_H
-
-#include <linux/spinlock.h>
-#include <linux/list.h>
-
-struct page;
-
-struct arm_vmregion_head {
-	spinlock_t		vm_lock;
-	struct list_head	vm_list;
-	unsigned long		vm_start;
-	unsigned long		vm_end;
-};
-
-struct arm_vmregion {
-	struct list_head	vm_list;
-	unsigned long		vm_start;
-	unsigned long		vm_end;
-	int			vm_active;
-	const void		*caller;
-};
-
-struct arm_vmregion *arm_vmregion_alloc(struct arm_vmregion_head *, size_t, size_t, gfp_t, const void *);
-struct arm_vmregion *arm_vmregion_find(struct arm_vmregion_head *, unsigned long);
-struct arm_vmregion *arm_vmregion_find_remove(struct arm_vmregion_head *, unsigned long);
-void arm_vmregion_free(struct arm_vmregion_head *, struct arm_vmregion *);
-
-int arm_vmregion_create_proc(const char *, struct arm_vmregion_head *);
-
-#endif
Signature · 1 line
1.7.9.5
#2 lore raw

RFC PATCH 2/3 ARM: static_vm: introduce an infrastructure for static mapped area

In reply to Joonsoo Kim

In current implementation, we used ARM-specific flag, that is, VM_ARM_STATIC_MAPPING, for distinguishing ARM specific static mapped area. The purpose of static mapped area is to re-use static mapped area when entire physical address range of the ioremap request can be covered by this area.

This implementation causes needless overhead for some cases. We unnecessarily iterate vmlist for finding matched area even if there is no static mapped area. And if there are some static mapped areas, iterating whole vmlist is not preferable.
In fact, it is not a critical problem, because ioremap is not frequently used. But reducing overhead is better idea.

Another reason for doing this work is for removing architecture dependency on vmalloc layer. I think that vmlist and vmlist_lock is internal data structure for vmalloc layer. Some codes for debugging and stat inevitably use vmlist and vmlist_lock. But it is preferable that they are used outside of vmalloc.c as least as possible.

Now, I introduce an ARM-specific infrastructure for static mapped area. In the following patch, we will use this and resolve above mentioned problem.

arch/arm/include/asm/mach/static_vm.h new file +45 -0
new file mode 100644
index 0000000..1bb6604
@@ -0,0 +1,45 @@
+/*
+ * arch/arm/include/asm/mach/static_vm.h
+ *
+ * Copyright (C) 2012 LG Electronics, Joonsoo Kim <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _ASM_MACH_STATIC_VM_H
+#define _ASM_MACH_STATIC_VM_H
+
+#include <linux/types.h>
+#include <linux/vmalloc.h>
+
+struct static_vm {
+	struct static_vm	*next;
+	void			*vaddr;
+	unsigned long		size;
+	unsigned long		flags;
+	phys_addr_t		paddr;
+	const void		*caller;
+};
+
+extern struct static_vm *static_vmlist;
+extern spinlock_t static_vmlist_lock;
+
+extern struct static_vm *find_static_vm_paddr(phys_addr_t paddr,
+			size_t size, unsigned long flags);
+extern struct static_vm *find_static_vm_vaddr(void *vaddr, unsigned long flags);
+extern void init_static_vm(struct static_vm *static_vm,
+			struct vm_struct *vm, unsigned long flags);
+extern void insert_static_vm(struct static_vm *vm);
+
+#endif /* _ASM_MACH_STATIC_VM_H */
arch/arm/mm/Makefile +1 -1
index 4e333fa..57b329a 100644
@@ -6,7 +6,7 @@ obj-y				:= dma-mapping.o extable.o fault.o init.o \
 				   iomap.o
 
 obj-$(CONFIG_MMU)		+= fault-armv.o flush.o idmap.o ioremap.o \
-				   mmap.o pgd.o mmu.o
+				   mmap.o pgd.o mmu.o static_vm.o
 
 ifneq ($(CONFIG_MMU),y)
 obj-y				+= nommu.o
arch/arm/mm/static_vm.c new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

RFC PATCH 3/3 ARM: mm: use static_vm for managing static mapped areas

In reply to Joonsoo Kim

A static mapped area is ARM-specific, so it is better not to use generic vmalloc data structure, that is, vmlist and vmlist_lock for managing static mapped area. And it causes some needless overhead and reducing this overhead is better idea.

Now, we have newly introduced static_vm infrastructure. With it, we don't need to iterate all mapped areas. Instead, we just iterate static mapped areas. It helps to reduce an overhead of finding matched area. And architecture dependency on vmalloc layer is removed, so it will help to maintainability for vmalloc layer.

arch/arm/include/asm/mach/static_vm.h +6 -0
index 1bb6604..0d9c685 100644
@@ -32,6 +32,12 @@ struct static_vm {
 	const void		*caller;
 };
 
+#define STATIC_VM_MEM		0x00000001
+#define STATIC_VM_EMPTY		0x00000002
+
+/* mtype should be less than 28 */
+#define STATIC_VM_MTYPE(mt)	(1UL << ((mt) + 4))
+
 extern struct static_vm *static_vmlist;
 extern spinlock_t static_vmlist_lock;
 
arch/arm/mm/ioremap.c +25 -44

103 lines not on this page · raw message

arch/arm/mm/mm.h +0 -10
index a8ee92d..3ae75e5 100644
@@ -52,16 +52,6 @@ extern void __flush_dcache_page(struct address_space *mapping, struct page *page
 /* (super)section-mapped I/O regions used by ioremap()/iounmap() */
 #define VM_ARM_SECTION_MAPPING	0x80000000
 
-/* permanent static mappings from iotable_init() */
-#define VM_ARM_STATIC_MAPPING	0x40000000
-
-/* empty mapping */
-#define VM_ARM_EMPTY_MAPPING	0x20000000
-
-/* mapping type (attributes) for permanent static mappings */
-#define VM_ARM_MTYPE(mt)		((mt) << 20)
-#define VM_ARM_MTYPE_MASK	(0x1f << 20)
-
 /* consistent regions used by dma_alloc_attrs() */
 #define VM_ARM_DMA_CONSISTENT	0x20000000
 
arch/arm/mm/mmu.c +34 -21

115 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw
In reply to Joonsoo Kim
Quoted 7 lines · Joonsoo Kim

In current implementation, we used ARM-specific flag, that is, VM_ARM_STATIC_MAPPING, for distinguishing ARM specific static mapped area. The purpose of static mapped area is to re-use static mapped area when entire physical address range of the ioremap request can be covered by this area.

This implementation causes needless overhead for some cases.

In what cases?

Quoted 3 lines

We unnecessarily iterate vmlist for finding matched area even if there is no static mapped area. And if there are some static mapped areas, iterating whole vmlist is not preferable.

Why not? Please put some explanation into your message rather than just statements making unexplained assertions.

Quoted 5 lines

Another reason for doing this work is for removing architecture dependency on vmalloc layer. I think that vmlist and vmlist_lock is internal data structure for vmalloc layer. Some codes for debugging and stat inevitably use vmlist and vmlist_lock. But it is preferable that they are used outside of vmalloc.c as least as possible.

The vmalloc layer is also made available for ioremap use, and it is intended that architectures hook into this for ioremap support.

#5 lore raw

Hello, Russell.
Thanks for review.

2012/11/15 Russell King - ARM Linux <[email protected]>:

Quoted 10 lines · Joonsoo Kim
Quoted 7 lines

In current implementation, we used ARM-specific flag, that is, VM_ARM_STATIC_MAPPING, for distinguishing ARM specific static mapped area. The purpose of static mapped area is to re-use static mapped area when entire physical address range of the ioremap request can be covered by this area.

This implementation causes needless overhead for some cases.

In what cases?

For example, assume that there is only one static mapped area and vmlist has 300 areas.
Every time we call ioremap, we check 300 areas for deciding whether it is matched or not.
Moreover, even if there is no static mapped area and vmlist has 300 areas, every time we call ioremap, we check 300 areas in now.

Quoted 6 lines
Quoted 3 lines

We unnecessarily iterate vmlist for finding matched area even if there is no static mapped area. And if there are some static mapped areas, iterating whole vmlist is not preferable.

Why not? Please put some explanation into your message rather than just statements making unexplained assertions.

If we construct a extra list for static mapped area, we can eliminate above mentioned overhead.
With a extra list, if there is one static mapped area,
we just check only one area and proceed next operation quickly.

Quoted 8 lines
Quoted 5 lines

Another reason for doing this work is for removing architecture dependency on vmalloc layer. I think that vmlist and vmlist_lock is internal data structure for vmalloc layer. Some codes for debugging and stat inevitably use vmlist and vmlist_lock. But it is preferable that they are used outside of vmalloc.c as least as possible.

The vmalloc layer is also made available for ioremap use, and it is intended that architectures hook into this for ioremap support.

Yes.
But, I think that it is preferable to use well-defined vmalloc API rather than directly manipulating low-level data structure. IMHO, if there is no suitable vmalloc API, making new one is better than directly manipulating low-level data structure. It makes vmalloc code more maintainable.

I'm not expert, so please let me know what I missed.

Thanks.