Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1636429rdh; Mon, 25 Sep 2023 21:13:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKna3c/5qNjj0+LwQclYN8kNtCe1S6q4yS7cp1sc+BFyd+zHPC0c/HemH2QOaKe7PCMe3s X-Received: by 2002:a17:90a:a093:b0:277:3932:6b84 with SMTP id r19-20020a17090aa09300b0027739326b84mr4687313pjp.21.1695701582358; Mon, 25 Sep 2023 21:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695701582; cv=none; d=google.com; s=arc-20160816; b=1B13VougU4ZGpk1j1OPYX2eAv3lqT4L/Y9uEYZukFNWZLebFsoj22VtknfP32GXMy3 sLNmrlu5iDJNGA3SOu3Dxit71vCkg4ltN94kATXFWKL4R5799ntN66GMDXxz3fRdxVDL clVPQ3egep9yLQtgHHPUSmeQKnjLwzgfGjODm2CV9nQPMcDwx98tkM9yNBGgT5rPMMAP AuCBWFP3TnlRSUE9TERrRN7EBoZ8jAVOpYIm83ngLuvtUQkUoySpJiIsA6p6KANI/uOQ +6c+6zvybFvb4DesirVSMF6lAca/BNJgxWJdwkzG9/GtiY5zzKGsaRbdmoQcph4NA5SZ FZTg== 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=rEeKjj+nCu8+n8S1jluBJxwJZhUI2GEoXKLMBjiuJJY=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=doXza2AmwLwNPsVC0O/meg+DrKg0ep8ZJq9ZB+QeKFsQD+IadoaIb3b91x3GZ4h9YO ew4VfqCJ2hkwBJv6a2DyXKi/EnTKJxtPvs4FU0lR1ceCbuEvGzzS1Ck6lgXFrh4nmb47 BqFM+sx1haO5Dty/SYJSkBWB/MQhCRKPoG9U4uEoGaqaCfAbM2d84AVR16vok8FEwmkj E42qonmL6CoFcyMlYCuwMINYOA8cy8zMbZLB3zOOmCrneMdCvz1/hfZ/iQfy8dnKIL2g I2fea+7qn4/oZTuYwbeImPms/mnqu4YMG2MXztE7uYQigRigP+LD09qm82u6PTP5YW5P hIXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w67-20020a636246000000b0057d08dac75csi9186742pgb.517.2023.09.25.21.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 21:13:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 85ED082277B6; Mon, 25 Sep 2023 21:10:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233371AbjIZEKM (ORCPT + 99 others); Tue, 26 Sep 2023 00:10:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233231AbjIZEKF (ORCPT ); Tue, 26 Sep 2023 00:10:05 -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 385B7F2 for ; Mon, 25 Sep 2023 21:09:59 -0700 (PDT) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 82FD9C8F2446; Mon, 25 Sep 2023 21:09:44 -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 v3 2/4] mm/ksm: add pages_skipped metric Date: Mon, 25 Sep 2023 21:09:37 -0700 Message-Id: <20230926040939.516161-3-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230926040939.516161-1-shr@devkernel.io> References: <20230926040939.516161-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 (howler.vger.email [0.0.0.0]); Mon, 25 Sep 2023 21:10:25 -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 d65eb48f9a13..3de130d170b7 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; @@ -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