Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2753716rdb; Tue, 12 Sep 2023 11:00:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9Nh5NtNTkq03xXKirrBzWu4bP3KI9IoFo2+kPQauAOTI503Yeb2M+Rk4NGEBbGcgGB3Cf X-Received: by 2002:a17:90a:cc0e:b0:271:78a0:8ab2 with SMTP id b14-20020a17090acc0e00b0027178a08ab2mr3955428pju.24.1694541607674; Tue, 12 Sep 2023 11:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694541607; cv=none; d=google.com; s=arc-20160816; b=iBYvIa1a2V8HTXEtBLYCuhZoxsiSS1PF/3YipRW7Dx5ZCUC1N2LPnfNKqnjFlRnOI/ weJefR4eLeVRMz0SiMVX6vOldv8MJuW33g/hjGG4luhYdk8cZUC3xqfHM8RDjrmESGtU oqdAmWPHfYhBKuaEKP3KiZXtUc65QWtQvVV6Gmxl8oIrrw1L4tCmnybLbaifexcln/7j Ai4mbl86rkJLH1iB3a+1/4OhFP9BP1vh5OVFRvEZbfu/EscsfCgo4cRpjlytBusYyA4G MAF+W17rZhRMjkffN9Xc2a0LBQxIBX0mpJycQvJuo/JuNcwEkpXHN7dXyzU1B+t0a+k1 /r1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CN2i2K1yeQi3CVF3AoCmDBQsHD9chBIcu/eGaGP4nGc=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=HVujV3Iazp2j/zD9FIeGPkdM4FAuDwrUQYbU0LT6biee3HSRDuywjycRDxJ2IHFng8 uK2s+ZGqDfXFTaE+bpi95dC62GukL8EzMCFPkPEuwqi2ilSkQUW1ifQY8Pi/PyUf50WA 3vHJHfvPoZCJ4j6nNrBA31FaGzEVWwzpU55T+RkBMRxETFSfKsCykM9q11Paj5M5gYfd hb1Q+jYus0UnZkltgjTGio2+RCJLO2rrJ6IEGPGTmReQssDdBYMjZMzLpVrpu4mSwqhA JWYbAAj5rd3e/qw8rbcDNWWDbqcUqfty+dGv0kIOCSZ5mY7oKuPZxLv0M4esV4tHJnzp LrqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id o9-20020a634e49000000b00573f753404bsi8386570pgl.891.2023.09.12.11.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 11:00:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A48B78292A7C; Tue, 12 Sep 2023 10:54:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237441AbjILRxn (ORCPT + 99 others); Tue, 12 Sep 2023 13:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237384AbjILRxW (ORCPT ); Tue, 12 Sep 2023 13:53:22 -0400 Received: from 66-220-144-179.mail-mxout.facebook.com (66-220-144-179.mail-mxout.facebook.com [66.220.144.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0C801FE9 for ; Tue, 12 Sep 2023 10:52:54 -0700 (PDT) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 28DACBCD162C; Tue, 12 Sep 2023 10:52:38 -0700 (PDT) From: Stefan Roesch To: kernel-team@fb.com Cc: shr@devkernel.io, akpm@linux-foundation.org, david@redhat.com, hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v1 2/4] mm/ksm: add pages_skipped metric Date: Tue, 12 Sep 2023 10:52:26 -0700 Message-Id: <20230912175228.952039-3-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230912175228.952039-1-shr@devkernel.io> References: <20230912175228.952039-1-shr@devkernel.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 10:54:50 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email This change adds the "pages skipped" metric. To be able to evaluate how successful smart page scanning is, the pages skipped metric can be compared to the pages scanned metric. The pages skipped metric is a cumulative counter. The counter is stored under /sys/kernel/mm/ksm/pages_skipped. Signed-off-by: Stefan Roesch --- mm/ksm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/ksm.c b/mm/ksm.c index bfd5087c7d5a..728574a3033e 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -293,6 +293,9 @@ static bool ksm_smart_scan; /* The number of zero pages which is placed by KSM */ unsigned long ksm_zero_pages; =20 +/* The number of pages that have been skipped due to "smart scanning" */ +static unsigned long ksm_pages_skipped; + #ifdef CONFIG_NUMA /* Zeroed when merging across nodes is not allowed */ static unsigned int ksm_merge_across_nodes =3D 1; @@ -2345,6 +2348,7 @@ static bool skip_rmap_item(struct page *page, struc= t ksm_rmap_item *rmap_item) return false; } =20 + ksm_pages_skipped++; if (rmap_item->skip_age =3D=3D 0) { rmap_item->skip_age =3D age + inc_skip_age(age); remove_rmap_item_from_tree(rmap_item); @@ -3435,6 +3439,13 @@ static ssize_t pages_volatile_show(struct kobject = *kobj, } KSM_ATTR_RO(pages_volatile); =20 +static ssize_t pages_skipped_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%lu\n", ksm_pages_skipped); +} +KSM_ATTR_RO(pages_skipped); + static ssize_t ksm_zero_pages_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -3532,6 +3543,7 @@ static struct attribute *ksm_attrs[] =3D { &pages_sharing_attr.attr, &pages_unshared_attr.attr, &pages_volatile_attr.attr, + &pages_skipped_attr.attr, &ksm_zero_pages_attr.attr, &full_scans_attr.attr, #ifdef CONFIG_NUMA --=20 2.39.3