Files
linux_media/include/linux
Roman Gushchin 2e9bd48315 mm: memcg/slab: pre-allocate obj_cgroups for slab caches with SLAB_ACCOUNT
In general it's unknown in advance if a slab page will contain accounted
objects or not.  In order to avoid memory waste, an obj_cgroup vector is
allocated dynamically when a need to account of a new object arises.  Such
approach is memory efficient, but requires an expensive cmpxchg() to set
up the memcg/objcgs pointer, because an allocation can race with a
different allocation on another cpu.

But in some common cases it's known for sure that a slab page will contain
accounted objects: if the page belongs to a slab cache with a SLAB_ACCOUNT
flag set.  It includes such popular objects like vm_area_struct, anon_vma,
task_struct, etc.

In such cases we can pre-allocate the objcgs vector and simple assign it
to the page without any atomic operations, because at this early stage the
page is not visible to anyone else.

A very simplistic benchmark (allocating 10000000 64-bytes objects in a
row) shows ~15% win.  In the real life it seems that most workloads are
not very sensitive to the speed of (accounted) slab allocations.

[guro@fb.com: open-code set_page_objcgs() and add some comments, by Johannes]
  Link: https://lkml.kernel.org/r/20201113001926.GA2934489@carbon.dhcp.thefacebook.com
[akpm@linux-foundation.org: fix it for mm-slub-call-account_slab_page-after-slab-page-initialization-fix.patch]

Link: https://lkml.kernel.org/r/20201110195753.530157-2-guro@fb.com
Signed-off-by: Roman Gushchin <guro@fb.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Christoph Lameter <cl@linux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-02-24 13:38:29 -08:00
..
2021-02-02 00:16:57 +01:00
2021-01-23 14:57:21 +01:00
2021-01-24 14:27:17 +01:00
2021-02-17 14:07:48 +01:00
2020-12-19 11:18:38 -08:00
2021-01-21 14:06:00 -07:00
2021-01-06 16:24:59 -08:00
2021-01-16 15:12:06 -05:00
2021-01-18 14:26:51 +01:00
2021-02-08 12:28:07 +01:00
2021-02-11 13:24:44 -08:00
2021-01-14 08:21:09 -08:00
2021-01-27 12:27:36 +01:00
2020-12-15 16:19:31 +01:00
2021-01-18 16:13:51 +01:00
2020-12-15 16:19:31 +01:00
2021-02-17 14:12:42 +01:00
2021-01-21 16:16:10 +00:00
2021-02-11 10:51:56 +00:00
2021-01-22 15:09:42 +01:00
2021-01-14 11:20:17 +01:00
2021-02-08 12:28:07 +01:00
2021-01-24 14:43:45 +01:00
2021-01-04 11:42:21 -05:00
2021-01-24 14:27:20 +01:00
2021-02-02 10:26:12 +01:00
2021-02-17 13:17:49 -08:00
2021-01-21 14:06:00 -07:00
2021-02-03 19:05:50 +01:00
2021-01-24 14:27:17 +01:00
2021-01-24 14:27:20 +01:00
2020-12-15 12:13:39 -08:00
2021-01-16 23:19:26 +01:00
2021-01-28 00:35:03 +01:00
2021-01-27 09:51:49 -07:00
2021-01-06 16:24:59 -08:00
2021-02-09 12:27:29 -05:00
2021-02-13 17:17:53 +01:00
2021-01-21 16:16:10 +00:00
2021-01-18 10:52:41 +01:00
2021-01-21 14:06:00 -07:00
2021-01-24 14:27:17 +01:00
2021-02-08 22:58:55 +01:00