]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Eliminate false sharing in malloc due to statistic collection
authormjg <mjg@FreeBSD.org>
Sun, 23 Sep 2018 19:00:06 +0000 (19:00 +0000)
committermjg <mjg@FreeBSD.org>
Sun, 23 Sep 2018 19:00:06 +0000 (19:00 +0000)
commite3c2d3a906b1063421584e83d3d3968849b04690
tree6bbb6c8470917cc25992b5e63859a49656e30bd8
parentdb05ff408df0c1903ca106708e43db275643349d
Eliminate false sharing in malloc due to statistic collection

Currently stats are collected in a MAXCPU-sized array which is not
aligned and suffers enormous false-sharing. Fix the problem by
utilizing per-cpu allocation.

The counter(9) API is not used here as it is too incomplete and does
not provide a win over per-cpu zone sized for malloc stats struct. In
particular stats are being reported for each cpu separately by just
copying what is supposed to be an array element for given cpu.

This eliminates significant false-sharing during malloc-heavy tests
e.g. on Skylake. See the review for details.

Reviewed by: markj
Approved by: re (kib)
Differential Revision: https://reviews.freebsd.org/D17289
sys/kern/kern_malloc.c
sys/sys/malloc.h