Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1205385rdb; Tue, 30 Jan 2024 10:54:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkBtQszBqcOJjvv9sVnakbKvQY6mUd4PS2yW2iAXmyti4jFrqocODwIY5DKGk1qJWD1z7W X-Received: by 2002:a05:6a00:1142:b0:6de:8c0:eb5f with SMTP id b2-20020a056a00114200b006de08c0eb5fmr8888476pfm.18.1706640883948; Tue, 30 Jan 2024 10:54:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706640883; cv=pass; d=google.com; s=arc-20160816; b=SKue67UB4teAKkr0xGHnCgjN6uPwmc4rIJexAsSvG+UyesIKXN2AdFUDmi8OApcO2w yW3Q8uQkNVpvAdHKnDNS1lFEdaCL2K8NiRXH+5WjX/Q0pIyVeKt03xWIKedxXkT+zysT zFYk7ECqsKPZgT02630RF9sD0VyP5OoV8OXYFGEJBQJgnTZsfgLhiG52CH2Hfi8ex8xr 8tI/0QKLiZ0uzpH3mfi2pgq9kasLMOrde94tS4xwUqzZYqXA/GMItVmBo6/vQmr3NkWr 30w9pg2S+N5NsZZQJahrtMw5hMAyiK9V74bIeJSn3CPK9/t9CbfEr74KsBzhtsiKr1VL PP/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=1hlck0SDOI53RH9ro1d/oaoEWA7eb7Oo/rrMeo05lWA=; fh=y2rbHuwQIJ6HgaGf1qBx8r4Sahax21s2wt7mETU9nbM=; b=l9x5m5Vp6i7W+Mnoud9mdl8IxRp4x1tK1OQw0WNOXltjm1fz/bWT+fD9jWhdCwPeDy Mkyztp0N6SaI7o5Dnq8XKwVzeIHV1KHuv+ZOl826PB18kEL4p0msdTnzW9Wnk657PZQz iwKzvjwS3JN52H391GSLCI4HOoenqxBp74j8Z8f4CYuYzCWSrHnO1NKx5yXbaU5apeoZ t2wec5CjDcrsSJQSTtoF7FdXVNuJf+ggyKzqlOKVWy7SwpCuRAwmHCaM2HdHIGO+0zPh dsvsAgYNdbSY+3zhSNOLXr9yQDaaOoYyfW1XZpBm+zMyfunbeHr6YCUbCXmkqrPLdBWD THKQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="pEucG/Bl"; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-45144-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45144-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x29-20020a056a000bdd00b006d98b960149si7900306pfu.347.2024.01.30.10.54.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:54:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45144-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="pEucG/Bl"; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-45144-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45144-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9624028461A for ; Tue, 30 Jan 2024 18:54:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D378879933; Tue, 30 Jan 2024 18:54:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pEucG/Bl" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8651979928 for ; Tue, 30 Jan 2024 18:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706640876; cv=none; b=dm2CGVxHTiVTNS5Yq9HOp9s/tA0S1rq4Ii3VkZSzP+Jv2QTlpWiFqmXsiN3rEi6yE4ADE6iE3Djm38ZzXzWxlFaiSl1LQqVT57yKlO+o+r4KUaVszLAQ7uSqj7MnG4j/D4nqrlpsR5ELuVl5UqOrbOwLhrsa5AR8NLb+dDsUFYE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706640876; c=relaxed/simple; bh=KaYqtwvhZkPpAlQK4G8JayCcItXB2wokKct2Y23TGIA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=psgwTawZjUtz2BoJoEqa75NHjg7Sb4mKaYNZ+T55VStJtp/3kDHXnXVHhoDeoyZWGdie5jbC2VC/pRAEBfQtAK+IrBDNVhYXruYqSgpMGXn7YyghYwD7uZrCL33w0QTLQh10/7ZknmBUS4MW33L98X967v4zA/wNzOv6VN9wX/o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pEucG/Bl; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc2358dce6bso5913909276.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=vger.kernel.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=pEucG/Bl6H/Xyn2Ts31jZRtLam8Gj0DZUmsO3NJjMRR/ibABUu8Ns7HYeh89rhyCqj CgyLDul2P0L/V9FtUGrl3H3a5fgbZBXczZbaNcFkbKWYS3tVZwm531Ho4O1E3Swk/C49 DZUrpUzWijwSZVnAsrEIgkyEeOumVVVJfxQ42/2wFxon9I7gnIaglOy2+Jjcrtukh1U+ dEmTNz3t0QY6wbRbRge1A5+ZjunGuuLErwUoM2wfqC/S0B41AFKJFWWfisg4WN0/1De8 EyfeJeHnhCraecEeNbFZXP6jCvSyn6JFKq9p9huibgJNQCvYGjedwgHIyTXS1bzC70K6 zkbw== 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=J2vrfuEgJ8kFxu0uGY31COFkK4TgnbQx1NaVXA6GGyvMTBjc3x9xwKPPapy4rCMc6C 1teMdwaXwxVKZ+R4jz0igMHaumhlveCimHX4F7RDbn7xJTL6UWQumF1MwE7ndnxRkuFh pxDAFXjj10Fjx6spPiSMdxqHo2mpKMuoIee1+qMuuolgmogQeOPQve6p3DkeJfZiUCRb GTLQdl0Nur91qCYjpKNLmCWNMwqjJVGM1FzylOeaHDJ603cn4jakQ9gme9/oEXROfMkM /23G2Tpwh3aM9r/ZveKM15H2Qk/vJvWGTOlRhvA6ccix9ipGTkTKiesUs3Oc6JDDRyg6 o4yQ== X-Gm-Message-State: AOJu0YznvbabxlY6V7ZsX90Y3ftRQPXN42w8yA4LY9OYFlIn1DdwSL2z eiSQxlzFaRYLy6PNdWV7LFynVgc55mVodlx3uwzP6/YU3eH4/0aye8YuE0ndq39q2yOyfLecveh C5+8O8/e+WkY4d3WisQ== 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 :)