<feed xmlns='http://www.w3.org/2005/Atom'>
<title>talos-skiboot/core/test/run-malloc.c, branch master</title>
<subtitle>Talos™ II skiboot sources</subtitle>
<id>https://git.raptorcs.com/git/talos-skiboot/atom?h=master</id>
<link rel='self' href='https://git.raptorcs.com/git/talos-skiboot/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/'/>
<updated>2017-12-21T04:15:36+00:00</updated>
<entry>
<title>lock: Add additional lock auditing code</title>
<updated>2017-12-21T04:15:36+00:00</updated>
<author>
<name>Benjamin Herrenschmidt</name>
<email>benh@kernel.crashing.org</email>
</author>
<published>2017-12-20T02:16:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=76d9bcdca58936d761458f8f05960239c4dd8dec'/>
<id>urn:sha1:76d9bcdca58936d761458f8f05960239c4dd8dec</id>
<content type='text'>
Keep track of lock owner name and replace lock_depth counter
with a per-cpu list of locks held by the cpu.

This allows us to print the actual locks held in case we hit
the (in)famous message about opal_pollers being run with a
lock held.

It also allows us to warn (and drop them) if locks are still
held when returning to the OS or completing a scheduled job.

Signed-off-by: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Reviewed-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
[stewart: fix unit tests]
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>Fix harmless free() after realloc() in test-malloc.c</title>
<updated>2015-09-09T05:51:23+00:00</updated>
<author>
<name>Stewart Smith</name>
<email>stewart@linux.vnet.ibm.com</email>
</author>
<published>2015-09-09T04:46:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=18cc99db5867438b2b9ba8dca4e78455c2a98abf'/>
<id>urn:sha1:18cc99db5867438b2b9ba8dca4e78455c2a98abf</id>
<content type='text'>
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>trivial run-malloc test fixup that was fooling coverity</title>
<updated>2015-09-08T03:53:24+00:00</updated>
<author>
<name>Stewart Smith</name>
<email>stewart@linux.vnet.ibm.com</email>
</author>
<published>2015-09-08T03:53:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=849419dfc658bf98aa24b4b7310100f9eda99ae1'/>
<id>urn:sha1:849419dfc658bf98aa24b4b7310100f9eda99ae1</id>
<content type='text'>
although we assert that p2==p, coverity doesn't pick this up,
so we get a false positive of a double free.
This is trivial to fix just by modifying our test case.

Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>core: Add asserts for region free-list locking</title>
<updated>2015-05-13T04:01:35+00:00</updated>
<author>
<name>Jeremy Kerr</name>
<email>jk@ozlabs.org</email>
</author>
<published>2015-05-12T10:12:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=ceea843752331258a01a683bf203e9fce6dcd546'/>
<id>urn:sha1:ceea843752331258a01a683bf203e9fce6dcd546</id>
<content type='text'>
This change adds asserts to the mem_region calls that should have the
per-region lock held.

To keep the tests working, they need the lock_held_by_me() function. The
run-mem_region.c test has a bogus implementation of this, as it doesn't
do any locking at the moment. This will be addressed in a later change.

Signed-off-by: Jeremy Kerr &lt;jk@ozlabs.org&gt;
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>core: Move free-list locking to a separate per-region lock</title>
<updated>2015-05-13T04:01:35+00:00</updated>
<author>
<name>Jeremy Kerr</name>
<email>jk@ozlabs.org</email>
</author>
<published>2015-05-12T10:12:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=f96dd8b3d82543ea733a7ab0e854b8331875d524'/>
<id>urn:sha1:f96dd8b3d82543ea733a7ab0e854b8331875d524</id>
<content type='text'>
Currently, we have a single lock for the entire mem_region system; this
protects both the global region list, and the allocations from each
region.

This means we can't allocate memory while traversing the global region
list, as any malloc/realloc/free will try to acquire the mem_region lock
again.

This change separates the locking into different functions. We keep the
mem_region_lock to protect the regions list, and introduce a per-region
lock to protect allocations from the regions' free_lists.

Then we remove the open-coded invocations of mem_alloc, where we'd
avoided malloc() due to the above locking issue.

Signed-off-by: Jeremy Kerr &lt;jk@ozlabs.org&gt;
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>Fix unused result of realloc warning in core/test/run-malloc.c</title>
<updated>2014-12-05T00:53:00+00:00</updated>
<author>
<name>Stewart Smith</name>
<email>stewart@linux.vnet.ibm.com</email>
</author>
<published>2014-12-05T00:53:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=f752d2a51f86ffa1e8101676a450a7d933f78d75'/>
<id>urn:sha1:f752d2a51f86ffa1e8101676a450a7d933f78d75</id>
<content type='text'>
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>Test zalloc() failure case.</title>
<updated>2014-10-22T06:01:27+00:00</updated>
<author>
<name>Stewart Smith</name>
<email>stewart@linux.vnet.ibm.com</email>
</author>
<published>2014-10-22T06:01:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=b0ec172fc1b09f2cf27832b56adb0eb9886c0727'/>
<id>urn:sha1:b0ec172fc1b09f2cf27832b56adb0eb9886c0727</id>
<content type='text'>
This brings us to near total test coverage of core/malloc.c

Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>Add unit test for realloc failure</title>
<updated>2014-10-22T05:57:09+00:00</updated>
<author>
<name>Stewart Smith</name>
<email>stewart@linux.vnet.ibm.com</email>
</author>
<published>2014-10-22T05:57:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=35651388cba4a5d34e1fcb37c675498ca374dea5'/>
<id>urn:sha1:35651388cba4a5d34e1fcb37c675498ca374dea5</id>
<content type='text'>
Increases test coverage of realloc too!

Was:
             Hit   Total  Coverage
Lines:      1936   2574    75.2 %
Functions:   177    225    78.7 %
Branches:   1243   2360    52.7 %

Now:
Lines:      1945   2582    75.3 %
Functions:   177    225    78.7 %
Branches:   1247   2364    52.7 %

Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>in realloc(), memcpy() call would copy past end of allocation</title>
<updated>2014-10-17T00:55:16+00:00</updated>
<author>
<name>Stewart Smith</name>
<email>stewart@linux.vnet.ibm.com</email>
</author>
<published>2014-10-16T07:05:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=78237cccad984a0d757e578ec2a9745de4fcfd87'/>
<id>urn:sha1:78237cccad984a0d757e578ec2a9745de4fcfd87</id>
<content type='text'>
or: Fix mem_size() to remove struct alloc_hdr from returned value

This bug was caught by switching test/run-malloc.c over to using
malloc/free (system malloc/free) to allocate the heap that we use
for testing our malloc and free.

Basically, when we did that, run-malloc.c test would get this
valgrind warning:
==3869== Invalid read of size 8
==3869==    at 0x4C2A706: memcpy (mc_replace_strmem.c:838)
==3869==    by 0x40323F: __realloc (malloc.c:69)
==3869==    by 0x405815: main (run-malloc.c:142)

Which was because in realloc(), when we have to relocate the allocated
bit of memory, we memcpy the contents of the old location into the new
one. The current mem_size() implementation *included* struct alloc_hdr
which mean that we were copying allocated size + sizeof(struct alloc_hdr)
from the returned pointer. This meant we read sizeof(struct alloc_hdr) past
the end of the allocation... which will pretty much always be harmless,
just get random junk in the realloc()ed space.

i.e. we would memcpy() 64+16 (80) bytes from the malloc(64) space to
the realloc(128) space, which is, obviously, 16 bytes more than we should.

IF we had some memory after a region that would make us explode if we read,
then we'd explode around the realloc() call... which would not be so good.
After a bit of a code audit I'm pretty sure this isn't going to actually
hurt us anywhere... or, at least, I hope not...

The fix is simple: fix mem_size() to subtract sizeof(struct alloc_hdr)
from the returned value. This should be okay with the other test case
that checks mem_size() result and there are no other mem_size() callers.

Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
Acked-by: Rusty Russell &lt;rusty@au1.ibm.com&gt;
</content>
</entry>
<entry>
<title>Initial commit of Open Source release</title>
<updated>2014-07-02T05:36:20+00:00</updated>
<author>
<name>Benjamin Herrenschmidt</name>
<email>benh@kernel.crashing.org</email>
</author>
<published>2014-07-02T05:36:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=1d880992fd8c8457a2d990ac6622cfd58fb1b261'/>
<id>urn:sha1:1d880992fd8c8457a2d990ac6622cfd58fb1b261</id>
<content type='text'>
Signed-off-by: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
</content>
</entry>
</feed>
