Re: The value of FB_MTU eats two pages

3 messages, 2 authors, 2021-06-03 · open the first message on its own page

Re: The value of FB_MTU eats two pages

From: Menglong Dong <hidden>
Date: 2021-06-03 02:27:28

Hello Maloy,

On Thu, Jun 3, 2021 at 3:50 AM Jon Maloy [off-list ref] wrote:

[...]
Hi Dong,
The value is based on empiric knowledge.
When I determined it I made a small loop in a kernel driver where I
allocated skbs (using tipc_buf_acquire) with an increasing size
(incremented with 1 each iteration), and then printed out the
corresponding truesize.

That gave the value we are using now.

Now, when re-running the test I get a different value, so something has
obviously changed since then.

[ 1622.158586] skb(513) =>> truesize 2304, prev skb(512) => prev
truesize 1280
[ 1622.162074] skb(1537) =>> truesize 4352, prev skb(1536) => prev
truesize 2304
[ 1622.165984] skb(3585) =>> truesize 8448, prev skb(3584) => prev
truesize 4352

As you can see, the optimal value now, for an x86_64 machine compiled
with gcc, is 3584 bytes, not 3744.
I'm not sure if this is a perfect way to determine the value of FB_MTU.
If 'struct skb_shared_info' changes, this value seems should change,
too.

How about we make it this:

#define FB_MTU (PAGE_SIZE - \
         SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - \
         SKB_DATA_ALIGN(BUF_HEADROOM + BUF_TAILROOM + 3 + \
                 MAX_H_SIZ))

The value 'BUF_HEADROOM + BUF_TAILROOM + 3' come from 'tipc_buf_acquire()':

#ifdef CONFIG_TIPC_CRYPTO
    unsigned int buf_size = (BUF_HEADROOM + size + BUF_TAILROOM + 3) & ~3u;
#else
    unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
#endif

Is it a good idea?

Thanks
Menglong Dong

Re: The value of FB_MTU eats two pages

From: Jon Maloy <jmaloy@redhat.com>
Date: 2021-06-03 13:08:08


On 6/2/21 10:26 PM, Menglong Dong wrote:
Hello Maloy,

On Thu, Jun 3, 2021 at 3:50 AM Jon Maloy [off-list ref] wrote:

[...]
quoted
Hi Dong,
The value is based on empiric knowledge.
When I determined it I made a small loop in a kernel driver where I
allocated skbs (using tipc_buf_acquire) with an increasing size
(incremented with 1 each iteration), and then printed out the
corresponding truesize.

That gave the value we are using now.

Now, when re-running the test I get a different value, so something has
obviously changed since then.

[ 1622.158586] skb(513) =>> truesize 2304, prev skb(512) => prev
truesize 1280
[ 1622.162074] skb(1537) =>> truesize 4352, prev skb(1536) => prev
truesize 2304
[ 1622.165984] skb(3585) =>> truesize 8448, prev skb(3584) => prev
truesize 4352

As you can see, the optimal value now, for an x86_64 machine compiled
with gcc, is 3584 bytes, not 3744.
I'm not sure if this is a perfect way to determine the value of FB_MTU.
If 'struct skb_shared_info' changes, this value seems should change,
too.

How about we make it this:

#define FB_MTU (PAGE_SIZE - \
          SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - \
          SKB_DATA_ALIGN(BUF_HEADROOM + BUF_TAILROOM + 3 + \
                  MAX_H_SIZ))

The value 'BUF_HEADROOM + BUF_TAILROOM + 3' come from 'tipc_buf_acquire()':

#ifdef CONFIG_TIPC_CRYPTO
     unsigned int buf_size = (BUF_HEADROOM + size + BUF_TAILROOM + 3) & ~3u;
#else
     unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
#endif

Is it a good idea?
Yes, I think that makes sense. I was always aware of the "fragility" of 
my approach, -this one looks more future safe.

///jon
Thanks
Menglong Dong

Re: The value of FB_MTU eats two pages

From: Menglong Dong <hidden>
Date: 2021-06-03 14:56:06

On Thu, Jun 3, 2021 at 9:08 PM Jon Maloy [off-list ref] wrote:
[...]
Yes, I think that makes sense. I was always aware of the "fragility" of
my approach, -this one looks more future safe.
Ok, I will post a patch.

Menglong Dong
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help