From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19CA3C433EF for ; Wed, 23 Feb 2022 18:15:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 616478D0034; Wed, 23 Feb 2022 13:15:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C8658D0011; Wed, 23 Feb 2022 13:15:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48CAD8D0034; Wed, 23 Feb 2022 13:15:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 23F6F8D0011 for ; Wed, 23 Feb 2022 13:15:33 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id CA8586114E for ; Wed, 23 Feb 2022 18:15:32 +0000 (UTC) X-FDA: 79174847304.01.CD0535F Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf18.hostedemail.com (Postfix) with ESMTP id 0A4D11C000C for ; Wed, 23 Feb 2022 18:15:31 +0000 (UTC) Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1645640129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1AOaosUbQBHhRF+hiDB1Ru/k/te68hEFr5W4BMIzNlU=; b=tybNPUXvheRopnzyhVh1h+T8oil0Hf4OBSZr0t7oyP3FKU0NC5/wYUMAQO/nBbC2H7gDFs P0DNXCHr7Qd8YgIGQ8oDDG3WzOd3GqZVlePZNLnQCO9782EiKNQ0OCa459O4FJTlxjsolW iNHzep9x1rgif+QJ/IuWElkBkVhOn2w= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: slabinfo shows incorrect active_objs ??? X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin In-Reply-To: <324372c6-1d9e-cdc9-b5b3-157746da8445@suse.cz> Date: Wed, 23 Feb 2022 10:15:26 -0800 Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Vasily Averin , Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg , Linux MM , Andrew Morton , kernel@openvz.org Message-Id: <00E0172D-B737-4412-B850-E5462BD0EF2A@linux.dev> References: <324372c6-1d9e-cdc9-b5b3-157746da8445@suse.cz> To: Vlastimil Babka X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tybNPUXv; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf18.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 0A4D11C000C X-Stat-Signature: woxxwcacyqnfazxpmare613yp8sp4e8w X-HE-Tag: 1645640131-212127 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > On Feb 23, 2022, at 9:31 AM, Vlastimil Babka wrote: >=20 > =EF=BB=BFOn 2/23/22 04:45, Hyeonggon Yoo wrote: >>> On Wed, Feb 23, 2022 at 01:32:36AM +0100, Vlastimil Babka wrote: >>> Hm it would be easier just to disable merging when the precise counters a= re >>> enabled. Assume it would be a config option (possibly boot-time option w= ith >>> static keys) anyway so those who don't need them can avoid the overhead.= >>=20 >> Is it possible to accurately account objects in SLUB? I think it's not >> easy because a CPU can free objects to remote cpu's partial slabs using >> cmpxchg_double()... >=20 > AFAIU Roman's idea would be that each alloc/free would simply inc/dec an > object counter that's disconnected from physical handling of particular sl= *b > implementation. It would provide exact count of objects from the perspecti= ve > of slab users. > I assume for reduced overhead the counters would be implemented in a percp= u > fashion as e.g. vmstats. Slabinfo gathering would thus have to e.g. sum up= > those percpu counters. Right, something like this. A bigger picture here: since we=E2=80=99ve moved to a per-object accounting,= accounted allocations became a bit slower. It seems to be a non-issue in th= e real life (at least I haven=E2=80=99t seen any reports, maybe because it c= ounter-weighted by memory savings and lower fragmentation), however benchmar= ks clearly show it and it=E2=80=99s something nice to fix at some point. The= obvious solution is to maintain some sort of a per-memcg cache of pre-charg= ed objects for particularly hot slab caches. But to do this we need to under= stand dynamically which slab caches are hot (and which cgroups are using the= m). This will require a per-memcg per-slab accounting mechanism. So maybe it= will replace the drgn script in the long run. Thanks!=