Re: [PATCH v3 2/2] tmpfs: Make tmpfs scalable with percpu_counter for used blocks

From: Minchan Kim
Date: Thu Jun 17 2010 - 21:35:57 EST


Hello.
The idea is good. :)

On Fri, Jun 18, 2010 at 8:56 AM, Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx> wrote:
> The current implementation of tmpfs is not scalable.
> We found that stat_lock is contended by multiple threads
> when we need to get a new page, leading to useless spinning
> inside this spin lock.
>
> This patch makes use of the percpu_counter library to maintain local
> count of used blocks to speed up getting and returning
> of pages. ÂSo the acquisition of stat_lock is unnecessary
> for getting and returning blocks, improving the performance
> of tmpfs on system with large number of cpus. ÂOn a 4 socket
> 32 core NHM-EX system, we saw improvement of 270%.
>

Good enhancement. :)

> Signed-off-by: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
> Âinclude/linux/shmem_fs.h | Â Â3 ++-
> Âmm/shmem.c        |  40 +++++++++++++++++-----------------------
> Â2 files changed, 19 insertions(+), 24 deletions(-)
>
> diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
> index e164291..399be5a 100644
> --- a/include/linux/shmem_fs.h
> +++ b/include/linux/shmem_fs.h
> @@ -3,6 +3,7 @@
>
> Â#include <linux/swap.h>
> Â#include <linux/mempolicy.h>
> +#include <linux/percpu_counter.h>
>
> Â/* inode in-kernel data */
>
> @@ -23,7 +24,7 @@ struct shmem_inode_info {
>
> Âstruct shmem_sb_info {
> Â Â Â Âunsigned long max_blocks; Â /* How many blocks are allowed */
> - Â Â Â unsigned long free_blocks; Â/* How many are left for allocation */
> + Â Â Â struct percpu_counter used_blocks; Â/* How many are allocated */

Just a nitpick.
Why do you change free_blocks and used_blocks?
I think we can use free_blocks following as.

ex)
if (percpu_counter_compare(&sbinfo->free_blocks, 0))

Do you have any reason?
Please, justify it.

Thanks, Tim.
--
Kind regards,
Minchan Kim
--
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/