Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2686707rdh; Wed, 27 Sep 2023 09:37:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9KJkSO1/XKBSo26jmybHkGil3Rha8MniOQgpvhKEix+Hyg8ubjOTXSCPvvMMm6HNQGcOS X-Received: by 2002:a05:6a20:d425:b0:161:7a0c:3c37 with SMTP id il37-20020a056a20d42500b001617a0c3c37mr18853pzb.5.1695832661153; Wed, 27 Sep 2023 09:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695832661; cv=none; d=google.com; s=arc-20160816; b=dZ09IzD/iLNG5uFa5fkaoVAQjBArg6bA0znS+cOxzIEu1Nk8BoA32I8d/PEFHb+Gl8 3k6lGgWWXRwKGuB+lKr2yLZTiruIcr60IefuJZD7tXJl/VTYJ5yPbzQTvw5Dk2sXuo27 sFICCidNpGnEpStdwLRxk4CuGvIKmWnhtlVBQT2MgJoIe5vTAkstXaT910Y8y2so3zt+ gEjLG9BNO/zQ1eiWN36F1l5Dp64TNelzXuGUXzJWou9+b4q7iLHNq8XyPoORxO2hHE6y 4QJBw8MfvjkkSp050+3WXvr4rIWxpbt0v0xkDBEHizGzi7siypL2+LwoIwacWnb7lPtV tKgw== 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=1LdjbrSTW7GDbAqE3wkNtvp3gXo6eKi0BIzKiZfMuRg=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=aDfBM3jyrOb2mAI/CRaTg9x9ORcbPn1ly5R8NBeHD1OZSFiwDrK/QGf8koF4zI8G0W mNMlGYE655xReHGHvM0WKdCwYXW/77GldoE7hR+M2rjcAzgMCy2zsppcQVvFy3r0xATU htRvFYPU7ySngHjT2WH7JQGFBXucHSgCHaZjgipCtFRrGhzip9UL4PQlf90Ld/l8qeDf 2RfSZE3w8goa70KdaSyPbNRaeyHpiH8xz9zmk1i0gD1iNP0mceoOKV3VBdS2C9Q8Avlo 8ma/tq+60sBsrw72A5usep1kJkSo9PCNA2AqEEAMPnCLvMPaQ5RYcSH7ayE9Rqa3Ngmk gMlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t2-20020a1709027fc200b001b8a8f359fcsi14659042plb.208.2023.09.27.09.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 09:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id D4181809871B; Wed, 27 Sep 2023 09:23:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231708AbjI0QW4 (ORCPT + 99 others); Wed, 27 Sep 2023 12:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbjI0QWt (ORCPT ); Wed, 27 Sep 2023 12:22:49 -0400 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D4F092 for ; Wed, 27 Sep 2023 09:22:48 -0700 (PDT) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 47CAECA4DC12; Wed, 27 Sep 2023 09:22:32 -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 v4 2/4] mm/ksm: add pages_skipped metric Date: Wed, 27 Sep 2023 09:22:20 -0700 Message-Id: <20230927162222.3827551-3-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230927162222.3827551-1-shr@devkernel.io> References: <20230927162222.3827551-1-shr@devkernel.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RDNS_DYNAMIC,SPF_HELO_PASS,SPF_NEUTRAL, TVD_RCVD_IP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 27 Sep 2023 09:23:08 -0700 (PDT) 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 Reviewed-by: David Hildenbrand --- mm/ksm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/ksm.c b/mm/ksm.c index c0a2e7759365..1df25a66f162 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -293,6 +293,9 @@ static bool ksm_smart_scan =3D 1; /* 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; @@ -2376,6 +2379,7 @@ static bool should_skip_rmap_item(struct page *page= , } =20 /* Skip this page */ + ksm_pages_skipped++; rmap_item->remaining_skips--; remove_rmap_item_from_tree(rmap_item); return true; @@ -3463,6 +3467,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) { @@ -3560,6 +3571,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