Skip to contentSkip to conversation

Remove slab cache declarations in slab.h

RFC In review Christoph Lameter 5 participants 23 messages Nov 18, 2006 – Nov 21, 2006

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Remove slab cache declarations in slab.h

One of the strange issues in include/linux/slab.h that it contains a list of global slab caches. The following patches remove all the global definitions from slab.h and find other ways of defining these caches.

6 of the 7 defined caches are rarely used. One is never used.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

RFC 1/7 Remove declaration of sighand_cachep from slab.h

Remove declaration of sighand_cachep from slab.h

The sighand cache is only used in fs/exec.c and kernel/fork.c. It is defined in kernel/fork.c but also used in fs/exec.c. So add an extern declaration to fs/exec.c and remove the definition from slab.h.

fs/exec.c +2 -0
Index: linux-2.6.19-rc5-mm2/fs/exec.c
===================================================================
@@ -62,6 +62,8 @@ int core_uses_pid;
 char core_pattern[128] = "core";
 int suid_dumpable = 0;
 
+extern kmem_cache_t	*sighand_cachep;
+
 EXPORT_SYMBOL(suid_dumpable);
 /* The maximal length of core_pattern is also specified in sysctl.c */
 
include/linux/slab.h +0 -1
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -302,7 +302,6 @@ extern kmem_cache_t	*names_cachep;
 extern kmem_cache_t	*files_cachep;
 extern kmem_cache_t	*filp_cachep;
 extern kmem_cache_t	*fs_cachep;
-extern kmem_cache_t	*sighand_cachep;
 extern kmem_cache_t	*bio_cachep;
 
 #endif	/* __KERNEL__ */

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw

Re: [RFC 1/7] Remove declaration of sighand_cachep from slab.h

Quoted 14 lines · On Fri, 17 Nov 2006 21:43:47 -0800 (PST) Christoph Lameter <[email protected]>…

Remove declaration of sighand_cachep from slab.h

The sighand cache is only used in fs/exec.c and kernel/fork.c. It is defined in kernel/fork.c but also used in fs/exec.c. So add an extern declaration to fs/exec.c and remove the definition from slab.h.

Index: linux-2.6.19-rc5-mm2/fs/exec.c
===================================================================

fs/exec.c int core_uses_pid; · line 65

Quoted 4 lines
fs/exec.c +1 -0
@@ -62,6 +62,8 @@ int core_uses_pid;
 char core_pattern[128] = "core";
 int suid_dumpable = 0;
 
+extern kmem_cache_t	*sighand_cachep;

Is there no suitable header file to put this in?

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

#3 lore raw

SCSI init discussion/SAN problem

I have a problem with the order that the SCSI subsystem attaches disk devices that shows up in a multipath environment.

My understanding is that during the finishing phase of the SCSI subsystem the partition table is read from the drive and the bare drive and each partition are registered with the kernel. Please correct me if I am wrong becuase I am not a kernel developer even at the tinkering level.

The problem shows up in a multipath environment where the same physical device has it's partition table read and then registered with the kernel *for each path on which it available*. I understand the requirement for the second (possibly more) devices registered with the kernel, and I want this behaviour to continue (how else would multipath work?). The problem is that reading the partition table on each of the paths causes I/O to be generated to the physical disk on each of the paths.
For some disk controllers (any with active/passive controllers) this will initial a failover event from the active to the passive controller. This failover can take a few seconds, but multipathing may result in 100's of such paths and failover events which make the boot time very long. I have a machine that takes close to 1hr to boot due to this behavior.

What I would like to have considered is the ability to get the serial number/WWName of the device prior to reading the partition table. If the serial number/WWName has already been registered under a different SCSI ID, then just use the partition table that was used to load the first instance. This will result in I/O only on the first path to each disk.

Another thing that might make things even better is to do something like the mp_prio utils of multipathing do and determine which paths is an active path, and only read the partition table from the active paths.
This may require a 2 pass device registration mechanism becuase it may be possible that none of the paths are active paths, meaning that the device did not get registered by the end of the device list. We would have to go back to the beginning of the list and for any device that was not yet registered with the kernel, read the serial number/WWName and partition table, register with the kernel and then determine if any of the other paths are for the same device to load them into the kernel.

I hope this is clear enough to start a dialog on how to change the scsi initialization faster for large systems on multipath hardware.

Evan Rempel
Senior Programmer Analyst
University of Victoria

#4 lore raw

Re: [RFC 1/7] Remove declaration of sighand_cachep from slab.h

In reply to Stephen Rothwell
Quoted 1 line · Stephen Rothwell

Is there no suitable header file to put this in?

There is only a single file that uses sighand_cachep apart from where it was defined. If we would add it to signal.h then we would also have to add an include for slab.h just for this statement. I cannot imagine any reason why one would have to use sighand_cachep outside of those two files.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw

Re: [RFC 1/7] Remove declaration of sighand_cachep from slab.h

Quoted 7 lines · On Mon, 20 Nov 2006 08:20:13 -0800 (PST) Christoph Lameter <[email protected]>…
Quoted 1 line · Stephen Rothwell

Is there no suitable header file to put this in?

There is only a single file that uses sighand_cachep apart from where it was defined. If we would add it to signal.h then we would also have to add an include for slab.h just for this statement.

That's one of the reasons why typedefs are bad.

Use struct kmem_cache' instead of kmem_cache_t' and lo, you can forward-declare it in the header file without having to include slab.h.

Patches which rid us of kmem_cache_t are always welcome..

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw

Re: [RFC 1/7] Remove declaration of sighand_cachep from slab.h

Quoted 4 lines · Andrew Morton

Use struct kmem_cache' instead of kmem_cache_t' and lo, you can forward-declare it in the header file without having to include slab.h.

Patches which rid us of kmem_cache_t are always welcome..

Ok. So this patch would be acceptable?

Remore kmem_cache_t from mm.

This patch removed all uses of kmem_cache_t from the code in mm/*. The typedef is replaced with a define to allow other code to compile.

include/linux/slab.h +28 -24
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -9,7 +9,8 @@
 
 #if	defined(__KERNEL__)
 
-typedef struct kmem_cache kmem_cache_t;
+/* Remove this after all occurrences of kmem_cache_t have been removed */
+#define kmem_cache_t struct kmem_cache
 
 #include	<linux/gfp.h>
 #include	<linux/init.h>
@@ -57,23 +58,24 @@ typedef struct kmem_cache kmem_cache_t;
 /* prototypes */
 extern void __init kmem_cache_init(void);
 
-extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long,
-				       void (*)(void *, kmem_cache_t *, unsigned long),
-				       void (*)(void *, kmem_cache_t *, unsigned long));
-extern void kmem_cache_destroy(kmem_cache_t *);
-extern int kmem_cache_shrink(kmem_cache_t *);
-extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t);
+extern struct kmem_cache *kmem_cache_create(const char *,
+		size_t, size_t, unsigned long,
+		void (*)(void *, struct kmem_cache *, unsigned long),
+		void (*)(void *, struct kmem_cache *, unsigned long));
+extern void kmem_cache_destroy(struct kmem_cache *);
+extern int kmem_cache_shrink(struct kmem_cache *);
+extern void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
 extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
-extern void kmem_cache_free(kmem_cache_t *, void *);
-extern unsigned int kmem_cache_size(kmem_cache_t *);
-extern const char *kmem_cache_name(kmem_cache_t *);
+extern void kmem_cache_free(struct kmem_cache *, void *);
+extern unsigned int kmem_cache_size(struct kmem_cache *);
+extern const char *kmem_cache_name(struct kmem_cache *);
 
 /* Size description struct for general caches. */
 struct cache_sizes {
 	size_t		 cs_size;
-	kmem_cache_t	*cs_cachep;
+	struct kmem_cache *cs_cachep;
 #ifdef CONFIG_ZONE_DMA
-	kmem_cache_t	*cs_dmacachep;
+	struct kmem_cache *cs_dmacachep;
 #else
 #define cs_dmacachep cs_cachep
 #endif
@@ -215,7 +217,7 @@ extern unsigned int ksize(const void *);
 extern int slab_is_available(void);
 
 #ifdef CONFIG_NUMA
-extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node);
+extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
 extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
 
 static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
@@ -241,7 +243,8 @@ found:
 	return __kmalloc_node(size, flags, node);
 }
 #else
-static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node)
+static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
+						 gfp_t flags, int node)
 {
 	return kmem_cache_alloc(cachep, flags);
 }
@@ -252,10 +255,11 @@ static inline void *kmalloc_node(size_t 
 #endif
 
 extern int FASTCALL(kmem_cache_reap(int));
-extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr));
+extern int FASTCALL(kmem_ptr_validate(struct kmem_cache *cachep, void *ptr));
 
 struct shrinker;
-extern void kmem_set_shrinker(kmem_cache_t *cachep, struct shrinker *shrinker);
+extern void kmem_set_shrinker(struct kmem_cache *cachep,
+					struct shrinker *shrinker);
 
 #else /* CONFIG_SLOB */
 
@@ -291,19 +295,19 @@ static inline void *kcalloc(size_t n, si
 #define kmalloc_track_caller kmalloc
 
 struct shrinker;
-static inline void kmem_set_shrinker(kmem_cache_t *cachep,
+static inline void kmem_set_shrinker(struct kmem_cache *cachep,
 				     struct shrinker *shrinker) {}
 
 #endif /* CONFIG_SLOB */
 
 /* System wide caches */
-extern kmem_cache_t	*vm_area_cachep;
-extern kmem_cache_t	*names_cachep;
-extern kmem_cache_t	*files_cachep;
-extern kmem_cache_t	*filp_cachep;
-extern kmem_cache_t	*fs_cachep;
-extern kmem_cache_t	*sighand_cachep;
-extern kmem_cache_t	*bio_cachep;
+extern struct kmem_cache	*vm_area_cachep;
+extern struct kmem_cache	*names_cachep;
+extern struct kmem_cache	*files_cachep;
+extern struct kmem_cache	*filp_cachep;
+extern struct kmem_cache	*fs_cachep;
+extern struct kmem_cache	*sighand_cachep;
+extern struct kmem_cache	*bio_cachep;
 
 #endif	/* __KERNEL__ */
 
mm/slab.c +1 -1
Index: linux-2.6.19-rc5-mm2/mm/slab.c
===================================================================
@@ -4393,7 +4393,7 @@ unsigned int ksize(const void *objp)
 	return obj_size(virt_to_cache(objp));
 }
 
-void kmem_set_shrinker(kmem_cache_t *cachep, struct shrinker *shrinker)
+void kmem_set_shrinker(struct kmem_cache *cachep, struct shrinker *shrinker)
 {
 	cachep->shrinker = shrinker;
 }
mm/swap_prefetch.c +1 -1
Index: linux-2.6.19-rc5-mm2/mm/swap_prefetch.c
===================================================================
@@ -39,7 +39,7 @@ struct swapped_root {
 	struct radix_tree_root	swap_tree;	/* Lookup tree of pages */
 	unsigned int		count;		/* Number of entries */
 	unsigned int		maxcount;	/* Maximum entries allowed */
-	kmem_cache_t		*cache;		/* Of struct swapped_entry */
+	struct kmem_cache	*cache;		/* Of struct swapped_entry */
 };
 
 static struct swapped_root swapped = {

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw

Re: [RFC 1/7] Remove declaration of sighand_cachep from slab.h

Quoted 7 lines · On Tue, 21 Nov 2006 11:36:19 -0800 (PST) Christoph Lameter <[email protected]>…
Quoted 4 lines · Andrew Morton

Use struct kmem_cache' instead of kmem_cache_t' and lo, you can forward-declare it in the header file without having to include slab.h.

Patches which rid us of kmem_cache_t are always welcome..

Quoted 8 lines

Ok. So this patch would be acceptable?

Remore kmem_cache_t from mm.

This patch removed all uses of kmem_cache_t from the code in mm/*. The typedef is replaced with a define to allow other code to compile.

spose so, although I wouldn't bother about the typedef->#define change. We just keep on plugging away at it until one day we can just remove the typedef.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw

Re: [RFC 1/7] Remove declaration of sighand_cachep from slab.h

Quoted 2 lines · Andrew Morton

spose so, although I wouldn't bother about the typedef->#define change. We just keep on plugging away at it until one day we can just remove the typedef.

You do have script that can replace a string throughout the kernel right?

A patch is following that does the core things in mm and include/linux/slab.h. Would you accept that patch and then do

s/kmem_cache_t/struct kmem_cache/g

over all the kernel sources?

There would be some oversized lines but otherwise this should work.

Remove kmem_cache_t

Remove kmem_cache_t from mm.

include/linux/slab.h +26 -25
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -9,8 +9,6 @@
 
 #if	defined(__KERNEL__)
 
-typedef struct kmem_cache kmem_cache_t;
-
 #include	<linux/gfp.h>
 #include	<linux/init.h>
 #include	<linux/types.h>
@@ -57,23 +55,24 @@ typedef struct kmem_cache kmem_cache_t;
 /* prototypes */
 extern void __init kmem_cache_init(void);
 
-extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long,
-				       void (*)(void *, kmem_cache_t *, unsigned long),
-				       void (*)(void *, kmem_cache_t *, unsigned long));
-extern void kmem_cache_destroy(kmem_cache_t *);
-extern int kmem_cache_shrink(kmem_cache_t *);
-extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t);
+extern struct kmem_cache *kmem_cache_create(const char *,
+		size_t, size_t, unsigned long,
+		void (*)(void *, struct kmem_cache *, unsigned long),
+		void (*)(void *, struct kmem_cache *, unsigned long));
+extern void kmem_cache_destroy(struct kmem_cache *);
+extern int kmem_cache_shrink(struct kmem_cache *);
+extern void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
 extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
-extern void kmem_cache_free(kmem_cache_t *, void *);
-extern unsigned int kmem_cache_size(kmem_cache_t *);
-extern const char *kmem_cache_name(kmem_cache_t *);
+extern void kmem_cache_free(struct kmem_cache *, void *);
+extern unsigned int kmem_cache_size(struct kmem_cache *);
+extern const char *kmem_cache_name(struct kmem_cache *);
 
 /* Size description struct for general caches. */
 struct cache_sizes {
 	size_t		 cs_size;
-	kmem_cache_t	*cs_cachep;
+	struct kmem_cache *cs_cachep;
 #ifdef CONFIG_ZONE_DMA
-	kmem_cache_t	*cs_dmacachep;
+	struct kmem_cache *cs_dmacachep;
 #else
 #define cs_dmacachep cs_cachep
 #endif
@@ -215,7 +214,7 @@ extern unsigned int ksize(const void *);
 extern int slab_is_available(void);
 
 #ifdef CONFIG_NUMA
-extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node);
+extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
 extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
 
 static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
@@ -241,7 +240,8 @@ found:
 	return __kmalloc_node(size, flags, node);
 }
 #else
-static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node)
+static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
+						 gfp_t flags, int node)
 {
 	return kmem_cache_alloc(cachep, flags);
 }
@@ -252,10 +252,11 @@ static inline void *kmalloc_node(size_t 
 #endif
 
 extern int FASTCALL(kmem_cache_reap(int));
-extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr));
+extern int FASTCALL(kmem_ptr_validate(struct kmem_cache *cachep, void *ptr));
 
 struct shrinker;
-extern void kmem_set_shrinker(kmem_cache_t *cachep, struct shrinker *shrinker);
+extern void kmem_set_shrinker(struct kmem_cache *cachep,
+					struct shrinker *shrinker);
 
 #else /* CONFIG_SLOB */
 
@@ -291,19 +292,19 @@ static inline void *kcalloc(size_t n, si
 #define kmalloc_track_caller kmalloc
 
 struct shrinker;
-static inline void kmem_set_shrinker(kmem_cache_t *cachep,
+static inline void kmem_set_shrinker(struct kmem_cache *cachep,
 				     struct shrinker *shrinker) {}
 
 #endif /* CONFIG_SLOB */
 
 /* System wide caches */
-extern kmem_cache_t	*vm_area_cachep;
-extern kmem_cache_t	*names_cachep;
-extern kmem_cache_t	*files_cachep;
-extern kmem_cache_t	*filp_cachep;
-extern kmem_cache_t	*fs_cachep;
-extern kmem_cache_t	*sighand_cachep;
-extern kmem_cache_t	*bio_cachep;
+extern struct kmem_cache	*vm_area_cachep;
+extern struct kmem_cache	*names_cachep;
+extern struct kmem_cache	*files_cachep;
+extern struct kmem_cache	*filp_cachep;
+extern struct kmem_cache	*fs_cachep;
+extern struct kmem_cache	*sighand_cachep;
+extern struct kmem_cache	*bio_cachep;
 
 #endif	/* __KERNEL__ */
 
mm/slab.c +1 -1
Index: linux-2.6.19-rc5-mm2/mm/slab.c
===================================================================
@@ -4393,7 +4393,7 @@ unsigned int ksize(const void *objp)
 	return obj_size(virt_to_cache(objp));
 }
 
-void kmem_set_shrinker(kmem_cache_t *cachep, struct shrinker *shrinker)
+void kmem_set_shrinker(struct kmem_cache *cachep, struct shrinker *shrinker)
 {
 	cachep->shrinker = shrinker;
 }
mm/swap_prefetch.c +1 -1
Index: linux-2.6.19-rc5-mm2/mm/swap_prefetch.c
===================================================================
@@ -39,7 +39,7 @@ struct swapped_root {
 	struct radix_tree_root	swap_tree;	/* Lookup tree of pages */
 	unsigned int		count;		/* Number of entries */
 	unsigned int		maxcount;	/* Maximum entries allowed */
-	kmem_cache_t		*cache;		/* Of struct swapped_entry */
+	struct kmem_cache	*cache;		/* Of struct swapped_entry */
 };
 
 static struct swapped_root swapped = {

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#9 lore raw

Re: [RFC 1/7] Remove declaration of sighand_cachep from slab.h

Quoted 7 lines · On Tue, 21 Nov 2006 11:56:33 -0800 (PST) Christoph Lameter <[email protected]>…
Quoted 2 lines · Andrew Morton

spose so, although I wouldn't bother about the typedef->#define change. We just keep on plugging away at it until one day we can just remove the typedef.

You do have script that can replace a string throughout the kernel right?

Nope.

Quoted 7 lines

A patch is following that does the core things in mm and include/linux/slab.h. Would you accept that patch and then do

s/kmem_cache_t/struct kmem_cache/g

over all the kernel sources?

This is one of those low-priority background activities. Not worth a lot of fuss.

I'd suggest that you proceeed with the original cleanups you were proposing, except use `struct kmem_cache' in header files rather than kmem_cache_t in .c files.

Then, as a separate and later exercise someone (maybe you) can raise patches to do the kmem_cache_t->kmem_cache conversion. They should go through maintainers hence they should be appropriately split and they will take months to all get to mainline. Once this is all completed we can remove the typedef.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw

RFC 2/7 Remove bio_cachep from slab.h

In reply to Christoph Lameter

Remove bio_cachep from slab.h

bio_cachep is no longer used it seems.

include/linux/slab.h +0 -1
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -302,7 +302,6 @@ extern kmem_cache_t	*names_cachep;
 extern kmem_cache_t	*files_cachep;
 extern kmem_cache_t	*filp_cachep;
 extern kmem_cache_t	*fs_cachep;
-extern kmem_cache_t	*bio_cachep;
 
 #endif	/* __KERNEL__ */
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#11 lore raw

RFC 3/7 Move vm_area_cachep to mm.h

In reply to Christoph Lameter

Move vm_area_cachep to mm.h

vm_area_cachep is used to store vm_area_structs. So move to mm.h.

include/linux/mm.h +2 -0
Index: linux-2.6.19-rc5-mm2/include/linux/mm.h
===================================================================
@@ -114,6 +114,8 @@ struct vm_area_struct {
 #endif
 };
 
+extern kmem_cache_t	*vm_area_cachep;
+
 /*
  * This struct defines the per-mm list of VMAs for uClinux. If CONFIG_MMU is
  * disabled, then there's a single shared list of VMAs maintained by the
include/linux/slab.h +0 -1
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -297,7 +297,6 @@ static inline void kmem_set_shrinker(kme
 #endif /* CONFIG_SLOB */
 
 /* System wide caches */
-extern kmem_cache_t	*vm_area_cachep;
 extern kmem_cache_t	*names_cachep;
 extern kmem_cache_t	*files_cachep;
 extern kmem_cache_t	*filp_cachep;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#12 lore raw

RFC 4/7 Move files_cachep to file.h

In reply to Christoph Lameter

Move files_cachep to file.h

The proper place is in file.h since its related to file I/O.

include/linux/file.h +2 -0
Index: linux-2.6.19-rc5-mm2/include/linux/file.h
===================================================================
@@ -101,4 +101,6 @@ struct files_struct *get_files_struct(st
 void FASTCALL(put_files_struct(struct files_struct *fs));
 void reset_files_struct(struct task_struct *, struct files_struct *);
 
+extern kmem_cache_t	*files_cachep;
+
 #endif /* __LINUX_FILE_H */
include/linux/slab.h +0 -1
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -298,7 +298,6 @@ static inline void kmem_set_shrinker(kme
 
 /* System wide caches */
 extern kmem_cache_t	*names_cachep;
-extern kmem_cache_t	*files_cachep;
 extern kmem_cache_t	*filp_cachep;
 extern kmem_cache_t	*fs_cachep;
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#13 lore raw

Re: [RFC 4/7] Move files_cachep to file.h

Quoted 22 lines · On Fri, 17 Nov 2006 21:44:03 -0800 (PST) Christoph Lameter <[email protected]>…

Move files_cachep to file.h

The proper place is in file.h since its related to file I/O.

Index: linux-2.6.19-rc5-mm2/include/linux/file.h
===================================================================

include/linux/file.h +2 -0
@@ -101,4 +101,6 @@ struct files_struct *get_files_struct(st
 void FASTCALL(put_files_struct(struct files_struct *fs));
 void reset_files_struct(struct task_struct *, struct files_struct *);
 
+extern kmem_cache_t	*files_cachep;
+
 #endif /* __LINUX_FILE_H */

Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================

include/linux/slab.h static inline void kmem_set_shrinker(kme · line 303

Quoted 7 lines
include/linux/slab.h +0 -1
@@ -298,7 +298,6 @@ static inline void kmem_set_shrinker(kme
 
 /* System wide caches */
 extern kmem_cache_t	*names_cachep;
-extern kmem_cache_t	*files_cachep;
 extern kmem_cache_t	*filp_cachep;
 extern kmem_cache_t	*fs_cachep;
 

Please convert to `struct kmem_cache' (all patches).

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#14 lore raw

RFC 5/7 Use external declaration for filep_cachep

In reply to Christoph Lameter

Use external declaration for filep_cachep.

filp_cachep is used in fs/file_table.c. Its defined in fs/dcache.c. The easiest solution here is to add an external declaration to fs/file_table.c.

include/linux/slab.h +0 -1
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -298,7 +298,6 @@ static inline void kmem_set_shrinker(kme
 
 /* System wide caches */
 extern kmem_cache_t	*names_cachep;
-extern kmem_cache_t	*filp_cachep;
 extern kmem_cache_t	*fs_cachep;
 
 #endif	/* __KERNEL__ */
fs/file_table.c +2 -0
Index: linux-2.6.19-rc5-mm2/fs/file_table.c
===================================================================
@@ -35,6 +35,8 @@ __cacheline_aligned_in_smp DEFINE_SPINLO
 
 static struct percpu_counter nr_files __cacheline_aligned_in_smp;
 
+extern kmem_cache_t *filp_cachep;
+
 static inline void file_free_rcu(struct rcu_head *head)
 {
 	struct file *f =  container_of(head, struct file, f_u.fu_rcuhead);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw

Re: [RFC 5/7] Use external declaration for filep_cachep

Quoted 12 lines · On Fri, 17 Nov 2006 21:44:08 -0800 (PST) Christoph Lameter <[email protected]>…

Use external declaration for filep_cachep.

filp_cachep is used in fs/file_table.c. Its defined in fs/dcache.c. The easiest solution here is to add an external declaration to fs/file_table.c.

fs/file_table.c __cacheline_aligned_in_smp DEFINE_SPINLO · line 38

Quoted 4 lines
fs/file_table.c +1 -0
@@ -35,6 +35,8 @@ __cacheline_aligned_in_smp DEFINE_SPINLO
 
 static struct percpu_counter nr_files __cacheline_aligned_in_smp;
 
+extern kmem_cache_t *filp_cachep;

Is there no suitable header file to put this in?

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

#17 lore raw

RFC 6/7 Use an external declaration in exit.c for fs_cachep

In reply to Christoph Lameter

Use an external declaration in exit.c for fs_cachep.

fs_cachep is only used in kernel/exit.c and in kernel/fork.c. It is defined in kernel/fork.c so we need to add an external declaration to kernel/exit.c to be able to avoid the declaration.

include/linux/slab.h +0 -1
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -298,7 +298,6 @@ static inline void kmem_set_shrinker(kme
 
 /* System wide caches */
 extern kmem_cache_t	*names_cachep;
-extern kmem_cache_t	*fs_cachep;
 
 #endif	/* __KERNEL__ */
 
kernel/exit.c +2 -0
Index: linux-2.6.19-rc5-mm2/kernel/exit.c
===================================================================
@@ -48,6 +48,8 @@
 #include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 
+extern kmem_cache_t *fs_cachep;
+
 extern void sem_exit (void);
 
 static void exit_mm(struct task_struct * tsk);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#18 lore raw

Re: [RFC 6/7] Use an external declaration in exit.c for fs_cachep

Quoted 13 lines · On Fri, 17 Nov 2006 21:44:13 -0800 (PST) Christoph Lameter <[email protected]>…

Use an external declaration in exit.c for fs_cachep.

fs_cachep is only used in kernel/exit.c and in kernel/fork.c. It is defined in kernel/fork.c so we need to add an external declaration to kernel/exit.c to be able to avoid the declaration.

kernel/exit.c line 51

Quoted 4 lines
kernel/exit.c +1 -0
@@ -48,6 +48,8 @@
 #include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 
+extern kmem_cache_t *fs_cachep;

You know what I am going to say, right? :-)

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

#19 lore raw

Re: [RFC 6/7] Use an external declaration in exit.c for fs_cachep

On 2006-11-18, Stephen Rothwell wrote:
[]

Quoted 9 lines

kernel/exit.c line 51

Quoted 7 lines
kernel/exit.c +1 -0
@@ -48,6 +48,8 @@
 #include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 
+extern kmem_cache_t *fs_cachep;

You know what I am going to say, right? :-)

I know, externs must be in headers. Please, explain why.

TIA.
____

#20 lore raw

Re: [RFC 6/7] Use an external declaration in exit.c for fs_cachep

Quoted 10 lines · On Sat, 18 Nov 2006 06:44:33 +0000 Oleg Verych <[email protected]> wrote:

On 2006-11-18, Stephen Rothwell wrote:
[]

Quoted 6 lines
Quoted 6 lines
kernel/exit.c +0 -0
@@ -48,6 +48,8 @@
 #include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 
Quoted 5 lines
Quoted 3 lines

kernel/exit.c line 51

Quoted 1 line
kernel/exit.c +1 -0
+extern kmem_cache_t *fs_cachep;

You know what I am going to say, right? :-)

I know, externs must be in headers. Please, explain why.

So that there is only one declaration. That way if it is changed, everywhere that uses it will notice. Also, the same header must be included by the file that defines the variable or function so any discrepancy between declaration and definition will be obvious.

i.e. we are protecting ourselves against change and making maintainance easier.

In this particular case, the type is probably never going to change, but consistency is good.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

#22 lore raw

RFC 7/7 Move names_cachep to fs.h

In reply to Christoph Lameter

Move names_cachep to fs.h

The names_cachep is used for getname() and putname(). So lets put it into fs.h.

include/linux/slab.h +0 -3
Index: linux-2.6.19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -296,9 +296,6 @@ static inline void kmem_set_shrinker(kme
 
 #endif /* CONFIG_SLOB */
 
-/* System wide caches */
-extern kmem_cache_t	*names_cachep;
-
 #endif	/* __KERNEL__ */
 
 #endif	/* _LINUX_SLAB_H */
include/linux/fs.h +2 -0
Index: linux-2.6.19-rc5-mm2/include/linux/fs.h
===================================================================
@@ -1558,6 +1558,8 @@ extern char * getname(const char __user 
 extern void __init vfs_caches_init_early(void);
 extern void __init vfs_caches_init(unsigned long);
 
+extern kmem_cache_t	*names_cachep;
+
 #define __getname()	kmem_cache_alloc(names_cachep, SLAB_KERNEL)
 #define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
 #ifndef CONFIG_AUDITSYSCALL

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>