[PATCH] make buffer size match kernel max transfer size

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] make buffer size match kernel max transfer size

Carlos Maiolino
Currently libfuse has a hardcoded buffer limit to 128kib, while fuse
kernel module has a limit up to 32 pages.

This patch changes buffer limit to match the current page size, instead
of assuming 4096 bytes pages, enabling architectures with bigger pages
to use larger buffers, improving performance.

Also, add a new macro (HEADER_SIZE) to specify the space needed to
accommodate the header, making it easier to understand why those extra
4096 bytes are needed

Signed-off-by: Carlos Maiolino <[hidden email]>
---
 lib/fuse_lowlevel.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index a960123..1ece58c 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -2767,7 +2767,10 @@ restart:
  return res;
 }
 
-#define MIN_BUFSIZE 0x21000
+#define KERNEL_BUF_PAGES 32
+
+/* room needed in buffer to accommodate header */
+#define HEADER_SIZE 0x1000
 
 struct fuse_session *fuse_session_new(struct fuse_args *args,
       const struct fuse_lowlevel_ops *op,
@@ -2829,8 +2832,7 @@ struct fuse_session *fuse_session_new(struct fuse_args *args,
  if (se->debug)
  fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
 
- se->bufsize = getpagesize() + 0x1000;
- se->bufsize = se->bufsize < MIN_BUFSIZE ? MIN_BUFSIZE : se->bufsize;
+ se->bufsize = KERNEL_BUF_PAGES * getpagesize() + HEADER_SIZE;
 
  list_init_req(&se->list);
  list_init_req(&se->interrupts);
--
2.9.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] make buffer size match kernel max transfer size

Miklos Szeredi
On Thu, Apr 20, 2017 at 2:53 PM, Carlos Maiolino <[hidden email]> wrote:

> Currently libfuse has a hardcoded buffer limit to 128kib, while fuse
> kernel module has a limit up to 32 pages.
>
> This patch changes buffer limit to match the current page size, instead
> of assuming 4096 bytes pages, enabling architectures with bigger pages
> to use larger buffers, improving performance.
>
> Also, add a new macro (HEADER_SIZE) to specify the space needed to
> accommodate the header, making it easier to understand why those extra
> 4096 bytes are needed
>
> Signed-off-by: Carlos Maiolino <[hidden email]>

Acked-by: Miklos Szeredi <[hidden email]>

Thanks for the patch.  Nikolaus, can you please add this?

Thanks,

Miklos

> ---
>  lib/fuse_lowlevel.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
> index a960123..1ece58c 100644
> --- a/lib/fuse_lowlevel.c
> +++ b/lib/fuse_lowlevel.c
> @@ -2767,7 +2767,10 @@ restart:
>         return res;
>  }
>
> -#define MIN_BUFSIZE 0x21000
> +#define KERNEL_BUF_PAGES 32
> +
> +/* room needed in buffer to accommodate header */
> +#define HEADER_SIZE 0x1000
>
>  struct fuse_session *fuse_session_new(struct fuse_args *args,
>                                       const struct fuse_lowlevel_ops *op,
> @@ -2829,8 +2832,7 @@ struct fuse_session *fuse_session_new(struct fuse_args *args,
>         if (se->debug)
>                 fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
>
> -       se->bufsize = getpagesize() + 0x1000;
> -       se->bufsize = se->bufsize < MIN_BUFSIZE ? MIN_BUFSIZE : se->bufsize;
> +       se->bufsize = KERNEL_BUF_PAGES * getpagesize() + HEADER_SIZE;
>
>         list_init_req(&se->list);
>         list_init_req(&se->interrupts);
> --
> 2.9.3
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> --
> fuse-devel mailing list
> To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] make buffer size match kernel max transfer size

Nikolaus Rath
On Apr 20 2017, Miklos Szeredi <[hidden email]> wrote:

> On Thu, Apr 20, 2017 at 2:53 PM, Carlos Maiolino <[hidden email]> wrote:
>> Currently libfuse has a hardcoded buffer limit to 128kib, while fuse
>> kernel module has a limit up to 32 pages.
>>
>> This patch changes buffer limit to match the current page size, instead
>> of assuming 4096 bytes pages, enabling architectures with bigger pages
>> to use larger buffers, improving performance.
>>
>> Also, add a new macro (HEADER_SIZE) to specify the space needed to
>> accommodate the header, making it easier to understand why those extra
>> 4096 bytes are needed
>>
>> Signed-off-by: Carlos Maiolino <[hidden email]>
>
> Acked-by: Miklos Szeredi <[hidden email]>
>
> Thanks for the patch.  Nikolaus, can you please add this?

Done, thanks Carlos!

Best,
-Nikolaus

--
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] make buffer size match kernel max transfer size

Carlos Maiolino
On Thu, Apr 20, 2017 at 09:24:38AM -0700, Nikolaus Rath wrote:

> On Apr 20 2017, Miklos Szeredi <[hidden email]> wrote:
> > On Thu, Apr 20, 2017 at 2:53 PM, Carlos Maiolino <[hidden email]> wrote:
> >> Currently libfuse has a hardcoded buffer limit to 128kib, while fuse
> >> kernel module has a limit up to 32 pages.
> >>
> >> This patch changes buffer limit to match the current page size, instead
> >> of assuming 4096 bytes pages, enabling architectures with bigger pages
> >> to use larger buffers, improving performance.
> >>
> >> Also, add a new macro (HEADER_SIZE) to specify the space needed to
> >> accommodate the header, making it easier to understand why those extra
> >> 4096 bytes are needed
> >>
> >> Signed-off-by: Carlos Maiolino <[hidden email]>
> >
> > Acked-by: Miklos Szeredi <[hidden email]>
> >
> > Thanks for the patch.  Nikolaus, can you please add this?
>
> Done, thanks Carlos!
>

Thanks for quick reply Nikolaus :)


> Best,
> -Nikolaus
>
> --
> GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              »Time flies like an arrow, fruit flies like a Banana.«
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> --
> fuse-devel mailing list
> To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel

--
Carlos

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel