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 7D52DC433EF for ; Tue, 22 Feb 2022 11:10:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98C1B8D0002; Tue, 22 Feb 2022 06:10:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 93C0D8D0001; Tue, 22 Feb 2022 06:10:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DDD98D0002; Tue, 22 Feb 2022 06:10:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 6F1938D0001 for ; Tue, 22 Feb 2022 06:10:56 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3288A20920 for ; Tue, 22 Feb 2022 11:10:56 +0000 (UTC) X-FDA: 79170148512.01.B7067D9 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf27.hostedemail.com (Postfix) with ESMTP id 8DA9A4000B for ; Tue, 22 Feb 2022 11:10:55 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id ED6DC210EA; Tue, 22 Feb 2022 11:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1645528253; h=from:from:reply-to: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=GdkWCPPNK6YCJrxXkexY9Haf0EM2VcVNHJBatZvbDzI=; b=eOO7Oejuy/PvZ60VndJtdyjUkubvWstWMcKlRTZHLH0iuPY40GS4pUERJKpvRTeTE5Sm1q 2ryrpYfq2neBs7Lpp6ewZmwpKurTftW9YYkk/7ouu19lcGmO+uoaeg1SvXtovcDz51Mo+y zHGUNygxkIinyJVq5A+rwEYeLRyFbec= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1645528253; h=from:from:reply-to: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=GdkWCPPNK6YCJrxXkexY9Haf0EM2VcVNHJBatZvbDzI=; b=36/TUhYpC+Iyah6sbPfgQ0nvj75TChRtA3kN1J5cx4Er5iVgMsJQV+ETgKDvDbGK9ub5cb vKOCmCjvaK/l18Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C752113BCB; Tue, 22 Feb 2022 11:10:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Qh3bL73EFGJGFAAAMHmgww (envelope-from ); Tue, 22 Feb 2022 11:10:53 +0000 Message-ID: Date: Tue, 22 Feb 2022 12:10:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: slabinfo shows incorrect active_objs ??? Content-Language: en-US To: Vasily Averin , Linux MM , Andrew Morton , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim , Roman Gushchin Cc: kernel@openvz.org References: From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=eOO7Oeju; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="36/TUhYp"; dmarc=none; spf=pass (imf27.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8DA9A4000B X-Stat-Signature: 85n4zx17uf1fpt4ukx3n5doqpk7jn3gf X-HE-Tag: 1645528255-808414 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 2/22/22 10:22, Vasily Averin wrote: > Dear all, > > I've found that /proc/slabinfo shows inadequate numbers of in-use slab objects. > it assumes that all objects stored in cpu caches are always 100% in use. > > for example: >  slabinfo shows that all 20 objects are in use. > > [root@fc34-vvs linux]# uname -a > Linux fc34-vvs.sw.ru 5.17.0-rc3+ #42 SMP PREEMPT Mon Feb 21 20:14:54 UTC > 2022 x86_64 x86_64 x86_64 GNU/Linux > > [root@fc34-vvs linux]# cat /proc/slabinfo > slabinfo - version: 2.1 > # name            > : tunables : slabdata > > ... > kmalloc-cg-8k         20     20   8192    4    8 : tunables    0    0    0 : > slabdata      5      5      0 > > At the same time crash said that only 2 objects are in use. > > crash> kmem -s kmalloc-cg-8k > CACHE             OBJSIZE  ALLOCATED     TOTAL  SLABS  SSIZE  NAME > ffff8f4840043b00     8192          2        20      5    32k  kmalloc-cg-8k > > And this looks like true, see kmem -S output below. > > Is it a bug or perhaps a well-known feature that I missed? It's a known tradeoff. It would affect the allocation/free hot paths to account the per-cpu slabs more accurately and thus some precision of slabinfo is sacrificed. > Numbers are counted in mm/slub.c, see below, > but count_partial() doe not includes free objects of cpu caches > > Moreover adequate statistic is not showed in any other interfaces too > /sys/kerenl/slab/ read cpu slab caches but does not output these numbers. > > Thank you, >     Vasily Averin > > #ifdef CONFIG_SLUB_DEBUG > void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo) > { >         unsigned long nr_slabs = 0; >         unsigned long nr_objs = 0; >         unsigned long nr_free = 0; >         int node; >         struct kmem_cache_node *n; > >         for_each_kmem_cache_node(s, node, n) { >                 nr_slabs += node_nr_slabs(n); >                 nr_objs += node_nr_objs(n); >                 nr_free += count_partial(n, count_free); >         } > >         sinfo->active_objs = nr_objs - nr_free; >         sinfo->num_objs = nr_objs; > > > > crash> kmem -S kmalloc-cg-8k > CACHE             OBJSIZE  ALLOCATED     TOTAL  SLABS  SSIZE  NAME > ffff8f4840043b00     8192          2        20      5    32k  kmalloc-cg-8k > CPU 0 KMEM_CACHE_CPU: >   ffff8f4b58236360 > CPU 0 SLAB: >   (empty) > CPU 0 PARTIAL: >   (empty) > CPU 1 KMEM_CACHE_CPU: >   ffff8f4b58276360 > CPU 1 SLAB: >   SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE >   ffffed3f842af400  ffff8f484abd0000     0      4          1     3 >   FREE / [ALLOCATED] >    ffff8f484abd0000  (cpu 1 cache) >    ffff8f484abd2000  (cpu 1 cache) >    ffff8f484abd4000  (cpu 1 cache) >   [ffff8f484abd6000] > CPU 1 PARTIAL: >   (empty) > CPU 2 KMEM_CACHE_CPU: >   ffff8f4b582b6360 > CPU 2 SLAB: >   (empty) > CPU 2 PARTIAL: >   (empty) > CPU 3 KMEM_CACHE_CPU: >   ffff8f4b582f6360 > CPU 3 SLAB: >   SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE >   ffffed3f842ce600  ffff8f484b398000     0      4          0     4 >   FREE / [ALLOCATED] >    ffff8f484b398000  (cpu 3 cache) >    ffff8f484b39a000  (cpu 3 cache) >    ffff8f484b39c000  (cpu 3 cache) >    ffff8f484b39e000  (cpu 3 cache) > CPU 3 PARTIAL: >   (empty) > CPU 4 KMEM_CACHE_CPU: >   ffff8f4b58336360 > CPU 4 SLAB: >   SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE >   ffffed3f8418c200  ffff8f4846308000     0      4          0     4 >   FREE / [ALLOCATED] >    ffff8f4846308000  (cpu 4 cache) >    ffff8f484630a000  (cpu 4 cache) >    ffff8f484630c000  (cpu 4 cache) >    ffff8f484630e000  (cpu 4 cache) > CPU 4 PARTIAL: >   (empty) > CPU 5 KMEM_CACHE_CPU: >   ffff8f4b58376360 > CPU 5 SLAB: >   (empty) > CPU 5 PARTIAL: >   (empty) > CPU 6 KMEM_CACHE_CPU: >   ffff8f4b583b6360 > CPU 6 SLAB: >   SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE >   ffffed3f8412d000  ffff8f4844b40000     0      4          0     4 >   FREE / [ALLOCATED] >    ffff8f4844b40000  (cpu 6 cache) >    ffff8f4844b42000  (cpu 6 cache) >    ffff8f4844b44000  (cpu 6 cache) >    ffff8f4844b46000  (cpu 6 cache) > CPU 6 PARTIAL: >   (empty) > CPU 7 KMEM_CACHE_CPU: >   ffff8f4b583f6360 > CPU 7 SLAB: >   SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE >   ffffed3f84124000  ffff8f4844900000     0      4          1     3 >   FREE / [ALLOCATED] >    ffff8f4844900000  (cpu 7 cache) >    ffff8f4844902000  (cpu 7 cache) >   [ffff8f4844904000] >    ffff8f4844906000  (cpu 7 cache) > CPU 7 PARTIAL: >   (empty) > KMEM_CACHE_NODE   NODE  SLABS  PARTIAL  PER-CPU > ffff8f48400416c0     0      5        0        5 > NODE 0 PARTIAL: >   (empty) > NODE 0 FULL: >   (not tracked) > > >