diff mbox series

mm: Increase folio batch size

Message ID 20240315140823.2478146-1-willy@infradead.org (mailing list archive)
State New
Headers show
Series mm: Increase folio batch size | expand

Commit Message

Matthew Wilcox (Oracle) March 15, 2024, 2:08 p.m. UTC
On a 104 thread, 2 socket Skylake system, Intel report a 4.7% performance
reduction with will-it-scale page_fault2.  This was due to reducing the
size of the batch from 32 to 15.  Increasing the folio batch size from
15 to 31 gives a performance increase of 12.5% relative to the original,
or 17.2% relative to the reduced performance commit.

The penalty of this commit is an additional 128 bytes of stack usage.
Six folio_batches are also allocated from percpu memory in cpu_fbatches
so that will be an additional 768 bytes of percpu memory (per CPU).
Tim Chen originally submitted a patch like this in 2020:
https://lore.kernel.org/linux-mm/d1cc9f12a8ad6c2a52cb600d93b06b064f2bbc57.1593205965.git.tim.c.chen@linux.intel.com/

Tested-by: Yujie Liu <yujie.liu@intel.com>
Fixes: 99fbb6bfc16f ("mm: make folios_put() the basis of release_pages()")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202403151058.7048f6a8-oliver.sang@intel.com
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/pagevec.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Shivank Garg March 28, 2024, 10:56 a.m. UTC | #1
>  include/linux/pagevec.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
> index fcc06c300a72..5d3a0cccc6bf 100644
> --- a/include/linux/pagevec.h
> +++ b/include/linux/pagevec.h
> @@ -11,8 +11,8 @@
>  
>  #include <linux/types.h>
>  
> -/* 15 pointers + header align the folio_batch structure to a power of two */
> -#define PAGEVEC_SIZE	15
> +/* 31 pointers + header align the folio_batch structure to a power of two */
> +#define PAGEVEC_SIZE	31
>  
>  struct folio;
>  

Hi,

Thanks for the patch.
I tested the patch with will-it-scale page-fault2 on AMD Zen 4 EPYC server (2-socket system with 128 cores per socket, SMT Enabled). 

Increasing the folio batch size from 15 to 31 gives following performance improvement:
Median: 8.32% 
Max: 23.15%
99th percentile: 20.95%

There is slight performance degradation (bound by -1.21%) in a few cases.

The patch seems to be beneficial for AMD systems as well.

Tested-by: Shivank Garg <shivankg@amd.com>

--
Best Regards,
Shivank
David Hildenbrand March 28, 2024, 12:31 p.m. UTC | #2
On 15.03.24 15:08, Matthew Wilcox (Oracle) wrote:
> On a 104 thread, 2 socket Skylake system, Intel report a 4.7% performance
> reduction with will-it-scale page_fault2.  This was due to reducing the
> size of the batch from 32 to 15.  Increasing the folio batch size from
> 15 to 31 gives a performance increase of 12.5% relative to the original,
> or 17.2% relative to the reduced performance commit.
> 
> The penalty of this commit is an additional 128 bytes of stack usage.
> Six folio_batches are also allocated from percpu memory in cpu_fbatches
> so that will be an additional 768 bytes of percpu memory (per CPU).
> Tim Chen originally submitted a patch like this in 2020:
> https://lore.kernel.org/linux-mm/d1cc9f12a8ad6c2a52cb600d93b06b064f2bbc57.1593205965.git.tim.c.chen@linux.intel.com/
> 
> Tested-by: Yujie Liu <yujie.liu@intel.com>
> Fixes: 99fbb6bfc16f ("mm: make folios_put() the basis of release_pages()")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202403151058.7048f6a8-oliver.sang@intel.com
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   include/linux/pagevec.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
> index fcc06c300a72..5d3a0cccc6bf 100644
> --- a/include/linux/pagevec.h
> +++ b/include/linux/pagevec.h
> @@ -11,8 +11,8 @@
>   
>   #include <linux/types.h>
>   
> -/* 15 pointers + header align the folio_batch structure to a power of two */
> -#define PAGEVEC_SIZE	15
> +/* 31 pointers + header align the folio_batch structure to a power of two */
> +#define PAGEVEC_SIZE	31
>   
>   struct folio;
>   

Reviewed-by: David Hildenbrand <david@redhat.com>
diff mbox series

Patch

diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
index fcc06c300a72..5d3a0cccc6bf 100644
--- a/include/linux/pagevec.h
+++ b/include/linux/pagevec.h
@@ -11,8 +11,8 @@ 
 
 #include <linux/types.h>
 
-/* 15 pointers + header align the folio_batch structure to a power of two */
-#define PAGEVEC_SIZE	15
+/* 31 pointers + header align the folio_batch structure to a power of two */
+#define PAGEVEC_SIZE	31
 
 struct folio;