Closed
Bug 1252639
Opened 9 years ago
Closed 9 years ago
Remove the shared PLArena freelist
Categories
(NSPR :: NSPR, defect)
NSPR
NSPR
Tracking
(Not tracked)
RESOLVED
FIXED
4.13
People
(Reporter: n.nethercote, Assigned: n.nethercote)
Details
Attachments
(2 files, 4 obsolete files)
9.33 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
7.44 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
plarena.c has a shared freelist for arenas. When an arena is freed via PL_ArenaRelease() or PL_FreeArenaPool() (but *not* via PL_FinishArenaPool()) it gets put on the freelist, which requires getting a lock. Subsequent arena allocations are obtained from the freelist when possible.
This adds complexity. It makes things confusing when investigating pool usage, because pools can end up with arenas larger or smaller than they're "supposed" to get. (This has tripped me up more than once.)
The freelist almost certainly doesn't help performance, but it may increase memory usage, because it's making decisions that the heap allocator is likely to do a better job at, given that heap allocator has a global view of things.
![]() |
Assignee | |
Comment 1•9 years ago
|
||
glandium: I'm not expecting you to review this until you are feeling better :)
Attachment #8725431 -
Flags: review?(mh+mozilla)
![]() |
Assignee | |
Updated•9 years ago
|
Assignee: nobody → n.nethercote
Status: NEW → ASSIGNED
![]() |
Assignee | |
Comment 2•9 years ago
|
||
Because the plarenas.h/plarena.h is strange and confusing. But the patch keeps
plarenas.h around in a way that the API doesn't change -- any code that
included plarena.h or plarenas.h should not need changing.
Attachment #8725433 -
Flags: review?(mh+mozilla)
![]() |
Assignee | |
Comment 3•9 years ago
|
||
Note to self: there are some tweaks in NSS that can be made as a result of this, such as removing NSS_DISABLE_ARENA_FREE_LIST.
Comment 4•9 years ago
|
||
Comment on attachment 8725433 [details] [diff] [review]
(part 2) - Move contents of plarenas.h into plarena.h
Review of attachment 8725433 [details] [diff] [review]:
-----------------------------------------------------------------
::: nsprpub/lib/ds/plarenas.h
@@ +5,5 @@
>
> +// PLArena-related declarations used to be split between plarenas.h and
> +// plarena.h. That split wasn't useful, so now all the declarations are in
> +// plarena.h. However, this file still exists so that any old code that
> +// includes it will still work.
You probably want to use /* */ here, we've had complaints about // comments.
![]() |
Assignee | |
Comment 5•9 years ago
|
||
Now with C-style comments only.
Attachment #8726461 -
Flags: review?(mh+mozilla)
![]() |
Assignee | |
Updated•9 years ago
|
Attachment #8725433 -
Attachment is obsolete: true
Attachment #8725433 -
Flags: review?(mh+mozilla)
Comment 6•9 years ago
|
||
Comment on attachment 8725431 [details] [diff] [review]
(part 1) - Remove the shared PLArena freelist
Review of attachment 8725431 [details] [diff] [review]:
-----------------------------------------------------------------
::: nsprpub/lib/ds/plarena.c
@@ -280,5 @@
> -#endif
> -
> - if (reallyFree) {
> - do {
> - *ap = a->next;
On the first iteration, this would do:
head->next = a->next;
effectively removing a from the linked list. Combined with the loop, all in all this means we do:
head->next = NULL;
Although the loop kinda sorta makes things a little bit safer while the loop is still running.
I don't see you doing this in the new code, effectively opening the door for use-after-free.
Attachment #8725431 -
Flags: review?(mh+mozilla) → review-
Updated•9 years ago
|
Attachment #8726461 -
Flags: review?(mh+mozilla) → review+
![]() |
Assignee | |
Comment 7•9 years ago
|
||
> I don't see you doing this in the new code, effectively opening the door for
> use-after-free.
Ugh, good catch. New patch coming shortly.
![]() |
Assignee | |
Comment 8•9 years ago
|
||
This version explicitly nulls head->next before the loop in FreeArenaList().
Attachment #8727198 -
Flags: review?(mh+mozilla)
![]() |
Assignee | |
Updated•9 years ago
|
Attachment #8725431 -
Attachment is obsolete: true
Updated•9 years ago
|
Attachment #8727198 -
Flags: review?(mh+mozilla) → review+
![]() |
Assignee | |
Comment 9•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/c661f2c5cd878c26e25abc0256b4893d8a249b49
Bug 1252639 (part 1) - Remove the shared PLArena freelist. r=glandium.
https://hg.mozilla.org/integration/mozilla-inbound/rev/bf22fcece06e85cd195d61e37382ffc0084e4d05
Bug 1252639 (part 2) - Move contents of plarenas.h into plarena.h. r=glandium.
![]() |
||
Comment 10•9 years ago
|
||
(In reply to Nicholas Nethercote [:njn] from comment #9)
> https://hg.mozilla.org/integration/mozilla-inbound/rev/
> c661f2c5cd878c26e25abc0256b4893d8a249b49
> Bug 1252639 (part 1) - Remove the shared PLArena freelist. r=glandium.
>
> https://hg.mozilla.org/integration/mozilla-inbound/rev/
> bf22fcece06e85cd195d61e37382ffc0084e4d05
> Bug 1252639 (part 2) - Move contents of plarenas.h into plarena.h.
> r=glandium.
Shouldn't this have landed upstream at https://hg.mozilla.org/projects/nspr first?
Flags: needinfo?(n.nethercote)
![]() |
Assignee | |
Comment 11•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/ce12c108f9c4294c51ccb9df1a1b6b124e1ce003
Backout c661f2c5cd87 and bf22fcece06e (from bug 1252639) because NSPR changes aren't supposed to land on mozilla-inbound.
![]() |
Assignee | |
Comment 12•9 years ago
|
||
> Shouldn't this have landed upstream at https://hg.mozilla.org/projects/nspr
> first?
Sorry, yes. My mistake. I've backed it out and I will land to the NSPR repo instead.
Flags: needinfo?(n.nethercote)
![]() |
Assignee | |
Comment 13•9 years ago
|
||
> I will land to the NSPR repo instead.
Except I don't have permission to push to the NSPR repo! Argh.
![]() |
Assignee | |
Comment 14•9 years ago
|
||
![]() |
Assignee | |
Comment 15•9 years ago
|
||
![]() |
Assignee | |
Updated•9 years ago
|
Attachment #8726461 -
Attachment is obsolete: true
![]() |
Assignee | |
Updated•9 years ago
|
Attachment #8727198 -
Attachment is obsolete: true
![]() |
Assignee | |
Updated•9 years ago
|
Attachment #8728801 -
Flags: review+
![]() |
Assignee | |
Updated•9 years ago
|
Attachment #8728802 -
Flags: review+
![]() |
Assignee | |
Comment 16•9 years ago
|
||
ted: I've updated the patches so they apply cleanly to the NSPR repo, and carried over glandium's r+s. I don't have permission to push patches to NSPR. Could you please do it for me?
Flags: needinfo?(ted)
Comment 17•9 years ago
|
||
https://hg.mozilla.org/projects/nspr/rev/936da2a62c9949b033682df5086a22fbf6e68172
Bug 1252639 (part 1) - Remove the shared PLArena freelist. r=glandium.
https://hg.mozilla.org/projects/nspr/rev/a738c6ec6475537abc88f94478c677c8fe6d5b81
Bug 1252639 (part 2) - Move contents of plarenas.h into plarena.h. r=glandium.
Comment 18•9 years ago
|
||
FYI, I am amenable to simultaneous landing of patches to mozilla-central and NSPR, as long as you've done something to ensure someone will land them in the NSPR repo (your needinfo? here was perfect). Also I should find out if glandium has the right bits set to push to the nspr repo, what with him being a peer. :)
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Flags: needinfo?(ted)
Resolution: --- → FIXED
![]() |
Assignee | |
Comment 19•9 years ago
|
||
I'm happy to wait for the next NSPR merge. Thank you for landing the patches.
Updated•8 years ago
|
Target Milestone: --- → 4.13
You need to log in
before you can comment on or make changes to this bug.
Description
•