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 30A91C07E98 for ; Tue, 28 Nov 2023 10:36:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D4EE6B027A; Tue, 28 Nov 2023 05:36:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 485186B027D; Tue, 28 Nov 2023 05:36:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34CB56B0280; Tue, 28 Nov 2023 05:36:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 251B16B027A for ; Tue, 28 Nov 2023 05:36:04 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E9CE214016A for ; Tue, 28 Nov 2023 10:36:03 +0000 (UTC) X-FDA: 81507007806.27.FC9F6C6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id AA0291A001B for ; Tue, 28 Nov 2023 10:36:00 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Snt9kOOt; spf=pass (imf19.hostedemail.com: domain of liwan@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=liwan@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701167760; a=rsa-sha256; cv=none; b=dpIU/N048qmrNfqHM2dyX3oTbbeFt70dXC/sjuTWSSI5a3lWIfYx4/AUbmnkPaU/aFq2Oc 8596VaEzloLKKt+xnrzFwVOaAZTRiC/qrIVIW2UuG8ipd9RiHPsxncyhz85HAbtUvkU5wQ z8Qoi4HvPiXsjH6odaUf6/avuW0cYig= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Snt9kOOt; spf=pass (imf19.hostedemail.com: domain of liwan@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=liwan@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701167760; 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=0MGDngZLKlDsQjQrSJHak5OGWCZyvqh7MuixsAkos8I=; b=4obGySR9VM4KkY9+Za+Ds5/hnW3OF1wQR1w2BtLArIHHB3YzBwqH5lBZgZCMZ4URtOye+9 3eKmBSq1yVciDMPyJk9xtH1GOm7XWgTEc8MvaJrZFGDM8eDFw+E+VEDMxKmlZnwb4e+OT3 F2st+qhtWg0tC2C1hzb3tzVLYBJP1qo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701167759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0MGDngZLKlDsQjQrSJHak5OGWCZyvqh7MuixsAkos8I=; b=Snt9kOOtWhtIFHdXFOUQ+C6FRUes9gW8kD2rWs/lqP/oC32SEhS1HAR3rXFj3yS5YqRyQK BZFqtGCE6txZOmeCmkDL2AnyJLNY8PSEz6GFofDRb6pugTsxGyxKt7PpNZveoAu2JfrBEo rI1ID43m6QjC8c/KRvtvqZHNj8GZ6iE= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-499-OIprQQaoOcWbKReoL4WctA-1; Tue, 28 Nov 2023 05:35:58 -0500 X-MC-Unique: OIprQQaoOcWbKReoL4WctA-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-50ba80696b3so3141979e87.0 for ; Tue, 28 Nov 2023 02:35:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701167756; x=1701772556; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0MGDngZLKlDsQjQrSJHak5OGWCZyvqh7MuixsAkos8I=; b=FtiziVnUR4bE1aYI1SIQFj8iCJ8FKLDj2/S/78zKH+8qs07xa1P7s7lC8s628maad3 k+MhbZVidxLezrze+WP6KMoOp9Y0a8h0iSUux06jozJjI/nRbZwch7Y/d+N2B+OTY+RQ 2JJ3BijHXamq9dAeC0ltifz/iOqrKn+0sNOKWw/yx6CgPmHlnM8JRdVURrm0EubHep4m zCx7vNarbtv64fYP3EaHhmv8HpXk9VI2Gel4d3f/re1rQBs8LLAG/3s0k8xcJzCVA/nx 36100bzqhaW4rve4nEUrkZ2pD27pPUBibuA2T5W6+3AwZKD7gJDUP2x/HTH+Ec2+KFL3 Ui0g== X-Gm-Message-State: AOJu0YwyDVcM99bjAJAZZR6L/ezKNOaMwX23kv2f5EQ4M4ZxFJpnUIE+ uyd6Z1iKytknBHuAA1LvRtsh5eCpWBcHsDIR5GbYT0hmz9QERSN7BJHMzjNjvAgvOMxTDKmbliZ AaGoWYDDm/1ShXs0tyyd9CAbPNQg= X-Received: by 2002:a05:6512:2389:b0:506:899d:1994 with SMTP id c9-20020a056512238900b00506899d1994mr9806318lfv.52.1701167756438; Tue, 28 Nov 2023 02:35:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEocTDZwjJMWN3mQ9/kvyJs6aEp7nBueYV3BRD/eViWTB22hQLexDkGzjhI9LoYLJRr1/h0wWeR2NHOnJ/UAdk= X-Received: by 2002:a05:6512:2389:b0:506:899d:1994 with SMTP id c9-20020a056512238900b00506899d1994mr9806299lfv.52.1701167756059; Tue, 28 Nov 2023 02:35:56 -0800 (PST) MIME-Version: 1.0 References: <20231127174517.2369593-1-shr@devkernel.io> <20231128074626.GA298624@pevik> In-Reply-To: <20231128074626.GA298624@pevik> From: Li Wang Date: Tue, 28 Nov 2023 18:35:43 +0800 Message-ID: Subject: Re: [LTP] [PATCH v1] mem: disable KSM smart scan for ksm tests To: Petr Vorel Cc: Stefan Roesch , kernel-team@fb.com, linux-mm@kvack.org, david@redhat.com, oliver.sang@intel.com, ltp@lists.linux.it X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000cdb77f060b33fb92" X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: AA0291A001B X-Stat-Signature: kqr98m7tzrtaarp7jban7n9ipgsx443o X-Rspam-User: X-HE-Tag: 1701167760-566781 X-HE-Meta: U2FsdGVkX19glxt6j9rwcisHEukFeIuB9Nz+bY+1iXhhpz2cx0kUZwqeZzx3wppABXkgLFXPeoSQuSIaDRfY+EWpBi07K0/MGDuh0DYgEUtFMUx4kRLOsH+iEYgesbQF6Dq/DB5kgZf0B41AH754keBpVetzLysNeHtDAPSLUoLPnwmlhwhiAqQ19FWrtXuGjOXPrqbRF2pnpePHotiK6KAqIcIjnYOsKbm6iOko4s7h1mwzi1UqCU1MSAqVvvHOQsxHrXyL544B05wTIB5f6WJ6StDQJogrL572g8YnXEvErg1e31ZZNk9xrsMSb1fkX1CLuz8BAOk5FmMnQLgunbFpdViJtBLtqgEA5GSHBnHW97LwlvQkotASw+Hhfm471xJ4jB7ocL5/Ehw/LB2CCRN6ntwronCDTxFmuHKPF6S9rC9/WXwlEPgwVpFqBpmIzV83Fx5He80Akb+JvJ8udt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uc5TWgc42JJnekyQwyQhtAvzGFNsJdLlL5XaeZu5U2fpSQ8Va7OZCiu5Inr4W/sR1rSXICjNeVrDFY6hf8m54FuI5a X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: --000000000000cdb77f060b33fb92 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Stefan, Petr, On Tue, Nov 28, 2023 at 3:46=E2=80=AFPM Petr Vorel wrote: > Hi Stefan, > > > This disables the "smart scan" KSM feature to make sure that the volati= le > > count remains at 0. > > > Signed-off-by: Stefan Roesch > nit: you forgot 'shr@' > Signed-off-by: Stefan Roesch > > > Reported-by: kernel test robot > > Closes: > https://lore.kernel.org/oe-lkp/202311161132.13d8ce5a-oliver.sang@intel.co= m > > --- > > testcases/kernel/mem/lib/mem.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > diff --git a/testcases/kernel/mem/lib/mem.c > b/testcases/kernel/mem/lib/mem.c > > index fbfeef026..ef274a3ac 100644 > > --- a/testcases/kernel/mem/lib/mem.c > > +++ b/testcases/kernel/mem/lib/mem.c > > @@ -454,6 +454,9 @@ void create_same_memory(int size, int num, int unit= ) > > {'a', size*MB}, {'a', size*MB}, {'d', size*MB}, {'d', > size*MB}, > > }; > > > + /* Disable smart scan for correct volatile counts. */ > > + SAFE_FILE_PRINTF(PATH_KSM "smart_scan", "0"); > NOTE, this fails on the systems without /sys/kernel/mm/ksm/smart_scan: > > mem.c:458: TBROK: Failed to open FILE '/sys/kernel/mm/ksm/smart_scan' for > writing: EACCES (13) > > NOTE, we normally handle the setup like this in test setup function. > > But new API has .save_restore which is more robust for tasks like this. > It's already used in ksm01.c, you need just to add this line: > {"/sys/kernel/mm/ksm/smart_scan", "0", TST_SR_SKIP}, > I guess we need to set 'TST_SR_SKIP_MISSING | TST_SR_TBROK_RO' as the last field. Because TST_SR_SKIP will continue the test without writing '0' to the smart_scan file, that's not correct if the file exists. It will ignore a kernel bug (smart_scan can't be written) by that config. Per the Doc Petr pointed below: TST_SR_SKIP_MISSING =E2=80=93 Continue without saving the file if it does= not exist TST_SR_TBROK_RO =E2=80=93 End test with TBROK if the file is read-only TST_SR_SKIP_RO =E2=80=93 Continue without saving the file if it is read-o= nly TST_SR_SKIP =E2=80=93 Equivalent to 'TST_SR_SKIP_MISSING | TST_SR_SKIP_RO= ' > (instead of both SAFE_FILE_PRINTF) > > See: > > https://github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--res= toring-procsys-values > > I wonder if ksm01.c is the only ksm test which needs to disable this. > I think all of the ksm0*.c tests should disable it by the config. The smart_scan will impact all the tests with invoke key function create_same_memory(). > > also nit: there is a wrong indent (spaces instead of tabs), please be > consistent > with the file content. > > NOTE: while this fixes problem on 6.7.0-rc1-2.g86e46c2-default (openSUSE)= , > it does not fixes other problem on 6.5.10 on Debian (16 errors like these > below): > > mem.c:252: TFAIL: pages_shared is not 2 but 5038. > mem.c:252: TFAIL: pages_sharing is not 98302 but 593629. > mem.c:252: TFAIL: pages_volatile is not 0 but 391. > mem.c:252: TFAIL: pages_unshared is not 0 but 149157. > > I have no idea if this is a real bug which needs to be fixed or test fals= e > positive to be fixed, or whether the problem has already been fixed in > newer > kernels. > It is more like a real bug, the Debain kernel-6.5.10 does not contain this smart_scan feature. Or you may try to build the latest kernel on your platform to see if it can be reproduced as well. > > > + > > ps =3D sysconf(_SC_PAGE_SIZE); > > pages =3D MB / ps; > > > @@ -526,6 +529,7 @@ void create_same_memory(int size, int num, int unit= ) > > > tst_res(TINFO, "stop KSM."); > > SAFE_FILE_PRINTF(PATH_KSM "run", "0"); > > + SAFE_FILE_PRINTF(PATH_KSM "smart_scan", "1"); > nit: Again, wrong indent. You could have seen it also in the generated > patch. > > Kind regards, > Petr > > > final_group_check(0, 0, 0, 0, 0, 0, size * pages * num); > > > while (waitpid(-1, &status, 0) > 0) > > > base-commit: 8c89ef3d451087ed6e18750bd5eedd10e5ab3d2e > > One more comment not related to this patch: @Stefan, do you have a test (or plan to) verify the 'smart_scan' feture works? As we do disables it for all ksm* tests in LTP, so, it would be great to have one for testing in enable mode. What do you think? --=20 Regards, Li Wang --000000000000cdb77f060b33fb92 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Stefan, Petr,

On Tue, Nov 28, 2023 at 3:46=E2=80=AFPM= Petr Vorel <pvorel@= suse.cz> wrote:
Hi Stefan,

> This disables the "smart scan" KSM feature to make sure that= the volatile
> count remains at 0.

> Signed-off-by: Stefan Roesch <devkernel.io>
nit: you forgot 'shr@'
Signed-off-by: Stefan Roesch <shr@devkernel.io>

> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.= kernel.org/oe-lkp/202311161132.13d8ce5a-oliver.sang@intel.com
> ---
>=C2=A0 testcases/kernel/mem/lib/mem.c | 4 ++++
>=C2=A0 1 file changed, 4 insertions(+)

> diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib= /mem.c
> index fbfeef026..ef274a3ac 100644
> --- a/testcases/kernel/mem/lib/mem.c
> +++ b/testcases/kernel/mem/lib/mem.c
> @@ -454,6 +454,9 @@ void create_same_memory(int size, int num, int uni= t)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {'a', size*MB}= , {'a', size*MB}, {'d', size*MB}, {'d', size*MB}, >=C2=A0 =C2=A0 =C2=A0 =C2=A0};

> +=C2=A0 /* Disable smart scan for correct volatile counts. */
> +=C2=A0 SAFE_FILE_PRINTF(PATH_KSM "smart_scan", "0"= ;);
NOTE, this fails on the systems without /sys/kernel/mm/ksm/smart_scan:

mem.c:458: TBROK: Failed to open FILE '/sys/kernel/mm/ksm/smart_scan= 9; for writing: EACCES (13)

NOTE, we normally handle the setup like this in test setup function.

But new API has .save_restore which is more robust for tasks=C2=A0 like thi= s.
It's already used in ksm01.c, you need just to add this line:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {"/sys/kernel/mm/ksm/smart_scan", &qu= ot;0", TST_SR_SKIP},

I guess we need to set 'TST_S= R_SKIP_MISSING | TST_SR_TBROK_RO'
as the last field. Because TST_SR_SKIP will continue= the test without
writing '0' to the smart_scan file, that's not correct if th= e file exists. It will
ignore a kernel bug (smart_scan can't be written) by that=C2=A0= config.
Per the Doc P= etr pointed below:
=C2=A0=C2=A0TST_SR_SKIP_MISSING =E2=80=93 Continue without savi= ng the file if it does not exist
=C2=A0=C2=A0TST_SR_TBROK_RO =E2=80=93 End te= st with TBROK if the file is read-only
=C2=A0=C2=A0TST_SR_SKIP_RO =E2=80=93 C= ontinue without saving the file if it is read-only
=C2=A0=C2=A0TST_SR_SKIP =E2= =80=93 Equivalent to 'TST_SR_SKIP_MISSING | TST_SR_SKIP_RO'



(instead of both SAFE_FILE_PRINTF)

See:
https:= //github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--restoring-p= rocsys-values

I wonder if ksm01.c is the only ksm test which needs to disable this.

I think all of the ksm0*.c tests should disable it by the config= . The smart_scan
will impact all the tests with invoke key function create_same_= memory().

<= /div>
=C2=A0

also nit: there is a wrong indent (spaces instead of tabs), please be consi= stent
with the file content.

NOTE: while this fixes problem on 6.7.0-rc1-2.g86e46c2-default (openSUSE),<= br> it does not fixes other problem on 6.5.10 on Debian (16 errors like these b= elow):

mem.c:252: TFAIL: pages_shared is not 2 but 5038.
mem.c:252: TFAIL: pages_sharing is not 98302 but 593629.
mem.c:252: TFAIL: pages_volatile is not 0 but 391.
mem.c:252: TFAIL: pages_unshared is not 0 but 149157.

I have no idea if this is a real bug which needs to be fixed or test false<= br> positive to be fixed, or whether the problem has already been fixed in newe= r
kernels.

It is more like a real bug, the Debain kernel-6.5.= 10 does not contain
this smart_scan feature. Or you may try to build the latest kernel
on your platform t= o see if it can be reproduced as well.

=C2=A0

> +
>=C2=A0 =C2=A0 =C2=A0 =C2=A0ps =3D sysconf(_SC_PAGE_SIZE);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0pages =3D MB / ps;

> @@ -526,6 +529,7 @@ void create_same_memory(int size, int num, int uni= t)

>=C2=A0 =C2=A0 =C2=A0 =C2=A0tst_res(TINFO, "stop KSM.");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0SAFE_FILE_PRINTF(PATH_KSM "run", &= quot;0");
> +=C2=A0 SAFE_FILE_PRINTF(PATH_KSM "smart_scan", "1"= ;);
nit: Again, wrong indent. You could have seen it also in the generated patc= h.

Kind regards,
Petr

>=C2=A0 =C2=A0 =C2=A0 =C2=A0final_group_check(0, 0, 0, 0, 0, 0, size * p= ages * num);

>=C2=A0 =C2=A0 =C2=A0 =C2=A0while (waitpid(-1, &status, 0) > 0)
> base-commit: 8c89ef3d451087ed6e18750bd5eedd10e5ab3d2e

<= br>

<= div class=3D"gmail_default" style=3D"font-size:small">One more comment not = related to this patch:

@S= tefan, do you have a test (or plan to) verify the 'smart_scan' fetu= re works?
As we= do disables it for all ksm* tests in=C2=A0LTP, so, it would be great to ha= ve one
for test= ing in enable mode. What do you think?

--
Regards,
Li Wang
= --000000000000cdb77f060b33fb92--