Thread (8 messages) 8 messages, 4 authors, 2018-12-13

Re: [PATCHv2 net 0/3] net: add support for flex_array_resize in flex_array

From: David Miller <davem@davemloft.net>
Date: 2018-12-12 06:50:04
Also in: linux-sctp, lkml

From: Xin Long <lucien.xin@gmail.com>
Date: Fri,  7 Dec 2018 14:30:32 +0800
Without the support for the total_nr_elements's growing or shrinking
dynamically, flex_array is not that 'flexible'. Like when users want
to change the size, they have to redo flex_array_alloc and copy all
the elements from the old to the new one.  The worse thing is every
element's memory gets changed.

To implement flex_array_resize based on current code, the difficult
thing is to process the size border of FLEX_ARRAY_BASE_BYTES_LEFT,
where the base data memory may change to an array for the 2nd level
data memory for growing, likewise for shrinking.

To make this part easier, we separate the base data memory and define
FLEX_ARRAY_BASE_SIZE as a same value of FLEX_ARRAY_PART_SIZE, as Neil
suggested.  When new size is crossing the border, the base memory is
allocated as the array for the 2nd level data memory and its part[0]
is pointed to the old base memory, and do the opposite for shrinking.

But it doesn't do any memory allocation or shrinking for elements in
flex_array_resize, as which should be done by flex_array_prealloc or
flex_array_shrink called by users.  No memory leaks can be caused by
that.

SCTP has benefited a lot from flex_array_resize() for managing its
stream memory so far.

v1->v2:
  Cc LKML and more developers.
So I don't know what to do about this series.

One of the responses stated that it has been proposed to remove flex_array
and I don't know what to make of that, nor can I tell if that makes this
series inappropriate or not.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help