From mboxrd@z Thu Jan 1 00:00:00 1970 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 29861C4167B for ; Mon, 4 Dec 2023 18:44:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A173E6B02E4; Mon, 4 Dec 2023 13:44:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C6256B02E6; Mon, 4 Dec 2023 13:44:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 840A36B02E7; Mon, 4 Dec 2023 13:44:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6E2C76B02E4 for ; Mon, 4 Dec 2023 13:44:37 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3B79EA02D8 for ; Mon, 4 Dec 2023 18:44:37 +0000 (UTC) X-FDA: 81530011794.14.99DC58F Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf10.hostedemail.com (Postfix) with ESMTP id 15627C0025 for ; Mon, 4 Dec 2023 18:44:34 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=devkernel.io header.s=fm2 header.b=R5CVCQth; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=JmnLIIy6; spf=pass (imf10.hostedemail.com: domain of shr@devkernel.io designates 66.111.4.26 as permitted sender) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701715475; a=rsa-sha256; cv=none; b=OqCMeMFLGuP+fQpfJ4f8WvqrbAvUPWk4Rc2chzJjXM8QAIfKgZPxM9wuVnFraFZsNjazV0 vo1Oiwh3Frj1yR6z2Hb+iewSsH15iOwatdIhk8ESwym2JhZ4ocri6osRIiszXIPRH3cDdJ THIvcDJJLAJHL8oRtKxPk4/Gm5kOVGA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=devkernel.io header.s=fm2 header.b=R5CVCQth; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=JmnLIIy6; spf=pass (imf10.hostedemail.com: domain of shr@devkernel.io designates 66.111.4.26 as permitted sender) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701715475; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/8+124M5wIy87HPWZG9mXZq93YLN1UZHX1YC4qqLEN4=; b=DhVeOPCAEdrg3F3O2578PAp+QfHqUyVtxu+7S7hU2I+EZcrjRnQgVyM+ZoZ0Q6g+XFx+q2 AdOPOv8KrG7uAEt9nS6vXL2tVJo+hH7pcMhXcLBoxNDULgkUkHjXT4ENqZsqAkzb9Xgm7W jsTLsEd84oXJJGrWNwD3SyWC7Cviob4= Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5743D5C0100; Mon, 4 Dec 2023 13:44:34 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 04 Dec 2023 13:44:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devkernel.io; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1701715474; x=1701801874; bh=/8 +124M5wIy87HPWZG9mXZq93YLN1UZHX1YC4qqLEN4=; b=R5CVCQthhs7inpZTsq qDdPsr8n3eGm+zJKw/9XczmGzDIDP6ug6+UqGALd0qSgInXntyrLK3k9ZJ9Sng9e f4shpg5EWn0D4yDXnKdYfcDpf4jTz/hHcV0GEMw27FMHsWfhrHPHIhbL8WS/qzWG fsTWY5G2PWxcuFxoGPaxdCasGM8Pjd86PykJXYQR5iFEa+GqytiR/ijRSaEn64wS s94LQ+ufwZK9EQ/+I0+EGmPRoYkv4gzeTvcwjsEjXouRS8b1ylREsXaU8vKAoEN7 6rMIlS5lo+JQE7MaWfTjmtTE++MyUkMvTAamtB5p4LdzvcnzI94N9pdTVTnFVgko VF0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1701715474; x=1701801874; bh=/8+124M5wIy87 HPWZG9mXZq93YLN1UZHX1YC4qqLEN4=; b=JmnLIIy67RqJwTQ8XnhFq+ajEK5b/ E15vYWUjvwtS5YdFfU4oSgIG6gMF5RP6/tpfK8wG/22ZzFJdJGG9Bzj7j8zbOGdt HJ8qwyUvVz8DjwsKptl3SiOiK6yC1gKZBhOp6upsPZDrNzxDSDWev4tCWoUvNMG4 zVvM42YR0LuoOPlEWsQO3N3vRRJqEQK/yv1Qjoxmdhz3dmP3ZL7ufp+jh9yZdM6e ZO5VsWAd3SIiAcF03Wf++J6cwsLawTUYtiuBIck+zS+m571EpFGOkKsfJbJGZBhj DysSkHgzvYjJrMvHY8FwSKErAi1J/yE+i5R0XvshYoa9P6MoAN1ncKgFg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudejiedguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvfevufffjgfkgggtsehttdertddtredtnecuhfhrohhmpefuthgv fhgrnhcutfhovghstghhuceoshhhrhesuggvvhhkvghrnhgvlhdrihhoqeenucggtffrrg htthgvrhhnpeeijeetleeujeeuffduffekhfdvtedtjefffeehveeijeejhfdtfeffgeej vdehfeenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepshhhrhesuggvvhhkvghrnhgvlhdrihho X-ME-Proxy: Feedback-ID: i84614614:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 4 Dec 2023 13:44:31 -0500 (EST) References: <20231201210930.2651725-1-shr@devkernel.io> <20231201210930.2651725-3-shr@devkernel.io> <20231204103950.GA22019@pevik> User-agent: mu4e 1.10.3; emacs 29.1 From: Stefan Roesch To: Petr Vorel Cc: kernel-team@fb.com, david@redhat.com, oliver.sang@intel.com, linux-mm@kvack.org, ltp@lists.linux.it, liwang@redhat.com Subject: Re: [PATCH v2 2/2] add ksm test for smart-scan feature Date: Mon, 04 Dec 2023 10:42:28 -0800 In-reply-to: <20231204103950.GA22019@pevik> Message-ID: <87sf4hrenm.fsf@devkernel.io> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 15627C0025 X-Stat-Signature: hrtma5fo33135wb3xkiueaz6trqgroe5 X-Rspam-User: X-HE-Tag: 1701715474-647056 X-HE-Meta: U2FsdGVkX18gE+foh9wFTssg0C7kZ27R+rI2pSKXUkW2tRdVcsr7ZZrIpLjEhI66bKL0rSFlpW+DjyHhLuimvXyWmkcTKOknOhacqBdoW8qTdmJhCaijxjGBlHWuyGW/oSyM5x6mTX0ErcdLdkuUn9ua1oOT3XDd2XOuRE7Rm91NvjPJsUXhbMxbV6kVE7Zmiczp1ALmz1D1gb09dLib2dCRdV8FT/zy4mHFKBtUcQ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=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Petr Vorel writes: > Hi Stefan, > > ... >> +++ b/testcases/kernel/mem/ksm/ksm07.c >> @@ -0,0 +1,69 @@ >> +/* >> + * Copyright (C) 2010-2017 Red Hat, Inc. >> + * > >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License as published by >> + * the Free Software Foundation; either version 2 of the License, or >> + * (at your option) any later version. >> + * >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See >> + * the GNU General Public License for more details. > NOTE: we use SPDX instead of verbose GPL (see ksm06.c). >> + * > > NOTE: we have special doc format which starts like this (see ksm06.c): > /*\ > * [Description] > * > * ... >> + * Kernel Samepage Merging (KSM) >> + * >> + * This adds a new ksm (kernel samepage merging) test to evaluate the new >> + * smart scan feature. It allocates a page and fills it with 'a' >> + * characters. It captures the pages_skipped counter, waits for a few >> + * iterations and captures the pages_skipped counter again. The expectation >> + * is that over 50% of the page scans are skipped (There is only one page >> + * that has KSM enabled and it gets scanned during each iteration and it >> + * cannot be de-duplicated). >> + * >> + * Prerequisites: >> + * >> + * 1) ksm and ksmtuned daemons need to be disabled. Otherwise, it could >> + * distrub the testing as they also change some ksm tunables depends >> + * on current workloads. > Hm, we don't have to any helper in LTP API to detect this, so at least we > document this. >> + * >> + */ > > The result is then uploaded: > https://github.com/linux-test-project/ltp/releases/download/20230929/metadata.20230929.html > > Therefore please use: > > // SPDX-License-Identifier: GPL-2.0-or-later > /* > * Copyright (C) 2010-2017 Red Hat, Inc. > */ > /*\ > * [Description] > * > * Kernel Samepage Merging (KSM) > * > * This adds a new ksm (kernel samepage merging) test to evaluate the new > * smart scan feature. It allocates a page and fills it with 'a' > * characters. It captures the pages_skipped counter, waits for a few > * iterations and captures the pages_skipped counter again. The expectation > * is that over 50% of the page scans are skipped (There is only one page > * that has KSM enabled and it gets scanned during each iteration and it > * cannot be de-duplicated). > * > * Prerequisites: > * > * 1) ksm and ksmtuned daemons need to be disabled. Otherwise, it could > * distrub the testing as they also change some ksm tunables depends > * on current workloads. > */ > The next version will use the above comment as documentation. >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include "../include/mem.h" >> +#include "ksm_common.h" >> + >> +static void verify_ksm(void) >> +{ >> + create_memory_for_smartscan(); > I wonder, if we reusable create_memory_for_smartscan() later. Maybe it should be > put into ksm07 for the start. > I moved it over to ksm07.c and renamed it to create_memory. > Also, the test needs to run on older kernel - exit with TCONF (which is not > considered as a failure) instead of TBROK which does now: > mem.c:488: TBROK: Failed to open FILE '/sys/kernel/mm/ksm/pages_skipped' for reading: ENOENT (2) > Changed it to TCONF. > If the testing code stays in testcases/kernel/mem/lib/mem.c, you will have to > stat() it. But if it's really just this test specific and you move it to > ksm07.c, then you can simply add the handling via .save_restore. > >> +} >> + >> +static struct tst_test test = { >> + .needs_root = 1, >> + .forks_child = 1, >> + .options = (struct tst_option[]) { >> + {} >> + }, >> + .save_restore = (const struct tst_path_val[]) { >> + {"/sys/kernel/mm/ksm/run", NULL, TST_SR_TBROK}, >> + {"/sys/kernel/mm/ksm/sleep_millisecs", NULL, TST_SR_TBROK}, >> + {"/sys/kernel/mm/ksm/smart_scan", "1", >> + TST_SR_SKIP_MISSING | TST_SR_TBROK_RO}, >> + {} >> + }, >> + .needs_kconfigs = (const char *const[]){ >> + "CONFIG_KSM=y", >> + NULL >> + }, >> + .test_all = verify_ksm, >> +}; > > Also, there are missing static: > These are declared as non-static in ksm_common.h. > $ cd testcases/kernel/mem/ksm/; make check-ksm07 > CHECK testcases/kernel/mem/ksm/ksm07.c > ksm07.c:1: WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 > make: [../../../../include/mk/rules.mk:56: check-ksm07] Error 1 (ignored) > ksm07.c: note: in included file: > ksm_common.h:14:5: warning: Symbol 'size' has no prototype or library ('tst_') prefix. Should it be static? > ksm_common.h:14:29: warning: Symbol 'num' has no prototype or library ('tst_') prefix. Should it be static? > ksm_common.h:14:38: warning: Symbol 'unit' has no prototype or library ('tst_') prefix. Should it be static? > ksm_common.h:15:6: warning: Symbol 'opt_sizestr' has no prototype or library > ('tst_') prefix. Should it be static? > ksm_common.h:15:20: warning: Symbol 'opt_numstr' has no prototype or library > ('tst_') prefix. Should it be static? > ksm_common.h:15:33: warning: Symbol 'opt_unitstr' has no prototype or library > ('tst_') prefix. Should it be static? > > Kind regards, > Petr