All of lore.kernel.org
 help / color / mirror / Atom feed
* Why is kmem_bufctl_t different across platforms?
@ 2005-08-28 21:42 Kyle Moffett
  2005-08-28 21:55 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Kyle Moffett @ 2005-08-28 21:42 UTC (permalink / raw)
  To: LKML; +Cc: Andrew Morton

While exploring the asm-*/types.h files, I discovered that the
type "kmem_bufctl_t" is differently defined across each platform,
sometimes as a short, and sometimes as an int.  The only file
where it's used is mm/slab.c, and as far as I can tell, that file
doesn't care at all, aside from preferring it to be a small-sized
type.  I found this comment:

> /*
>  * kmem_bufctl_t:
>  *
>  * Bufctl's are used for linking objs within a slab
>  * linked offsets.
>  *
>  * This implementation relies on "struct page" for locating the  
> cache &
>  * slab an object belongs to.
>  * This allows the bufctl structure to be small (one int), but limits
>  * the number of objects a slab (not a cache) can contain when off- 
> slab
>  * bufctls are used. The limit is the size of the largest general  
> cache
>  * that does not use off-slab slabs.
>  * For 32bit archs with 4 kB pages, is this 56.
>  * This is not serious, as it is only for large objects, when it is  
> unwise
>  * to have too many per slab.
>  * Note: This limit can be raised by introducing a general cache  
> whose size
>  * is less than 512 (PAGE_SIZE<<3), but greater than 256.
>  */

It appears to state that the max kmem_bufctl_t value is ~56 on most
setups, although it could be higher with 64-bit or bigger pages.
Since this value is never used by anything except that kernel-internal
file, should it be unified across all architectures?  If so, I'll send
a patch to remove the various typedefs and introduce a single
"typedef unsigned short kmem_bufctl_t" in include/linux/types.h

Cheers,
Kyle Moffett

--
Premature optimization is the root of all evil in programming
   -- C.A.R. Hoare




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

* Re: Why is kmem_bufctl_t different across platforms?
  2005-08-28 21:42 Why is kmem_bufctl_t different across platforms? Kyle Moffett
@ 2005-08-28 21:55 ` Andrew Morton
  2005-08-28 23:37   ` Adrian Bunk
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2005-08-28 21:55 UTC (permalink / raw)
  To: Kyle Moffett; +Cc: linux-kernel

Kyle Moffett <mrmacman_g4@mac.com> wrote:
>
> While exploring the asm-*/types.h files, I discovered that the
>  type "kmem_bufctl_t" is differently defined across each platform,
>  sometimes as a short, and sometimes as an int.  The only file
>  where it's used is mm/slab.c, and as far as I can tell, that file
>  doesn't care at all, aside from preferring it to be a small-sized
>  type.

I don't think there's any good reason for this.  -mm's
slab-leak-detector.patch switches them all to unsigned long.

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

* Re: Why is kmem_bufctl_t different across platforms?
  2005-08-28 21:55 ` Andrew Morton
@ 2005-08-28 23:37   ` Adrian Bunk
  2005-08-29  2:00     ` Kyle Moffett
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Bunk @ 2005-08-28 23:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Kyle Moffett, linux-kernel

On Sun, Aug 28, 2005 at 02:55:03PM -0700, Andrew Morton wrote:
> Kyle Moffett <mrmacman_g4@mac.com> wrote:
> >
> > While exploring the asm-*/types.h files, I discovered that the
> >  type "kmem_bufctl_t" is differently defined across each platform,
> >  sometimes as a short, and sometimes as an int.  The only file
> >  where it's used is mm/slab.c, and as far as I can tell, that file
> >  doesn't care at all, aside from preferring it to be a small-sized
> >  type.
> 
> I don't think there's any good reason for this.  -mm's
> slab-leak-detector.patch switches them all to unsigned long.

What about moving it to include/linux/types.h ?

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


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

* Re: Why is kmem_bufctl_t different across platforms?
  2005-08-28 23:37   ` Adrian Bunk
@ 2005-08-29  2:00     ` Kyle Moffett
  0 siblings, 0 replies; 4+ messages in thread
From: Kyle Moffett @ 2005-08-29  2:00 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Andrew Morton, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 812 bytes --]

On Aug 28, 2005, at 19:37:16, Adrian Bunk wrote:
> On Sun, Aug 28, 2005 at 02:55:03PM -0700, Andrew Morton wrote:
>> Kyle Moffett <mrmacman_g4@mac.com> wrote:
>>> While exploring the asm-*/types.h files, I discovered that the
>>>  type "kmem_bufctl_t" is differently defined across each platform,
>>>  sometimes as a short, and sometimes as an int.  The only file
>>>  where it's used is mm/slab.c, and as far as I can tell, that file
>>>  doesn't care at all, aside from preferring it to be a small-sized
>>>  type.
>>
>> I don't think there's any good reason for this.  -mm's
>> slab-leak-detector.patch switches them all to unsigned long.
>
> What about moving it to include/linux/types.h ?

Or, since it's _only_ used in mm/slab.c, why not put it in there?
Here is a really simple patch that does just that:

[-- Attachment #2: kmem_bufctl_t-consolidation.patch --]
[-- Type: application/octet-stream, Size: 7300 bytes --]

diff -r 79e63ca47e09 include/asm-alpha/types.h
--- a/include/asm-alpha/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-alpha/types.h	Sun Aug 28 21:59:49 2005
@@ -56,8 +56,6 @@
 typedef u64 dma_addr_t;
 typedef u64 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
 #endif /* _ALPHA_TYPES_H */
diff -r 79e63ca47e09 include/asm-arm/types.h
--- a/include/asm-arm/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-arm/types.h	Sun Aug 28 21:59:49 2005
@@ -52,8 +52,6 @@
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-arm26/types.h
--- a/include/asm-arm26/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-arm26/types.h	Sun Aug 28 21:59:49 2005
@@ -52,8 +52,6 @@
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-cris/types.h
--- a/include/asm-cris/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-cris/types.h	Sun Aug 28 21:59:49 2005
@@ -52,8 +52,6 @@
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-frv/types.h
--- a/include/asm-frv/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-frv/types.h	Sun Aug 28 21:59:49 2005
@@ -65,8 +65,6 @@
 
 typedef u32 dma_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-h8300/types.h
--- a/include/asm-h8300/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-h8300/types.h	Sun Aug 28 21:59:49 2005
@@ -58,8 +58,6 @@
 #define HAVE_SECTOR_T
 typedef u64 sector_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __KERNEL__ */
 
 #endif /* __ASSEMBLY__ */
diff -r 79e63ca47e09 include/asm-i386/types.h
--- a/include/asm-i386/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-i386/types.h	Sun Aug 28 21:59:49 2005
@@ -63,8 +63,6 @@
 #define HAVE_SECTOR_T
 #endif
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-ia64/types.h
--- a/include/asm-ia64/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-ia64/types.h	Sun Aug 28 21:59:49 2005
@@ -67,8 +67,6 @@
 
 typedef u64 dma_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 # endif /* __KERNEL__ */
 #endif /* !__ASSEMBLY__ */
 
diff -r 79e63ca47e09 include/asm-m32r/types.h
--- a/include/asm-m32r/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-m32r/types.h	Sun Aug 28 21:59:49 2005
@@ -55,8 +55,6 @@
 typedef u32 dma_addr_t;
 typedef u64 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-m68k/types.h
--- a/include/asm-m68k/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-m68k/types.h	Sun Aug 28 21:59:49 2005
@@ -60,8 +60,6 @@
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-mips/types.h
--- a/include/asm-mips/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-mips/types.h	Sun Aug 28 21:59:49 2005
@@ -99,8 +99,6 @@
 #define HAVE_SECTOR_T
 #endif
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-parisc/types.h
--- a/include/asm-parisc/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-parisc/types.h	Sun Aug 28 21:59:49 2005
@@ -56,8 +56,6 @@
 typedef u32 dma_addr_t;
 typedef u64 dma64_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-ppc/types.h
--- a/include/asm-ppc/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-ppc/types.h	Sun Aug 28 21:59:49 2005
@@ -62,8 +62,6 @@
 #define HAVE_SECTOR_T
 #endif
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-ppc64/types.h
--- a/include/asm-ppc64/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-ppc64/types.h	Sun Aug 28 21:59:49 2005
@@ -72,7 +72,6 @@
 	unsigned long env;
 } func_descr_t;
 
-typedef unsigned int kmem_bufctl_t;
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-s390/types.h
--- a/include/asm-s390/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-s390/types.h	Sun Aug 28 21:59:49 2005
@@ -79,8 +79,6 @@
 
 typedef u32 dma_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #ifndef __s390x__
 typedef union {
 	unsigned long long pair;
diff -r 79e63ca47e09 include/asm-sh/types.h
--- a/include/asm-sh/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-sh/types.h	Sun Aug 28 21:59:49 2005
@@ -58,8 +58,6 @@
 #define HAVE_SECTOR_T
 #endif
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-sh64/types.h
--- a/include/asm-sh64/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-sh64/types.h	Sun Aug 28 21:59:49 2005
@@ -65,8 +65,6 @@
 #endif
 typedef u64 dma64_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #define BITS_PER_LONG 32
diff -r 79e63ca47e09 include/asm-sparc/types.h
--- a/include/asm-sparc/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-sparc/types.h	Sun Aug 28 21:59:49 2005
@@ -54,8 +54,6 @@
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-sparc64/types.h
--- a/include/asm-sparc64/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-sparc64/types.h	Sun Aug 28 21:59:49 2005
@@ -56,8 +56,6 @@
 typedef u32 dma_addr_t;
 typedef u64 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-v850/types.h
--- a/include/asm-v850/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-v850/types.h	Sun Aug 28 21:59:49 2005
@@ -59,8 +59,6 @@
 
 typedef u32 dma_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-x86_64/types.h
--- a/include/asm-x86_64/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-x86_64/types.h	Sun Aug 28 21:59:49 2005
@@ -51,8 +51,6 @@
 typedef u64 sector_t;
 #define HAVE_SECTOR_T
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff -r 79e63ca47e09 include/asm-xtensa/types.h
--- a/include/asm-xtensa/types.h	Fri Aug 26 18:39:19 2005
+++ b/include/asm-xtensa/types.h	Sun Aug 28 21:59:49 2005
@@ -58,8 +58,6 @@
 
 typedef u32 dma_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif	/* __KERNEL__ */
 #endif
 
diff -r 79e63ca47e09 mm/slab.c
--- a/mm/slab.c	Fri Aug 26 18:39:19 2005
+++ b/mm/slab.c	Sun Aug 28 21:59:49 2005
@@ -189,6 +189,7 @@
  * is less than 512 (PAGE_SIZE<<3), but greater than 256.
  */
 
+typedef unsigned int kmem_bufctl_t;
 #define BUFCTL_END	(((kmem_bufctl_t)(~0U))-0)
 #define BUFCTL_FREE	(((kmem_bufctl_t)(~0U))-1)
 #define	SLAB_LIMIT	(((kmem_bufctl_t)(~0U))-2)

[-- Attachment #3: Type: text/plain, Size: 113 bytes --]


Cheers,
Kyle Moffett

--
Q: Why do programmers confuse Halloween and Christmas?
A: Because OCT 31 == DEC 25.




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

end of thread, other threads:[~2005-08-29  2:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-28 21:42 Why is kmem_bufctl_t different across platforms? Kyle Moffett
2005-08-28 21:55 ` Andrew Morton
2005-08-28 23:37   ` Adrian Bunk
2005-08-29  2:00     ` Kyle Moffett

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.