<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/lib/flex_array.c, branch v2.6.39</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.39</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.39'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2011-04-28T20:12:54Z</updated>
<entry>
<title>flex_arrays: allow zero length flex arrays</title>
<updated>2011-04-28T20:12:54Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2011-04-28T19:55:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bf69d41d198138e3c601e9a6645f4f1369aff7e0'/>
<id>urn:sha1:bf69d41d198138e3c601e9a6645f4f1369aff7e0</id>
<content type='text'>
Just like kmalloc will allow one to allocate a 0 length segment of memory
flex arrays should do the same thing.  It should bomb if you try to use
something, but it should at least allow the allocation.

This is needed because when SELinux switched to using flex_arrays in 2.6.38
the inability to allocate a 0 length array resulted in SELinux policy load
returning -ENOSPC when previously it worked.

Based-on-patch-by: Steffen Klassert &lt;steffen.klassert@secunet.com&gt;
Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Tested-by: Chris Richards &lt;gizmo@giz-works.com&gt;
Cc: stable@kernel.org [2.6.38+]
</content>
</entry>
<entry>
<title>flex_array: flex_array_prealloc takes a number of elements, not an end</title>
<updated>2011-04-28T20:12:47Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2011-04-28T19:55:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5d30b10bd68df007e7ae21e77d1e0ce184b53040'/>
<id>urn:sha1:5d30b10bd68df007e7ae21e77d1e0ce184b53040</id>
<content type='text'>
Change flex_array_prealloc to take the number of elements for which space
should be allocated instead of the last (inclusive) element. Users
and documentation are updated accordingly.  flex_arrays got introduced before
they had users.  When folks started using it, they ended up needing a
different API than was coded up originally.  This swaps over to the API that
folks apparently need.

Based-on-patch-by: Steffen Klassert &lt;steffen.klassert@secunet.com&gt;
Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Tested-by: Chris Richards &lt;gizmo@giz-works.com&gt;
Acked-by: Dave Hansen &lt;dave@linux.vnet.ibm.com&gt;
Cc: stable@kernel.org [2.6.38+]
</content>
</entry>
<entry>
<title>flex_array: export symbols to modules</title>
<updated>2011-01-13T16:03:11Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2011-01-13T00:59:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=78c377d1b5e7ef15c8c307c2aa2511602a0829c3'/>
<id>urn:sha1:78c377d1b5e7ef15c8c307c2aa2511602a0829c3</id>
<content type='text'>
Alex said:

  I want to use flex_array to store a sparse array of ATM cell
  re-assembly buffers for my ATM over Ethernet driver.  Using the per-vcc
  user_back structure causes problems when stacked with things like
  br2684.

Add EXPORT_SYMBOL() for all publically accessible flex array functions
and move to obj-y so that modules may use this library.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Dave Hansen &lt;dave@linux.vnet.ibm.com&gt;
Cc: Paul Mundt &lt;lethal@linux-sh.org&gt;
Reported-by: Alex Bennee &lt;kernel-hacker@bennee.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>flex_array: add helpers to get and put to make pointers easy to use</title>
<updated>2010-08-10T03:45:09Z</updated>
<author>
<name>Eric Paris</name>
<email>eparis@redhat.com</email>
</author>
<published>2010-08-10T00:20:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ea98eed9bcb62d1319db8b1210712c6a110a886c'/>
<id>urn:sha1:ea98eed9bcb62d1319db8b1210712c6a110a886c</id>
<content type='text'>
Getting and putting arrays of pointers with flex arrays is a PITA.  You
have to remember to pass &amp;ptr to the _put and you have to do weird and
wacky casting to get the ptr back from the _get.  Add two functions
flex_array_get_ptr() and flex_array_put_ptr() to handle all of the magic.

[akpm@linux-foundation.org: simplification suggested by Joe]
Signed-off-by: Eric Paris &lt;eparis@redhat.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Dave Hansen &lt;dave@linux.vnet.ibm.com&gt;
Cc: Joe Perches &lt;joe@perches.com&gt;
Cc: James Morris &lt;jmorris@namei.org&gt;
Cc: Joe Perches &lt;joe@perches.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>flex_array: fix the panic when calling flex_array_alloc() without __GFP_ZERO</title>
<updated>2010-04-24T18:31:24Z</updated>
<author>
<name>Changli Gao</name>
<email>xiaosuo@gmail.com</email>
</author>
<published>2010-04-23T17:17:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e59464c735db19619cde2aa331609adb02005f5b'/>
<id>urn:sha1:e59464c735db19619cde2aa331609adb02005f5b</id>
<content type='text'>
memset() is called with the wrong address and the kernel panics.

Signed-off-by: Changli Gao &lt;xiaosuo@gmail.com&gt;
Cc: Patrick McHardy &lt;kaber@trash.net&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: &lt;stable@kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>flex_array: add missing kerneldoc annotations</title>
<updated>2009-09-22T14:17:47Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2009-09-22T00:04:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fc0d8d944df0c58cd810f33db82f87dcf5dcc190'/>
<id>urn:sha1:fc0d8d944df0c58cd810f33db82f87dcf5dcc190</id>
<content type='text'>
Add kerneldoc annotations for function formals of type struct flex_array
and gfp_t which are currently lacking.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Dave Hansen &lt;dave@linux.vnet.ibm.com&gt;
Cc: Randy Dunlap &lt;randy.dunlap@oracle.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>flex_array: introduce DEFINE_FLEX_ARRAY</title>
<updated>2009-09-22T14:17:47Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2009-09-22T00:04:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=45b588d6e5cc172704bac0c998ce54873b149b22'/>
<id>urn:sha1:45b588d6e5cc172704bac0c998ce54873b149b22</id>
<content type='text'>
FLEX_ARRAY_INIT(element_size, total_nr_elements) cannot determine if
either parameter is valid, so flex arrays which are statically allocated
with this interface can easily become corrupted or reference beyond its
allocated memory.

This removes FLEX_ARRAY_INIT() as a struct flex_array initializer since no
initializer may perform the required checking.  Instead, the array is now
defined with a new interface:

	DEFINE_FLEX_ARRAY(name, element_size, total_nr_elements)

This may be prefixed with `static' for file scope.

This interface includes compile-time checking of the parameters to ensure
they are valid.  Since the validity of both element_size and
total_nr_elements depend on FLEX_ARRAY_BASE_SIZE and FLEX_ARRAY_PART_SIZE,
the kernel build will fail if either of these predefined values changes
such that the array parameters are no longer valid.

Since BUILD_BUG_ON() requires compile time constants, several of the
static inline functions that were once local to lib/flex_array.c had to be
moved to include/linux/flex_array.h.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Acked-by: Dave Hansen &lt;dave@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>flex_array: add flex_array_shrink function</title>
<updated>2009-09-22T14:17:47Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2009-09-22T00:04:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4af5a2f770cc8575840ccb1514ec76ecb592985c'/>
<id>urn:sha1:4af5a2f770cc8575840ccb1514ec76ecb592985c</id>
<content type='text'>
Add a new function to the flex_array API:

	int flex_array_shrink(struct flex_array *fa)

This function will free all unused second-level pages.  Since elements are
now poisoned if they are not allocated with __GFP_ZERO, it's possible to
identify parts that consist solely of unused elements.

flex_array_shrink() returns the number of pages freed.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Dave Hansen &lt;dave@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>flex_array: poison free elements</title>
<updated>2009-09-22T14:17:47Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2009-09-22T00:04:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=19da3dd157f8db6fe727ff268dab4791d55a6371'/>
<id>urn:sha1:19da3dd157f8db6fe727ff268dab4791d55a6371</id>
<content type='text'>
Newly initialized flex_array's and/or flex_array_part's are now poisoned
with a new poison value, FLEX_ARRAY_FREE.  It's value is similar to
POISON_FREE used in the various slab allocators, but is different to
distinguish between flex array's poisoned kmem and slab allocator poisoned
kmem.

This will allow us to identify flex_array_part's that only contain free
elements (and free them with an addition to the flex_array API).  This
could also be extended in the future to identify `get' uses on elements
that have not been `put'.

If __GFP_ZERO is passed for a part's gfp mask, the poisoning is avoided.
These elements are considered to be in-use since they have been
initialized.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Dave Hansen &lt;dave@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>flex_array: add flex_array_clear function</title>
<updated>2009-09-22T14:17:47Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2009-09-22T00:04:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e6de3988aa52debb25a427d085061f3bf1181d54'/>
<id>urn:sha1:e6de3988aa52debb25a427d085061f3bf1181d54</id>
<content type='text'>
Add a new function to the flex_array API:

	int flex_array_clear(struct flex_array *fa,
				unsigned int element_nr)

This function will zero the element at element_nr in the flex_array.

Although this is equivalent to using flex_array_put() and passing a
pointer to zero'd memory, flex_array_clear() does not require such a
pointer to memory that would most likely need to be allocated on the
caller's stack which could be significantly large depending on
element_size.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Dave Hansen &lt;dave@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
