Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp199013rdb; Mon, 18 Sep 2023 12:11:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9DxSj82fkLkdnmkZlZJ0+BND9yXvt5tmaEr7ySVaQhl+Drw72iMXCK94pJQ7IGXu1KCMe X-Received: by 2002:a17:90a:bf90:b0:26d:2b86:dbe1 with SMTP id d16-20020a17090abf9000b0026d2b86dbe1mr7352703pjs.25.1695064270166; Mon, 18 Sep 2023 12:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695064270; cv=none; d=google.com; s=arc-20160816; b=gg8jAs7uZk+vEk5xnQ+jf9GyWZ+eQKseEus+3m4XdpoPqGCo6+qDW0ZZze/A3TPLJo enmroT/CEvjF1aOcSfEqClw5BMZKd71x5tjKg57TZniph4Ho5lUa+uxWhVOvV22JvBIg iYTOo89lOlCti7ncGZ+c1c/ihxH0XUZfCRU4V+yP8thqUBM+wAAsrexK7N/nC00AF49O apJDtVRQk9e7bEHe7QQoKHBbgXir6CLlWp9qmEVngMctw061Lcj6qR53In66dOgx3cwY WWF+U0bc7I6I43KkH+eF//dkee0fFyFGK6JT2AQthMGexXLFLOu4qMLODMlYjfjFdqAJ 1UVA== 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=awJU8GMl6Va3wNMo4dFdW3id0t0DydghBy65nawHNHc=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=DoPeXRm2qlpeAg2HmXSrM/ejRb3ELpF4G0Qk3xPowrMHuDJ16WF4c4OOT1f7bftC24 yc0XwDtFiWONlW11Cv4sguL5j1zHIzkgQ5iz1DBdxSjoahmjC6rVV1uIZlsOU4wyU4YP NbqAaU4xorQg0mha5GXKCbrqpZpW61k7P/vPFkvBAcwVAAOViv1M7ZGSFC65mCbTTp+N 8youETBYUvn6w5rWTs7XW6oWJz+1y4xFaDikv1pKSsWeDALpV1Ab04a5S1fKBozRnrsK ev/VnJ51H1i1+ZoozSPyi7oKgcqJ3q/LZv87JmHRLgHrba4489z3BJh/oAbhhKc7zMLN U2YA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s9-20020a17090aad8900b00268414272d1si8563322pjq.156.2023.09.18.12.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 12:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id F351980BF1B7; Mon, 18 Sep 2023 11:59:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbjIRS6w (ORCPT + 99 others); Mon, 18 Sep 2023 14:58:52 -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 S229771AbjIRS6n (ORCPT ); Mon, 18 Sep 2023 14:58:43 -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 AE087121 for ; Mon, 18 Sep 2023 11:58:37 -0700 (PDT) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 2B029C25F828; Mon, 18 Sep 2023 11:58:22 -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 v2 2/4] mm/ksm: add pages_skipped metric Date: Mon, 18 Sep 2023 11:58:14 -0700 Message-Id: <20230918185816.1518366-3-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230918185816.1518366-1-shr@devkernel.io> References: <20230918185816.1518366-1-shr@devkernel.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 fry.vger.email 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 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 11:59:14 -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 7a1aa3872cf4..7fbf22814c8d 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; @@ -2378,6 +2381,7 @@ static bool should_skip_rmap_item(struct page *page= , * Skip the page and calculate skip_age on when to re-enable scanning * for this page. */ + ++ksm_pages_skipped; if (rmap_item->skip_age =3D=3D 0) { rmap_item->skip_age =3D (age + skip_age(age)) & 0xFF; remove_rmap_item_from_tree(rmap_item); @@ -3468,6 +3472,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) { @@ -3565,6 +3576,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