From patchwork Fri Mar 3 07:31:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13158390 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 6B9E2C678D4 for ; Fri, 3 Mar 2023 07:31:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04BB86B0083; Fri, 3 Mar 2023 02:31:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F3EBC6B0085; Fri, 3 Mar 2023 02:31:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDED36B0087; Fri, 3 Mar 2023 02:31:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CF8E56B0083 for ; Fri, 3 Mar 2023 02:31:51 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 96835A1176 for ; Fri, 3 Mar 2023 07:31:51 +0000 (UTC) X-FDA: 80526767622.15.BC2B5A1 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf22.hostedemail.com (Postfix) with ESMTP id BBF09C0002 for ; Fri, 3 Mar 2023 07:31:49 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=kDqZjoYf; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf22.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.173 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677828709; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3mmQBxcW7ejWxn4u/9kaDGpuSUOVrknjbsls0Wrd7oQ=; b=TZvgyUdK5EB1UWWLsFNGyidBQwHZa/Iy11xK9+bW7+QL9JXAaz7F4g8SnlVbLdgXDpeaMZ wxJC19pZN6+7eBV6c2uAd1uIQkEB9EXl3AkWeEzGZSO8dLth+GFU1wKqcfIPxifChec7XS /nM1K1VKBuhjMweJH+PjKoOMlRf22sw= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=kDqZjoYf; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf22.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.173 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677828709; a=rsa-sha256; cv=none; b=kGKFoxFV1Zb4eX8el27oN9sJXEPsXxsreFTqhZt3kDeKZQ6kisyCaWeBVboO/TyVyvyAeL yUPr+jSxmhb1Yp74x79jPCaC6EZpYb1v3FnOdREtDEdHZ4oOMqoqFjbPjJykBjRNZYuEKE AIvCGlfIq6S6oBKKrPWG83SUeud/Ik0= Received: by mail-pg1-f173.google.com with SMTP id bn17so924784pgb.10 for ; Thu, 02 Mar 2023 23:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3mmQBxcW7ejWxn4u/9kaDGpuSUOVrknjbsls0Wrd7oQ=; b=kDqZjoYfdctRAdTqU0bk8va0TLut3cg+xNPzeKMEXmxSfnkUW0t8MPd7IZbuldVC2q FOlOZCbIVtUpKCU9LNrNP5wk0pFFIqdWENvaSq2cZ/4I5/vlAfa5bgI5MVDzHhkQ7D1+ ZvuShnw/whNxLNAM78sHeZNXh9Zc2UpXJzE58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3mmQBxcW7ejWxn4u/9kaDGpuSUOVrknjbsls0Wrd7oQ=; b=4FxpVelJ9pcsR5cifSaOqd6LrDWUkvYdLoAHZJ2n8SfwwMRKvX7GYsrUSFmnsmrGSk V+vKB8QqsUFCi3H+cqrMyN3LCpOGfGgMSsgrDm8qBQULORwr0YocF8r2yJ1Bajb0WJcs /eeE8mQwDbq1m0PriyqB6qINg7kUoFQ5HW0Q9uA9qXIq2O8TcN165YIqJuYyP4R6gK0t yMiXLxjPfuh1UtSf5gRtVyD/iynt5KjmnQ0TtFWvXl06r9s1UubdrLKa2KW7yv83CZbo 2OupeoTa8g6m+6t77M11afBHhNjYtOBmGoQ0Snp4jHeRvbb200AyXj+IqWlu6MPgUKlc q0SQ== X-Gm-Message-State: AO0yUKVSHP2mDWHUIj/fR9/RtTedqLWr/PBBSCHfe9e2RqqEWXTb3kZv 2EtwhV3046+6KC2P7BrdoDhC9tcJt7+O11YH X-Google-Smtp-Source: AK7set95IKXsbDSABhjpYLGQU6qZ7FB8tuGqKxll1zoDEf9YglRFwASYw4TOOIRNu/lNrenPkdhAzA== X-Received: by 2002:a62:7b45:0:b0:5a9:b4eb:d262 with SMTP id w66-20020a627b45000000b005a9b4ebd262mr1432036pfc.1.1677828708593; Thu, 02 Mar 2023 23:31:48 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:badf:7e3e:d3f9:4956]) by smtp.gmail.com with ESMTPSA id c18-20020aa781d2000000b005a8b4dcd21asm933439pfn.15.2023.03.02.23.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 23:31:48 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv3 4/4] zsmalloc: show per fullness group class stats Date: Fri, 3 Mar 2023 16:31:30 +0900 Message-Id: <20230303073130.1950714-5-senozhatsky@chromium.org> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog In-Reply-To: <20230303073130.1950714-1-senozhatsky@chromium.org> References: <20230303073130.1950714-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BBF09C0002 X-Stat-Signature: 3c89rwsrxic8bdywarqhh459j1etaw5u X-HE-Tag: 1677828709-503234 X-HE-Meta: U2FsdGVkX19aKuBT0lfweFckEThQH8Uk5cOgXTFE74x8QmLSOkBoeF9mddZC7DcXrvYXJmDYVmWYpk4QfYRngIArbQM8Y/ra9iHFddkTAGuQBi8el5gGNMYAKpSJ2Ihi/VLZwsjtj+b6JXJPAeC9BL8htoPYqDTgyyEyfnGC2Sit01CXNUk8X28E2ArBc4D2MEoqCmYW6HatySeg0Zzs/I15wdmmgsbhenqYhh182nQfH7Z1XRa2g2XvcX5Roeq+Ct2UMBChmahveopLJ4ljUH3hm23qZ3UGY4Xl+/ygqBisWOmzk4q0rC8NmlDakjrQkpCF34vmU0w93+Pmfb2xEJb9vp/Vr1ALEah0LIhFDSfyNSVqY9t0BqyLEiIIrIG25KBaKmZMVXSM5XFhsnslfvV9cO4AVqNHjRPzX+Kpn+3OhRZaaOARBMuq+9rjjnwnOf6TlkrmBFTpEgiHTBP2NUQ7sjVs2Kya2DVfSP9I3XzKjv2jVx/vdCzrxrDnaXOoChsTo3f5YF6XmXxpyWLR9sV6klGuMCXOToHOnY3Li1dTiShsk3I5qDGIEEumZ1GMttgBusMzVr9Pq/5B4voaOuQYZ+YvttApXZoMZeFmEUxPI4g4f9DPOc4PhO2Mx+0WpoCpgA5uSaMkiNt68UkX6LOGIfCJCEBzVU6g85fMS3rjQF7hB1C8bwWjRHoW6hSO9lGklzB7hK/x3Fd4FymRkXcXvFavHOEcVmOwnVlJAIFn2i4hjwvjp3bsSDw2IEi85RgzuqomQVqwPl+kS4kgQOxnE6rFU/4TqNf9U3JoEczdh90xRS6/Fa3DrbKHPR1o/94Q4i9rcCIG3JJY77PCeSMbiP29obPgLk2JPROZncpfXskBFu4bGHdCZLdKStj94A0CkQeCxdEPHDz2Ogj4ui151/7VMF/6yJixDraT30asjWbC4C/Q+9VABOn6fEimuzItVA0PVQGRDDnhQ6W e9DlqmRL k7w2pmLJqxJx7uR9J6zhZ+jSFm2uim0cxioAP7V2XzBfskpa1ZPfBkvALEwAqPS7bFYNM30JFZw6mGYIXC93cvd8CFMwJB3JYHMJ9Z7UUer9QGJ2S7FK3olrSIuPJsLwBpzKdoqrzA57pFZ6BTevy2kwqyfh0nwCA5IfhgRuoW3yGLVWfKmQ3hcn+Y4s54Q2pUoEMbssQow5c5LtwsHCRwiecxfoR7AP/+ZoH4hDHWdjXbxaJFkDcJlQuFYk1qJEUCR6QrvIfKCz/BuHeHKljZULCS2bWZlJs8hQY2MB2xAbIbVpTQd68BjTJ7AZFNIegQpFHB46cvxdQpjf06KLMIGhXIUL8tWnyhBiRvATXAf3Qb7+iRycDZCBtOCfhxUg6CQJi0LPI5C0El3sSy9xRlu6QTw== 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: We keep the old fullness (3/4 threshold) reporting in zs_stats_size_show(). Switch from allmost full/empty stats to fine-grained per inuse ratio (fullness group) reporting, which gives signicantly more data on classes fragmentation. Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 141a3f69b642..5ee9a76b3446 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -172,9 +172,7 @@ enum fullness_group { ZS_INUSE_RATIO_0, ZS_INUSE_RATIO_10, - /* NOTE: 5 more fullness groups here */ - ZS_INUSE_RATIO_70 = 7, - /* NOTE: 2 more fullness groups here */ + /* NOTE: 8 more fullness groups here */ ZS_INUSE_RATIO_99 = 10, ZS_INUSE_RATIO_100, NR_FULLNESS_GROUPS, @@ -625,19 +623,19 @@ static int zs_stats_size_show(struct seq_file *s, void *v) struct zs_pool *pool = s->private; struct size_class *class; int objs_per_zspage; - unsigned long class_almost_full, class_almost_empty; unsigned long obj_allocated, obj_used, pages_used, freeable; - unsigned long total_class_almost_full = 0, total_class_almost_empty = 0; unsigned long total_objs = 0, total_used_objs = 0, total_pages = 0; unsigned long total_freeable = 0; + unsigned long inuse_totals[NR_FULLNESS_GROUPS] = {0, }; + int fg; - seq_printf(s, " %5s %5s %11s %12s %13s %10s %10s %16s %8s\n", - "class", "size", "almost_full", "almost_empty", + seq_printf(s, " %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %13s %10s %10s %16s %8s\n", + "class", "size", "10%", "20%", "30%", "40%", + "50%", "60%", "70%", "80%", "90%", "99%", "100%", "obj_allocated", "obj_used", "pages_used", "pages_per_zspage", "freeable"); for (i = 0; i < ZS_SIZE_CLASSES; i++) { - int fg; class = pool->size_class[i]; @@ -646,14 +644,12 @@ static int zs_stats_size_show(struct seq_file *s, void *v) spin_lock(&pool->lock); - /* - * Replecate old behaviour for almost_full and almost_empty - * stats. - */ - for (fg = ZS_INUSE_RATIO_70; fg <= ZS_INUSE_RATIO_99; fg++) - class_almost_full = zs_stat_get(class, fg); - for (fg = ZS_INUSE_RATIO_10; fg < ZS_INUSE_RATIO_70; fg++) - class_almost_empty = zs_stat_get(class, fg); + seq_printf(s, " %5u %5u ", i, class->size); + + for (fg = ZS_INUSE_RATIO_10; fg <= ZS_INUSE_RATIO_100; fg++) { + inuse_totals[fg] += zs_stat_get(class, fg); + seq_printf(s, "%8lu ", zs_stat_get(class, fg)); + } obj_allocated = zs_stat_get(class, ZS_OBJS_ALLOCATED); obj_used = zs_stat_get(class, ZS_OBJS_INUSE); @@ -664,14 +660,10 @@ static int zs_stats_size_show(struct seq_file *s, void *v) pages_used = obj_allocated / objs_per_zspage * class->pages_per_zspage; - seq_printf(s, " %5u %5u %11lu %12lu %13lu" - " %10lu %10lu %16d %8lu\n", - i, class->size, class_almost_full, class_almost_empty, - obj_allocated, obj_used, pages_used, - class->pages_per_zspage, freeable); + seq_printf(s, "%13lu %10lu %10lu %16d %8lu\n", + obj_allocated, obj_used, pages_used, + class->pages_per_zspage, freeable); - total_class_almost_full += class_almost_full; - total_class_almost_empty += class_almost_empty; total_objs += obj_allocated; total_used_objs += obj_used; total_pages += pages_used; @@ -679,10 +671,14 @@ static int zs_stats_size_show(struct seq_file *s, void *v) } seq_puts(s, "\n"); - seq_printf(s, " %5s %5s %11lu %12lu %13lu %10lu %10lu %16s %8lu\n", - "Total", "", total_class_almost_full, - total_class_almost_empty, total_objs, - total_used_objs, total_pages, "", total_freeable); + seq_printf(s, " %5s %5s ", "Total", ""); + + for (fg = ZS_INUSE_RATIO_10; fg <= ZS_INUSE_RATIO_100; fg++) + seq_printf(s, "%8lu ", inuse_totals[fg]); + + seq_printf(s, "%13lu %10lu %10lu %16s %8lu\n", + total_objs, total_used_objs, total_pages, "", + total_freeable); return 0; }