<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/lib/list_sort.c, branch v3.19</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=v3.19</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.19'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2014-08-07T01:01:25Z</updated>
<entry>
<title>lib/list_sort.c: convert to pr_foo</title>
<updated>2014-08-07T01:01:25Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@linux-foundation.org</email>
</author>
<published>2014-08-06T23:09:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d0da23b0debcef135c866cc8117d197fb40a6079'/>
<id>urn:sha1:d0da23b0debcef135c866cc8117d197fb40a6079</id>
<content type='text'>
Cc: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Cc: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.com&gt;
Cc: Dave Chinner &lt;david@fromorbit.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>lib: list_sort.c: Limit number of unused cmp callbacks</title>
<updated>2014-08-07T01:01:25Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>linux@rasmusvillemoes.dk</email>
</author>
<published>2014-08-06T23:09:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=61b3d6c48f059bb054b0019088736dab6c2ac0ec'/>
<id>urn:sha1:61b3d6c48f059bb054b0019088736dab6c2ac0ec</id>
<content type='text'>
The helper merge_and_restore_back_links() makes sure to call the
caller's cmp function during the final -&gt;prev pointer fixup, so that the
cmp function may call cond_resched().  However, if the cmp function does
not call cond_resched() at all, this is entirely redundant.  If it does,
doing at least two function calls for every two pointer assignments is a
bit excessive.  This patch limits the calls to once for every 256
iterations.

Signed-off-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Cc: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.com&gt;
Cc: Dave Chinner &lt;david@fromorbit.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>lib: list_sort_test(): simplify and harden cleanup</title>
<updated>2014-08-07T01:01:25Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>linux@rasmusvillemoes.dk</email>
</author>
<published>2014-08-06T23:09:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=694123031d12458a343492528fa40113e5ec843e'/>
<id>urn:sha1:694123031d12458a343492528fa40113e5ec843e</id>
<content type='text'>
There is no reason to maintain the list structure while freeing the
debug elements.  Aside from the redundant pointer manipulations, it is
also inefficient from a locality-of-reference viewpoint, since they are
visited in a random order (wrt.  the order they were allocated).
Furthermore, if we jumped to exit: after detecting list corruption, it
is actually dangerous.

So just free the elements in the order they were allocated, using the
backing array elts.  Allocate that using kcalloc(), so that if
allocation of one of the debug element fails, we just end up calling
kfree(NULL) for the trailing elements.

Minor details: Use sizeof(*elts) instead of sizeof(void *), and return
err immediately when allocation of elts fails, to avoid introducing
another label just before the final return statement.

Signed-off-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Cc: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.com&gt;
Cc: Dave Chinner &lt;david@fromorbit.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>lib: list_sort_test(): add extra corruption check</title>
<updated>2014-08-07T01:01:25Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>linux@rasmusvillemoes.dk</email>
</author>
<published>2014-08-06T23:09:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9d418dcc6d15539a9567b2ad7fe7473648989f44'/>
<id>urn:sha1:9d418dcc6d15539a9567b2ad7fe7473648989f44</id>
<content type='text'>
Add a check to make sure that the prev pointer of the list head points
to the last element on the list.

Signed-off-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Cc: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.com&gt;
Cc: Dave Chinner &lt;david@fromorbit.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>lib: list_sort_test(): return -ENOMEM when allocation fails</title>
<updated>2014-08-07T01:01:25Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>linux@rasmusvillemoes.dk</email>
</author>
<published>2014-08-06T23:09:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=27d555d101c820ac4b1962680bd0192993c6e4e0'/>
<id>urn:sha1:27d555d101c820ac4b1962680bd0192993c6e4e0</id>
<content type='text'>
Signed-off-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Cc: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.com&gt;
Cc: Dave Chinner &lt;david@fromorbit.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>lib/: rename random32() to prandom_u32()</title>
<updated>2013-04-30T01:28:42Z</updated>
<author>
<name>Akinobu Mita</name>
<email>akinobu.mita@gmail.com</email>
</author>
<published>2013-04-29T23:21:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f39fee5f11f7adfcf5c9643f87718b80450be18a'/>
<id>urn:sha1:f39fee5f11f7adfcf5c9643f87718b80450be18a</id>
<content type='text'>
Use preferable function name which implies using a pseudo-random
number generator.

Signed-off-by: Akinobu Mita &lt;akinobu.mita@gmail.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>lib/list_sort: test: check element addresses</title>
<updated>2010-10-26T23:52:19Z</updated>
<author>
<name>Artem Bityutskiy</name>
<email>Artem.Bityutskiy@nokia.com</email>
</author>
<published>2010-10-26T21:23:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=041b78f232bb87b2de8ca3fed50384bc7dc9c2de'/>
<id>urn:sha1:041b78f232bb87b2de8ca3fed50384bc7dc9c2de</id>
<content type='text'>
Improve 'lib_sort()' test and check that:
 o 'cmp()' is called only for elements which were present in the original list,
   i.e., the 'a' and 'b' parameters are valid
 o the resulted (sorted) list consists onlly of the original elements
 o intdoruce "poison" fields to make sure data around 'struc list_head' field
   are not corrupted.

Signed-off-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.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>lib/list_sort: test: unify test messages</title>
<updated>2010-10-26T23:52:19Z</updated>
<author>
<name>Artem Bityutskiy</name>
<email>Artem.Bityutskiy@nokia.com</email>
</author>
<published>2010-10-26T21:23:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=014afa943d44f0df8e65bc4bd071c67772277d93'/>
<id>urn:sha1:014afa943d44f0df8e65bc4bd071c67772277d93</id>
<content type='text'>
This patch unifies 'list_sort_test()' messages a bit and makes sure all of
them start with the "list_sort_test:" prefix to make it obvious for users
where the messages come from.

Signed-off-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.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>lib/list_sort: test: improve errors handling</title>
<updated>2010-10-26T23:52:19Z</updated>
<author>
<name>Artem Bityutskiy</name>
<email>Artem.Bityutskiy@nokia.com</email>
</author>
<published>2010-10-26T21:23:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f3dc0e384248ea6fda0987f909007fa9ab5fb51a'/>
<id>urn:sha1:f3dc0e384248ea6fda0987f909007fa9ab5fb51a</id>
<content type='text'>
The 'lib_sort()' test does not free memory if it fails, and it makes the
kernel panic if it cannot allocate memory.  This patch fixes the problem.

This patch also changes several small things:
 o use 'list_add()' helper instead of adding manually
 o introduce temporary 'el1' variable to avoid ugly and unreadalbe
   "if" statement
 o make 'head' to be stack variable instead of 'kmalloc()'ed, which
   simplifies code a bit

Overall, this patch is of clean-up type.

Signed-off-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.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>lib/list_sort: test: use generic random32</title>
<updated>2010-10-26T23:52:19Z</updated>
<author>
<name>Artem Bityutskiy</name>
<email>Artem.Bityutskiy@nokia.com</email>
</author>
<published>2010-10-26T21:23:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=eeee9ebb54b76a33a13d2c926ffb018a4aea410f'/>
<id>urn:sha1:eeee9ebb54b76a33a13d2c926ffb018a4aea410f</id>
<content type='text'>
Instead of using own pseudo-random generator, use generic linux
'random32()' function.  Presumably, this should improve test coverage.

At the same time, do the following changes:
  o Use shorter macro name for test list length
  o Do not use strange 'l_h' name for 'struct list_head' element,
    use 'list', because it is traditional name and thus, makes the
    code more obvious and readable.

Signed-off-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Cc: Don Mullis &lt;don.mullis@gmail.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>
