diff mbox series

ceph: fix incorrect kmalloc size of pagevec mempool

Message ID 20240711064756.334775-1-ethanwu@synology.com
State New
Headers show
Series ceph: fix incorrect kmalloc size of pagevec mempool | expand

Commit Message

ethanwu July 11, 2024, 6:47 a.m. UTC
The kmalloc size of pagevec mempool is incorrectly calculated.
It misses the size of page pointer and only accounts the number for the array.

Fixes: a0102bda5bc0 ("ceph: move sb->wb_pagevec_pool to be a global mempool")
Signed-off-by: ethanwu <ethanwu@synology.com>
---
 fs/ceph/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Xiubo Li July 15, 2024, 2:10 a.m. UTC | #1
On 7/11/24 14:47, ethanwu wrote:
> The kmalloc size of pagevec mempool is incorrectly calculated.
> It misses the size of page pointer and only accounts the number for the array.
>
> Fixes: a0102bda5bc0 ("ceph: move sb->wb_pagevec_pool to be a global mempool")
> Signed-off-by: ethanwu <ethanwu@synology.com>
> ---
>   fs/ceph/super.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index 885cb5d4e771..46f640514561 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -961,7 +961,8 @@ static int __init init_caches(void)
>   	if (!ceph_mds_request_cachep)
>   		goto bad_mds_req;
>   
> -	ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10, CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT);
> +	ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10,
> +				(CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT) * sizeof(struct page *));
>   	if (!ceph_wb_pagevec_pool)
>   		goto bad_pagevec_pool;
>   

Good cache, LGTM.

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Ilya Dryomov July 23, 2024, 6:34 a.m. UTC | #2
On Mon, Jul 15, 2024 at 4:10 AM Xiubo Li <xiubli@redhat.com> wrote:
>
>
> On 7/11/24 14:47, ethanwu wrote:
> > The kmalloc size of pagevec mempool is incorrectly calculated.
> > It misses the size of page pointer and only accounts the number for the array.
> >
> > Fixes: a0102bda5bc0 ("ceph: move sb->wb_pagevec_pool to be a global mempool")
> > Signed-off-by: ethanwu <ethanwu@synology.com>
> > ---
> >   fs/ceph/super.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> > index 885cb5d4e771..46f640514561 100644
> > --- a/fs/ceph/super.c
> > +++ b/fs/ceph/super.c
> > @@ -961,7 +961,8 @@ static int __init init_caches(void)
> >       if (!ceph_mds_request_cachep)
> >               goto bad_mds_req;
> >
> > -     ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10, CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT);
> > +     ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10,
> > +                             (CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT) * sizeof(struct page *));
> >       if (!ceph_wb_pagevec_pool)
> >               goto bad_pagevec_pool;
> >
>
> Good cache, LGTM.

I don't think this matters in practice since 64M / 4K = 16K * 10 = 160K
of memory reserved just for page pointers is already quite a lot...

However, since commit a0102bda5bc0 is talking about moving a pool to be
global without adjusting its parameters, I agree that this fix is valid.

Thanks,

                Ilya
diff mbox series

Patch

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 885cb5d4e771..46f640514561 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -961,7 +961,8 @@  static int __init init_caches(void)
 	if (!ceph_mds_request_cachep)
 		goto bad_mds_req;
 
-	ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10, CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT);
+	ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10,
+				(CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT) * sizeof(struct page *));
 	if (!ceph_wb_pagevec_pool)
 		goto bad_pagevec_pool;