@@ -1633,20 +1633,12 @@ runtime·gchelper(void)
1633
1633
// extra memory used).
1634
1634
static int32 gcpercent = GcpercentUnknown ;
1635
1635
1636
- static void
1637
- stealcache (void )
1638
- {
1639
- M * mp ;
1640
-
1641
- for (mp = runtime·allm ; mp ; mp = mp -> alllink )
1642
- runtime·MCache_ReleaseAll (mp -> mcache );
1643
- }
1644
-
1645
1636
static void
1646
1637
cachestats (GCStats * stats )
1647
1638
{
1648
1639
M * mp ;
1649
1640
MCache * c ;
1641
+ P * p , * * pp ;
1650
1642
int32 i ;
1651
1643
uint64 stacks_inuse ;
1652
1644
uint64 * src , * dst ;
@@ -1655,8 +1647,6 @@ cachestats(GCStats *stats)
1655
1647
runtime·memclr ((byte * )stats , sizeof (* stats ));
1656
1648
stacks_inuse = 0 ;
1657
1649
for (mp = runtime·allm ; mp ; mp = mp -> alllink ) {
1658
- c = mp -> mcache ;
1659
- runtime·purgecachedstats (c );
1660
1650
stacks_inuse += mp -> stackinuse * FixedStack ;
1661
1651
if (stats ) {
1662
1652
src = (uint64 * )& mp -> gcstats ;
@@ -1665,6 +1655,12 @@ cachestats(GCStats *stats)
1665
1655
dst [i ] += src [i ];
1666
1656
runtime·memclr ((byte * )& mp -> gcstats , sizeof (mp -> gcstats ));
1667
1657
}
1658
+ }
1659
+ for (pp = runtime·allp ; p = * pp ; pp ++ ) {
1660
+ c = p -> mcache ;
1661
+ if (c == nil )
1662
+ continue ;
1663
+ runtime·purgecachedstats (c );
1668
1664
for (i = 0 ; i < nelem (c -> local_by_size ); i ++ ) {
1669
1665
mstats .by_size [i ].nmalloc += c -> local_by_size [i ].nmalloc ;
1670
1666
c -> local_by_size [i ].nmalloc = 0 ;
@@ -1819,12 +1815,11 @@ gc(struct gc_args *args)
1819
1815
runtime·parfordo (work .sweepfor );
1820
1816
t3 = runtime·nanotime ();
1821
1817
1822
- stealcache ();
1823
- cachestats (& stats );
1824
-
1825
1818
if (work .nproc > 1 )
1826
1819
runtime·notesleep (& work .alldone );
1827
1820
1821
+ cachestats (& stats );
1822
+
1828
1823
stats .nprocyield += work .sweepfor -> nprocyield ;
1829
1824
stats .nosyield += work .sweepfor -> nosyield ;
1830
1825
stats .nsleep += work .sweepfor -> nsleep ;
0 commit comments