From patchwork Wed Aug 3 10:05:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CGEL X-Patchwork-Id: 12935351 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 8EC16C19F28 for ; Wed, 3 Aug 2022 10:06:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E51C8E0001; Wed, 3 Aug 2022 06:06:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 293FC6B0072; Wed, 3 Aug 2022 06:06:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 183208E0001; Wed, 3 Aug 2022 06:06:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 077DE6B0071 for ; Wed, 3 Aug 2022 06:06:25 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D6D011C6E7C for ; Wed, 3 Aug 2022 10:06:24 +0000 (UTC) X-FDA: 79757851488.24.00DB502 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf06.hostedemail.com (Postfix) with ESMTP id 8718118003E for ; Wed, 3 Aug 2022 10:06:05 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id gj1so1136148pjb.0 for ; Wed, 03 Aug 2022 03:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=N6470V84i8r/SrAbUOMPMzFLhAwImnUfo4s3+mmJyH4=; b=gIbeBO48HczBwJi8HhEhiZlbToMlHiOOoZJ/OiW7pomV3TCRTBIJFQek8ZQfpj8bdD 6Haf2rdTJfq8QgglHWwURPMsF80Fw/7k3DdMkbG8Ul8vDmYN68blcn53jsfywQg5AhEw rVZiDEMDNxTj5ZHYNli3kUiEUXEQzk6YQYyigG80fN7BU3SOgL8dwQxupJRkyohV7Hj3 /3ipKsYLv0Ccs0xzYfsu9YuYpJC/b2kwyR7oDx6/gXzPns/LzKz/64J0hR1ZEkf7ARAE IV/f9lRsZTgtCgxrOvsHw0fTO3SfZLEUokHTjt5RIypzKt6bGmoPYi6bGNIrgRZ6W7BH H2OQ== 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; bh=N6470V84i8r/SrAbUOMPMzFLhAwImnUfo4s3+mmJyH4=; b=SseSl5r+lQI+cPoAfFoFhOVjXFjpFEaP1Ci4CXOqBcGCJDhEq3CUznS4+2oNQpjiRc 7W/kQ8qMzs/A0rqdvdmGffKgEiLd8bjbf7t599X6EdtjZb9/h718hSlKmpFr1trinABz eUQCsEA4hgpMhR/ZIS7FZO2UZAhTNOu9Lka2t5GcUJCmoWh4qw5ZSHvgtsqNWfXQOcyD 0ZqE44+D8tgyQ1iD+5THx5+bmGC6Oq2STRcP3UAcIMbWwoT7yfFqxJw88DJCKm47HLNH wMrQFLm64ykoDD7RCn0upBBOc+moXEavaigif9/tsjdqUgkX7Wv6VfqS2IhFpLBfic56 M+zg== X-Gm-Message-State: ACgBeo0+f9Ao3Qna5Cqhkfk6aUKUc4+QKVJ8J4EDdSnHnguvXdkSikK7 DcJklyOl/4kcAtraBwfD8Ag= X-Google-Smtp-Source: AA6agR6ATn+tw5xU/Xs1DoivKBqKZJJ2fvM7DM7gwnYkVkEDKR9V5dy4GqCzUk4ZFQmpDss/ft05zg== X-Received: by 2002:a17:90b:4d07:b0:1ef:521c:f051 with SMTP id mw7-20020a17090b4d0700b001ef521cf051mr4171718pjb.164.1659521164547; Wed, 03 Aug 2022 03:06:04 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id h3-20020a63df43000000b00416018b5bbbsm10809337pgj.76.2022.08.03.03.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Aug 2022 03:06:04 -0700 (PDT) From: cgel.zte@gmail.com X-Google-Original-From: xu.xin16@zte.con.cn To: akpm@linux-foundation.org Cc: hughd@google.com, izik.eidus@ravellosystems.com, willy@infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, xu xin , CGEL Subject: [RFC PATCH 4/4] ksm: show ksmd status of auto mode Date: Wed, 3 Aug 2022 10:05:59 +0000 Message-Id: <20220803100559.1653604-1-xu.xin16@zte.con.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803100306.1653382-1-xu.xin16@zte.con.cn> References: <20220803100306.1653382-1-xu.xin16@zte.con.cn> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: byisfftawrumq9ip5t9zpfhbkfjz1xop X-Rspamd-Queue-Id: 8718118003E Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gIbeBO48; spf=temperror (imf06.hostedemail.com: error in processing during lookup of cgel.zte@gmail.com: DNS error) smtp.mailfrom=cgel.zte@gmail.com; dmarc=temperror reason="query timed out" header.from=gmail.com (policy=temperror) X-Rspamd-Server: rspam02 X-HE-Tag: 1659521165-63519 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: From: xu xin Add a sysfs interface of ksmd_status to show some details related with auto-mode. Signed-off-by: xu xin Signed-off-by: CGEL --- mm/ksm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mm/ksm.c b/mm/ksm.c index 78819b56efec..6417bc034a3d 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -3070,6 +3070,29 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr, } KSM_ATTR(run); +static ssize_t ksmd_status_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + int len = 0; + + if (ksm_run & KSM_RUN_AUTO) { + len += sysfs_emit_at(buf, len, "mode: auto\n"); + len += sysfs_emit_at(buf, len, "auto_triggered %d\n", + auto_triggered); + len += sysfs_emit_at(buf, len, "scanning_factor: %u\n", + scanning_factor); + } else if (ksm_run & KSM_RUN_MERGE) + len += sysfs_emit_at(buf, len, "mode: on\n"); + else if (ksm_run & KSM_RUN_UNMERGE) + len += sysfs_emit_at(buf, len, "mode: unmerge\n"); + else + len += sysfs_emit_at(buf, len, "mode: off\n"); + + + return len; +} +KSM_ATTR_RO(ksmd_status); + static ssize_t max_scanning_factor_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -3332,6 +3355,7 @@ static struct attribute *ksm_attrs[] = { &sleep_millisecs_attr.attr, &pages_to_scan_attr.attr, &run_attr.attr, + &ksmd_status_attr.attr, &max_scanning_factor_attr.attr, &auto_threshold_percent_attr.attr, &pages_shared_attr.attr,