Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Issue 7671034: doubly-linked free-lists for thread caches and page heaps (Closed)

Created:
9 years, 4 months ago by bxx
Modified:
7 years, 2 months ago
CC:
chromium-reviews, brettw-cc_chromium.org, antonm, willchan no longer on Chromium
Visibility:
Public.

Description

tcmalloc doubly-linked free-lists for thread caches Added the ability for free lists to be built out of doubly-linked lists in tcalloc. TCMALLOC_USE_DOUBLYLINKED_FREELIST flag must be set in order for doubly-linked lists to be used. By default flag is only set in Debug builds. BUG=None TEST=None Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=99515 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=100074 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=100525

Patch Set 1 : added #include that was accidently removed #

Patch Set 2 : code style fixes #

Total comments: 77

Patch Set 3 : style tweaks, fixed pointer checks, reduce wasted space #

Patch Set 4 : add doubly linked lists to page_heap_allocator #

Total comments: 10

Patch Set 5 : clean up code, improve macro name #

Total comments: 30

Patch Set 6 : fix macros and size class checks #

Total comments: 14

Patch Set 7 : added references to SLL_* functions #

Total comments: 2

Patch Set 8 : move size implementation #

Total comments: 4

Patch Set 9 : add check in size #

Patch Set 10 : size assert->memory check #

Patch Set 11 : fix FL interface, class sizes #

Patch Set 12 : change macro name #

Patch Set 13 : remove macros #

Patch Set 14 : nit fixes #

Patch Set 15 : remove inline to fix linking problems #

Patch Set 16 : enable doubly linked lists only in Debug builds #

Unified diffs Side-by-side diffs Delta from patch set Stats (+365 lines, -39 lines) Patch
M base/allocator/allocator.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +6 lines, -0 lines 0 comments Download
M third_party/tcmalloc/chromium/src/central_freelist.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 7 chunks +10 lines, -15 lines 0 comments Download
M third_party/tcmalloc/chromium/src/common.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +15 lines, -4 lines 0 comments Download
M third_party/tcmalloc/chromium/src/common.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
A third_party/tcmalloc/chromium/src/free_list.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +99 lines, -0 lines 0 comments Download
A third_party/tcmalloc/chromium/src/free_list.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +219 lines, -0 lines 0 comments Download
M third_party/tcmalloc/chromium/src/page_heap_allocator.h View 1 2 3 3 chunks +3 lines, -4 lines 0 comments Download
M third_party/tcmalloc/chromium/src/tcmalloc.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/tcmalloc/chromium/src/thread_cache.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +6 lines, -12 lines 0 comments Download
M third_party/tcmalloc/chromium/src/thread_cache.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +4 lines, -1 line 0 comments Download

Messages

Total messages: 27 (0 generated)
jar (doing other things)
+cc antonm and willchan, as they are picky enough to spot stuff to. I'm really ...
9 years, 4 months ago (2011-08-20 02:40:30 UTC) #1
bxx
I made most of the changes you asked for. One of the changes I didn't ...
9 years, 4 months ago (2011-08-24 00:19:24 UTC) #2
jschuh
I just added a few nits from a quick skim. Given that Jim is way ...
9 years, 4 months ago (2011-08-24 17:22:30 UTC) #3
bxx
http://codereview.chromium.org/7671034/diff/23003/third_party/tcmalloc/chromium/src/central_freelist.cc File third_party/tcmalloc/chromium/src/central_freelist.cc (right): http://codereview.chromium.org/7671034/diff/23003/third_party/tcmalloc/chromium/src/central_freelist.cc#newcode95 third_party/tcmalloc/chromium/src/central_freelist.cc:95: void *next = span->objects; Good catch. I don't even ...
9 years, 4 months ago (2011-08-24 22:02:09 UTC) #4
jar (doing other things)
http://codereview.chromium.org/7671034/diff/6003/third_party/tcmalloc/chromium/src/free_list.cc File third_party/tcmalloc/chromium/src/free_list.cc (right): http://codereview.chromium.org/7671034/diff/6003/third_party/tcmalloc/chromium/src/free_list.cc#newcode51 third_party/tcmalloc/chromium/src/free_list.cc:51: return *(reinterpret_cast<void**> (static_cast<void **>(t) + 1)); This file is ...
9 years, 4 months ago (2011-08-25 02:07:50 UTC) #5
bxx
Class size code seems a little hacky at the moment. I considered cleaning it up ...
9 years, 4 months ago (2011-08-25 20:23:18 UTC) #6
jar (doing other things)
This is looking much nicer. A few more comments below... and perhaps you'll get a ...
9 years, 4 months ago (2011-08-26 18:56:29 UTC) #7
bxx
Hopefully these will be the last set of changes. I kicked off the trybots, but ...
9 years, 4 months ago (2011-08-26 21:45:10 UTC) #8
jar (doing other things)
As I mentioned, I'd really like to see this land separately from other checkins, so ...
9 years, 4 months ago (2011-08-26 23:17:42 UTC) #9
jar (doing other things)
Two things I failed to point out: a) All the SLL_* code should be referenced, ...
9 years, 3 months ago (2011-08-29 09:59:39 UTC) #10
bxx
Sorry, I had some git issues and also screwed up the last patch on this ...
9 years, 3 months ago (2011-08-29 19:20:54 UTC) #11
jar (doing other things)
http://codereview.chromium.org/7671034/diff/44013/third_party/tcmalloc/chromium/src/free_list.h File third_party/tcmalloc/chromium/src/free_list.h (right): http://codereview.chromium.org/7671034/diff/44013/third_party/tcmalloc/chromium/src/free_list.h#newcode135 third_party/tcmalloc/chromium/src/free_list.h:135: inline size_t FL_Size(void *head) { You should probably push ...
9 years, 3 months ago (2011-08-29 19:37:46 UTC) #12
bxx
http://codereview.chromium.org/7671034/diff/44013/third_party/tcmalloc/chromium/src/free_list.h File third_party/tcmalloc/chromium/src/free_list.h (right): http://codereview.chromium.org/7671034/diff/44013/third_party/tcmalloc/chromium/src/free_list.h#newcode135 third_party/tcmalloc/chromium/src/free_list.h:135: inline size_t FL_Size(void *head) { On 2011/08/29 19:37:46, jar ...
9 years, 3 months ago (2011-08-29 20:44:52 UTC) #13
jar (doing other things)
http://codereview.chromium.org/7671034/diff/50001/third_party/tcmalloc/chromium/src/free_list.cc File third_party/tcmalloc/chromium/src/free_list.cc (right): http://codereview.chromium.org/7671034/diff/50001/third_party/tcmalloc/chromium/src/free_list.cc#newcode168 third_party/tcmalloc/chromium/src/free_list.cc:168: int count = 0; Please validate: MEMORY_CHECK(FL_Previous_No_Check(*head), NULL);
9 years, 3 months ago (2011-08-29 20:55:21 UTC) #14
bxx
http://codereview.chromium.org/7671034/diff/50001/third_party/tcmalloc/chromium/src/free_list.cc File third_party/tcmalloc/chromium/src/free_list.cc (right): http://codereview.chromium.org/7671034/diff/50001/third_party/tcmalloc/chromium/src/free_list.cc#newcode168 third_party/tcmalloc/chromium/src/free_list.cc:168: int count = 0; On 2011/08/29 20:55:21, jar wrote: ...
9 years, 3 months ago (2011-08-29 21:38:13 UTC) #15
jar (doing other things)
http://codereview.chromium.org/7671034/diff/50001/third_party/tcmalloc/chromium/src/free_list.cc File third_party/tcmalloc/chromium/src/free_list.cc (right): http://codereview.chromium.org/7671034/diff/50001/third_party/tcmalloc/chromium/src/free_list.cc#newcode168 third_party/tcmalloc/chromium/src/free_list.cc:168: int count = 0; The original implementation (via SLL_*) ...
9 years, 3 months ago (2011-08-29 21:54:33 UTC) #16
bxx
http://codereview.chromium.org/7671034/diff/50001/third_party/tcmalloc/chromium/src/free_list.cc File third_party/tcmalloc/chromium/src/free_list.cc (right): http://codereview.chromium.org/7671034/diff/50001/third_party/tcmalloc/chromium/src/free_list.cc#newcode168 third_party/tcmalloc/chromium/src/free_list.cc:168: int count = 0; On 2011/08/29 21:54:33, jar wrote: ...
9 years, 3 months ago (2011-08-29 22:17:12 UTC) #17
jar (doing other things)
LGTM... and you should ask Sanjay if he'd like to review and comment. Thanks!
9 years, 3 months ago (2011-08-29 23:16:55 UTC) #18
brettw
base LGTM rubberstamp
9 years, 3 months ago (2011-09-09 22:29:57 UTC) #19
willchan no longer on Chromium
http://build.chromium.org/p/chromium/builders/Linux%20Tests%20%28Views%20dbg%29%281%29/builds/5502/steps/browser_tests/logs/stdio#failure3 NetworkScreenTest.Cellular seems to fail flakily in shutdown with messages like: === [ OK ] ...
9 years, 3 months ago (2011-09-13 06:15:29 UTC) #20
jschuh
On Mon, Sep 12, 2011 at 11:15 PM, William Chan (陈智昌) <willchan@chromium.org>wrote: > > http://build.chromium.org/p/chromium/builders/Linux%20Tests%20%28Views%20dbg%29%281%29/builds/5502/steps/browser_tests/logs/stdio#failure3 ...
9 years, 3 months ago (2011-09-13 15:19:34 UTC) #21
bxx_google.com
I would be interested in seeing how this looks under ASAN. I haven't been able ...
9 years, 3 months ago (2011-09-13 18:15:34 UTC) #22
jschuh
D'oh, I meant ASAN, not TSAN. -j On Tue, Sep 13, 2011 at 11:15 AM, ...
9 years, 3 months ago (2011-09-13 23:56:52 UTC) #23
Alexander Potapenko
If that's still necessary, I can try the test under ASan and/or help you to ...
9 years, 3 months ago (2011-09-21 23:01:38 UTC) #24
alkondratenko
Upstream gperftools maintainer here. I'm looking at list of differences between chromium fork and upstream ...
7 years, 2 months ago (2013-10-21 03:12:45 UTC) #25
willchan no longer on Chromium
I forget..but I think this was either debugging or for security hardening. jschuh@ or jar@ ...
7 years, 2 months ago (2013-10-21 18:45:33 UTC) #26
jar (doing other things)
7 years, 2 months ago (2013-10-21 22:08:05 UTC) #27
It was indeed both, if you consider "debugging" to include "easier to
understand core dumps."

A common problem was a memory corruption bug induced by a double free, (or
by flat out memory corruption of the free heap? use after free? etc.).  A
double-free would routinely cause singly linked lists to be "crossed" (two
lists point to the same "next" item).  The fact that the single-linked-list
also contained an external "list length" further aggravated the problem.
This would generally explode when we either walked off the end of the list
(paying too much attention to the length, such as when passing groups of
memory from a central cache to the thread cache), or plausibly via a double
use when reallocating (out of the separate thread caches <oops>).

The addition of the back-pointers in a doubly linked list tend to reveal
this instantly as we try to walk off the list. This avoids any chance of
using the freed memory in two ways... adding (we think) a good amount of
hardening.

YMMV... but we didn't see any significant perf impact (in our
application)... and we tend to get a much earlier crash when we do have
corrupt heaps.

As for upstream... you'd certainly want to carefully measure the perf
impact in your application(s).  The good news is that (as I recall) we
crafted it to be easy to select between the two list implementations (at
compile time, with no perf impact).... so that format may provide a nice
upstream patch.

Jim


On Mon, Oct 21, 2013 at 11:45 AM, William Chan (陈智昌)
<willchan@chromium.org>wrote:

> I forget..but I think this was either debugging or for security hardening.
> jschuh@ or jar@ should know. I didn't review this one.
>
>
> On Sun, Oct 20, 2013 at 8:12 PM, <alkondratenko@gmail.com> wrote:
>
>> Upstream gperftools maintainer here. I'm looking at list of differences
>> between
>> chromium fork and upstream and came across this set of changes. What is
>> not
>> clear to me from all comments is what is the purpose of this change? Is
>> that for
>> better/easier debugging ? Do you think it might be worth upstreaming it ?
>>
>>
https://codereview.chromium.**org/7671034/<https://codereview.chromium.org/76...
>>
>
>

To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698