Hi Ying, As you will see I opted for your proposal instead of my own, more accurate, one. The reason is that I fear that when we add the base buffer's overhead we will still end up seeing a lot of unnecessary copying. If this solution is accepted by netdev I am ok, otherwise I will fall back to my own version.
///jon > -----Original Message----- > From: Jon Maloy > Sent: Wednesday, February 14, 2018 12:01 > To: Jon Maloy <[email protected]>; Jon Maloy > <[email protected]> > Cc: Mohan Krishna Ghanta Krishnamurthy > <[email protected]>; Tung Quang Nguyen > <[email protected]>; Hoang Huu Le > <[email protected]>; Canh Duc Luu > <[email protected]>; Ying Xue <[email protected]>; > [email protected]; [email protected]; tipc- > [email protected] > Subject: [net v2 1/1] tipc: avoid unnecessary copying of bundled messages > > A received sk buffer may contain dozens of smaller 'bundled' messages > which after extraction go each in their own direction. > > Unfortunately, when we extract those messages using skb_clone() each of > the extracted buffers inherit the truesize value of the original buffer. Apart > from causing massive overaccounting of the base buffers memory, this also > causes tipc_msg_validate() to almost always come to the false conclusion > that the ratio truesize/datasize > 4, and perform an unnecessary copying of > the extracted buffer. > > We now mitigate this problem by explicitly correcting the truesize value of > the clone buffers to be the truesize of the clone. This change eliminates the > overaccounting and most of the unnecessary buffer copying. > > Reported-by: Hoang Le <[email protected]> > Signed-off-by: Jon Maloy <[email protected]> > --- > net/tipc/msg.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 4e1c6f6..a368fa8 100644 > --- a/net/tipc/msg.c > +++ b/net/tipc/msg.c > @@ -434,6 +434,9 @@ bool tipc_msg_extract(struct sk_buff *skb, struct > sk_buff **iskb, int *pos) > skb_pull(*iskb, offset); > imsz = msg_size(buf_msg(*iskb)); > skb_trim(*iskb, imsz); > + > + /* Scale extracted buffer's truesize to avoid double accounting */ > + (*iskb)->truesize = SKB_TRUESIZE(imsz); > if (unlikely(!tipc_msg_validate(iskb))) > goto none; > *pos += align(imsz); > -- > 2.1.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ tipc-discussion mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tipc-discussion
