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 6B2D5C46CD2 for ; Tue, 30 Jan 2024 18:54:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 983266B00A2; Tue, 30 Jan 2024 13:54:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 932F96B00A3; Tue, 30 Jan 2024 13:54:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FAD36B00A8; Tue, 30 Jan 2024 13:54:36 -0500 (EST) 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 6F0B36B00A2 for ; Tue, 30 Jan 2024 13:54:36 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 415E51C0EA4 for ; Tue, 30 Jan 2024 18:54:36 +0000 (UTC) X-FDA: 81736878552.12.C77AB02 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf15.hostedemail.com (Postfix) with ESMTP id 94DEDA0011 for ; Tue, 30 Jan 2024 18:54:34 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=UVtFBYXi; spf=pass (imf15.hostedemail.com: domain of 36UW5ZQoKCI4G6A9Gsz4wvy66y3w.u64305CF-442Dsu2.69y@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=36UW5ZQoKCI4G6A9Gsz4wvy66y3w.u64305CF-442Dsu2.69y@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706640874; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1hlck0SDOI53RH9ro1d/oaoEWA7eb7Oo/rrMeo05lWA=; b=TfYW9WhSrKfQvRx7cb5Vf2ifwh9nn2OHIPp8VL4IG5Hf5uHnORy/JKqe3neqXb3EKwpzBH CdLPReyFIU5oAT+c/puuG8aZzqbCYguJ3/zeu7CidT0lQJhIQbyDje3nX18Ihz8+v0I/cD yqluyp7kZDsCs8tvQhU2XWyCNP76SqY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706640874; a=rsa-sha256; cv=none; b=Fd5tvZZW/f+Iy+k4dFtfQehekcH3/4TE7FyNKb0X9pXg1PRKoALMFc76Djsv+YUFQk4lp0 W3LRzO91bKcncWKd+PIJGFkZLgiodPoZJNkwdqlZa5UwqY2oW/P11rU+YY82wwDLVvjAE2 iwFWL7nz/dpiaNKYI+J9HZC5b5e7TpU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=UVtFBYXi; spf=pass (imf15.hostedemail.com: domain of 36UW5ZQoKCI4G6A9Gsz4wvy66y3w.u64305CF-442Dsu2.69y@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=36UW5ZQoKCI4G6A9Gsz4wvy66y3w.u64305CF-442Dsu2.69y@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc2358dce6bso5913910276.3 for ; Tue, 30 Jan 2024 10:54:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706640873; x=1707245673; darn=kvack.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=1hlck0SDOI53RH9ro1d/oaoEWA7eb7Oo/rrMeo05lWA=; b=UVtFBYXiJdqc5uLYsKG+C36F9N/azjDBc1L3zPdL2uTBr8yeodXHgohcx4PUUHEXin gFI/cz/8RDhxuwhbLJdOUsQFtJZbLgu8OjIBjEg+ckX0LuSsGTfuK8gFO7WgWtRO9wNi WMdkABTA56lKJPMe7TzlLZo4opCidPdp235ObvQadBg/eqxVn5BenUUzYU9as2JFZnam rFkgvWf734+QKe5ZPPLqvK6hs9ZV3axsMbYiAvE3b6lHh1ZKLezSBQ6NLin6luEk6MLK GVrj0rhJW8mXTT8Qwp2mi5Is2hO5H0rZOg4YPlHQVoN7UtEYNoOwG753YAoODX4nATS1 e40w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706640873; x=1707245673; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=1hlck0SDOI53RH9ro1d/oaoEWA7eb7Oo/rrMeo05lWA=; b=C2G9690DH36PmZTomQnE7ukhHxWXiFzaHlk48K2ykjz7FRhx4Tg0LV0Ry/yagVoook lYYvhUBeYJtTUyoNvjlYhdlSG7rkg/LCzZlOSdQVr98zVIi683Y7B/TD7435/2xxWZkF jDolWvEusqqdNjk58U8IhQfmUgh4aRfScFwQbVL/MckUhTrXrwJjeJckLAxpelPm6D6M SkGUIlCYgHCDffVY00EAZNpGV28x6NJLJxLUKuawVgnL39KgI6dTF2+TPXy5lmRyy1EF QREFHC+Z26IxT4vme4XN7Lg774vlSRWsy7j+fiJIQzGwy1XSS22wDorSfrZ/yhsrhpm5 U7yA== X-Gm-Message-State: AOJu0YwDACG6woasbs32XUEzDjPx9fenO1m/WGjRGNA+pJK2qQTKHo8r hSE2jkzextVVoDCw3P4jz2kYK/rhPokZg0so2RgFLnp8h0/2ZrcCEbQgxXm+9DFlCAIIIcKf4EF jUz55n2us4Ar4vW9Q1w== X-Google-Smtp-Source: AGHT+IGkAvVn8Mmr3dy++eKOOGQiEGQjnS5RHrgdsd6QmPtWfbsuMCKcf4YEWnY1RKKIg+sA0Vjc2FJQc9D75VEc X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:2191:b0:dc2:6605:f6ba with SMTP id dl17-20020a056902219100b00dc26605f6bamr606ybb.2.1706640873582; Tue, 30 Jan 2024 10:54:33 -0800 (PST) Date: Tue, 30 Jan 2024 18:54:31 +0000 In-Reply-To: Mime-Version: 1.0 References: <20240129224542.162599-1-nphamcs@gmail.com> <20240129224542.162599-4-nphamcs@gmail.com> Message-ID: Subject: Re: [PATCH 3/3] selftests: add test for zswapin From: Yosry Ahmed To: Nhat Pham Cc: akpm@linux-foundation.org, shuah@kernel.org, hannes@cmpxchg.org, tj@kernel.org, lizefan.x@bytedance.com, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 94DEDA0011 X-Rspam-User: X-Stat-Signature: bu9r3rr11to8xyxcwj5w3scr5rcosz5d X-Rspamd-Server: rspam03 X-HE-Tag: 1706640874-608747 X-HE-Meta: U2FsdGVkX18FWqbKTQ83INPMlSiOkUx+wtbfh5gq1n80I5NjPkDYUfyI2JD8swynv/CcgKD79YK4zWKukUsr+h8Fw8OrCXfiWob4n8hFh5jTtXMsuPSqg5tsSI57+t90uKjYJq5y391KHrdo0QSYgxYEm9WP9GYDbk6JT081RJwyyxbgFMIS3wp/sqfGDoOSRVnslC8CVL38SEKXC0ybBJ0FW99zUDzDogPTK6uPYn6cz8MdZL0vCQyBTktIJptyKoJH4f40oSLlM2LrTAiQX7bLLV8yIsGQ51isbv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J0vp X-Bogosity: Ham, tests=bogofilter, spamicity=0.001586, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Jan 30, 2024 at 10:31:24AM -0800, Nhat Pham wrote: > On Mon, Jan 29, 2024 at 5:24=E2=80=AFPM Yosry Ahmed wrote: > > [..] > > > -static int allocate_bytes(const char *cgroup, void *arg) > > > +static int allocate_bytes_and_read(const char *cgroup, void *arg, bo= ol read) > > > { > > > size_t size =3D (size_t)arg; > > > char *mem =3D (char *)malloc(size); > > > + int ret =3D 0; > > > > > > if (!mem) > > > return -1; > > > for (int i =3D 0; i < size; i +=3D 4095) > > > mem[i] =3D 'a'; > > > + > > > + if (read) { > > > + /* cycle through the allocated memory to (z)swap in and= out pages */ > > > + for (int t =3D 0; t < 5; t++) { > > > > What benefit does the iteration serve here? I would guess one iteration > > is enough to swap everything in at least once, no? >=20 > There might be data races etc. that might not appear in one iteration. > Running multiple iterations increases the probability of these bugs > cropping up. Hmm this is a test running in a single process, and I assume the rest of the system would be idle (at least from a zswap perspective). Did the iterations actually catch problems in this scenario (not specifically in this test, but generally in similar testing)? >=20 > Admittedly, the same effect could, perhaps, also be achieved by > running the same test multiple times, so this is not a hill I will die > on :) This is just a bit more convenient - CI infra often runs these > tests once every time a new kernel is built. >=20 [..] > > > + > > > +static int test_swapin(const char *root) > > > +{ > > > + return test_zswapin_size(root, "0"); > > > +} > > > > Why are we testing the no zswap case? I am all for testing but it seems > > out of scope here. It would have been understandable if we are testing > > memory.zswap.max itself, but we are not doing that. >=20 > Eh it's just by convenience. We already have the workload - any test > for zswap can pretty much be turned into a test for swap by disabling > zswap (and enabling swap), so I was trying to kill two birds with one > stone and cover a bit more of the codebase. We can check that no data is actually in zswap after test_zswapin_size(root, "0"), in which case it becomes more of a zswap test and we get a sanity check for memory.zswap.max =3D=3D 0. WDYT? Perhaps we can rename it to test_swpain_nozswap() or so. >=20 > > > > FWIW, I think the tests here should really be separated from cgroup > > tests, but I understand why they were added here. There is a lot of > > testing for memcg interface and control for zswap, and a lot of nice > > helpers present. >=20 > Yeah FWIW, I agree :) I wonder if there's an easy way to inherit > helpers from one test suite to another. Some sort of kselftest > dependency? Or maybe move these cgroup helpers up the hierarchy (so > that it can be shared by multiple selftest suites). I am not fluent in kselftest so I can't claim to know the answer here. There are a lot of things to do testing-wise for zswap, but I am not asking anyone to do it because I don't have the time to do it myself. It would be nice though :)