Google
  Web www.spinics.net

Re: [PATCH] fs: buffer_head, remove kmem_cache constructor to reduce memory usage under slub

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Tue, Feb 09, 2010 at 01:29:51PM +0000, Richard Kennedy wrote:
> fs: Remove the buffer_head kmem_cache constructor to reduce memory usage
> under slub.
> 
> When using slub, having a kmem_cache constructor forces slub to add a
> free pointer to the size of the cached object, which can have a
> significant impact to the number of small objects that can fit into a
> slab. 
> 
> As buffer_head is relatively small and we can have large numbers of
> them, removing the constructor is a definite win.
> 
> On x86_64 removing the constructor gives me 39 objects/slab, 3 more than
> without the patch. And on x86_32 73 objects/slab, which is 9 more.
> 
> As alloc_buffer_head() already initializes each new object there is very
> little difference in actual code run.  
> 
> Signed-off-by: Richard Kennedy <richard@xxxxxxxxxxxxxxx>

Looks fine to me. Seems like it should reduce temporal cache footprint
too by just touching the objects as they are used.

Acked-by: Nick Piggin <npiggin@xxxxxxx>

> ----
> This patch against 2.6.33-rc7
> 
> I've been running this patch for over a week on both a x86_64 desktop & 
> a x86_32 laptop with no problems, only having fewer pages in the
> buffer_head cache :)
> 
> regards
> Richard
> 
> 
> 
> 
> diff --git a/fs/buffer.c b/fs/buffer.c
> index 6fa5302..bc3212e 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -3265,7 +3265,7 @@ static void recalc_bh_state(void)
>  	
>  struct buffer_head *alloc_buffer_head(gfp_t gfp_flags)
>  {
> -	struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags);
> +	struct buffer_head *ret = kmem_cache_zalloc(bh_cachep, gfp_flags);
>  	if (ret) {
>  		INIT_LIST_HEAD(&ret->b_assoc_buffers);
>  		get_cpu_var(bh_accounting).nr++;
> @@ -3352,15 +3352,6 @@ int bh_submit_read(struct buffer_head *bh)
>  }
>  EXPORT_SYMBOL(bh_submit_read);
>  
> -static void
> -init_buffer_head(void *data)
> -{
> -	struct buffer_head *bh = data;
> -
> -	memset(bh, 0, sizeof(*bh));
> -	INIT_LIST_HEAD(&bh->b_assoc_buffers);
> -}
> -
>  void __init buffer_init(void)
>  {
>  	int nrpages;
> @@ -3369,7 +3360,7 @@ void __init buffer_init(void)
>  			sizeof(struct buffer_head), 0,
>  				(SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
>  				SLAB_MEM_SPREAD),
> -				init_buffer_head);
> +				NULL);
>  
>  	/*
>  	 * Limit the bh occupancy to 10% of ZONE_NORMAL
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Site Home]     [Other Archives]     [Linux Kernel Newbies]     [Linux Driver Development]     [Fedora Kernel]     [Linux Kernel Testers]     [Linux SH]     [Linux Omap]     [Linux Kbuild]     [Linux Tape]     [Linux Input]     [Linux Kernel Janitors]     [Linux Kernel Packagers]     [Linux Doc]     [Linux Man Pages]     [Linux API]     [Linux Memory Management]     [Linux Modules]     [Linux Standards]     [Kernel Announce]     [Memory]     [Netdev]     [Git]     [Linux PCI]     [Linux I2C]     [Linux RDMA]     [Linux NUMA]     [Netfilter]     [Netfilter Devel]     [SELinux]     [Bugtraq]     [FIO]     [Linux Perf Users]     [Linux Serial]     [Linux PPP]     [Linux ISDN]     [Linux Next]     [Kernel Stable Commits]     [Linux Tip Commits]     [Kernel MM Commits]     [Linux Security Module]     [Ext3]     [Ext4]     [Linux BTRFS]     [Linux XFS]     [Linux NFS]     [Linux NILFS]     [Linux Cachefs]     [Reiser FS]     [Initramfs]     [Fastboot]     [Linux RT Users]     [eCos]     [Linux Virtualization]     [LVS Devel]     [Hot Plug]     [KVM]     [KVM PPC]     [KVM ia64]     [Linux Containers]     [Util Linux NG]     [Sk Drivers]     [Wireless]     [Linux Bluetooth]     [Bluez Devel]     [Ethernet Bridging]     [LM Sensors]     [Embedded Linux]     [Barebox]     [Linux MMC]     [Sparse]     [Linux Arch]     [Linux ACPI]     [Linux IBM ACPI]     [Linux FB Devel]     [Linux OpenGL]     [CPU Freq]     [Linux Power Management]     [Linux DCCP]     [Linux SCTP]     [ALSA Devel]     [Linux USB]     [Large Format Photos]     [DVD Store]     [Tux]     [Gimp]     [Yosemite National Park Information & Advice]     [Linux PA RISC]     [Linux Samsung SOC]     [MIPS Linux]     [IBM S/390 Linux]     [ARM Linux]     [ARM Kernel]     [ARM MSM]     [Sparc Linux]     [Linux Security]     [Linux Sound]     [Linux Media]     [Video 4 Linux]     [Linux IRDA Users]     [Linux for the blind]     [Linux RAID]     [Linux ATA RAID]     [Device Mapper]     [Linux Clusters]     [Linux SCSI]     [Linux SCSI Target Infrastructure]     [Linux IDE]     [Linux SMP]     [Linux AXP]     [Linux Alpha]     [Linux M68K]     [Linux ia64]     [Linux 8086]     [Linux x86_64]     [Linux Config]     [Linux Apps]     [Linux MSDOS]     [Linux X.25]     [Linux Crypto]     [DM Crypt]     [Linux Btrace]     [Utrace Devel]     [Yosemite Photos]     [Linux C Programming]     [Linux Assembly]     [Dash]     [DWARVES]     [Hail Devel]     [Gcc Help]     [Older Kernel Mail]

Add to Google Powered by Linux