From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BD4623EAB0 for ; Thu, 12 Mar 2026 01:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773279694; cv=none; b=p/F6pxatRMIHb1UlLOXZIsjr7su+AR8zjRwTTJlLyuZAgG/96g7d8OYDI+IwTLtAgcAiirfAGDCmEE9qWiAme1ZfXcVq2wak8DXqwu8/Eh0o6ARGZq8g4DtyYv+PEMY1kprG1QSUYWuBADXcwbJy5RRU35bfUFSgG6avrJVH9V4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773279694; c=relaxed/simple; bh=Kjpe0bufYsY03//k8j5lZt5tgyKrAJyQTr+PAoPzhsg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FEEE1OdFatnJwVgRYGJ83G90BqZ6Ndc2tHHshmWYoVFCAD9yCMNiM+43VRP8wYW3llRDY9PhbBUEXHNikxwOcy4eLqdB8zOlrm4vXXGLBf9+SbBpiidgubazxrOD1Zqlqasl41GkZq6aCriJhaU+fzIxIiZIxE/o4Veqn5Q9Jfs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hyvPjs6z; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=nC/xzCAc; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hyvPjs6z"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="nC/xzCAc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773279692; 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=UPGfLKT3oSZ8YEaztiojC78G5a88HSzUeVHYmBe+bKs=; b=hyvPjs6z2VEh62cMtLYAheUYXVV6Kzi4FzC7LjJrDpKx0WzcQFMZ6MCqvKVxl2/sGDZG44 R12jGF0v20dZx1EtcemEucmiRLwyDpzTzSaAc3ZaLUvviUimsZC0jcS3yQsPCbpPqxYpWd ZuTGe8NeBvs6eEY1QVM0bklmdYoHQWc= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-102-6AkH4mKoPiikJkH8DDtn8w-1; Wed, 11 Mar 2026 21:41:30 -0400 X-MC-Unique: 6AkH4mKoPiikJkH8DDtn8w-1 X-Mimecast-MFC-AGG-ID: 6AkH4mKoPiikJkH8DDtn8w_1773279689 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-c629a3276e9so1937021a12.2 for ; Wed, 11 Mar 2026 18:41:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1773279689; x=1773884489; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=UPGfLKT3oSZ8YEaztiojC78G5a88HSzUeVHYmBe+bKs=; b=nC/xzCAceSNqBZbC0k8CyTHkiImx32ax6UlWxjbQKQmsu3ppKLUk4xiNT/9fz+4veh CeFFH35uac749lz5wMEfqUZ4cc+rs6TiIobUJo94YaK4/fRdQZBVqKm3nCYN2bsSVCGg +iOIb2pEB7NkFlCT4JPwSEj1VULbBxiSiV8k+xQOdDdkc6XWYUzZUHBQ3Pv2+q/bkiES 3Ui4YPpK//6e6q8UCs/4e+8YFRfT/nftPtH9VzIc+P/z8KdPryf/Og+rcxoMctml1Hkl h7A+5MnRLzWS1l+eKBEs9nnTMoHiYKVyaJH4r/16C31JVTQHO/hsXKIs+VGNsHFKlFBn HmTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773279689; x=1773884489; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UPGfLKT3oSZ8YEaztiojC78G5a88HSzUeVHYmBe+bKs=; b=Lj8QHaJmdbCh3wJeuEs2DHHVkxOgU606YgBBC0a4blpFl+sjC50GMKxSQaFC+UyE7T SzXXCM5qBnH4Qe60GHqGlf+TZaydn37MD+/mYYRC98igktWgUAdBVsiQObGWEfOcRZeR Bd7YuPdFkjFvxqiLpM6ILFRPf8ydrL34j5wSgY7ly04YSD/1vLDV3My2gd1vflczm21M Fbr1RZC2xAlkk/hmCP9y/RbyO4JX1kwMPBwdEtfPdboN9GIAbONaRAiBp9+l4+a1innn 5nRrTlOz4LUtiw+eDdZlG04gMYC3zR/4FfxGwD0X8R1pYMCsIVhA3tza7MeygwIPbcol 1A6g== X-Forwarded-Encrypted: i=1; AJvYcCWRanW8/3DqQcKL+r278qBuNHffDWZTYtr2lv41sorp6ffvTfTGvG4qL/yqSgWTkpNqu3Tab6ceMD+5hy8=@vger.kernel.org X-Gm-Message-State: AOJu0YwJ2meaAzE7VyXvr3Og3MK/PsD1ue+Du2CRdRH4cNo1xO6yAEQo HaC2bkar3NpNeU6GebF7kS3hlVDao+rQP6V7UuL/FR6+Ea1M0uukVxjPEKK+/ibZ5XWq38bgMFf NwoHdFCdpkdvMHboeyo2iGIMhZ/15Ekk6P6yI/dTCVosKa0KAGqOkt4RcYKhHc24qmw== X-Gm-Gg: ATEYQzwPkR/5zLYp/Hx/O2ER7WlkzSDJcKeEvz+cndlZRGAQttbhF3FLZf0uk2vDDok NPrjg+G8aUlfvinp2TzhiZTwsyEZ5MwwOz7BK/sPMui9zMItVsXburJ4GrW+HHkxJiJ7i9B86DA ytNOdlHDMflVu1BE1YXCXVU69/5cE+F/BXCX4Ys43ZPLXQdfySxGkmRBqT60SG8MXrpnstA9CPj xQHlxBzcsUSWzMA+F62n4ZbxP0zkE9xiESINZl6qpRtdC4qvXIo1Bqc9xg5en0Ur8+3TbY+WAdS 4214ru5G7ssy2EEU18BHZbuOZLSb/gCT0cpp0Rpm00+SIjUxyTTf/3v09ueMTXfgJBjqbNgx9xL kQBvc659z5yOcT6N1Og== X-Received: by 2002:a05:6a21:682:b0:398:b5c0:565 with SMTP id adf61e73a8af0-398c60e592dmr4152609637.39.1773279689502; Wed, 11 Mar 2026 18:41:29 -0700 (PDT) X-Received: by 2002:a05:6a21:682:b0:398:b5c0:565 with SMTP id adf61e73a8af0-398c60e592dmr4152586637.39.1773279689116; Wed, 11 Mar 2026 18:41:29 -0700 (PDT) Received: from redhat.com ([209.132.188.88]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c73cdf2725csm3476355a12.13.2026.03.11.18.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 18:41:28 -0700 (PDT) Date: Thu, 12 Mar 2026 09:41:26 +0800 From: Li Wang To: Yosry Ahmed , Michal =?utf-8?Q?Koutn=C3=BD?= Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, Johannes Weiner , Michal Hocko , Muchun Song , Nhat Pham , Tejun Heo , Roman Gushchin , Shakeel Butt Subject: Re: [PATCH 1/5] selftests/cgroup: detect and handle global zswap state in test_zswap Message-ID: References: <20260311110523.26624-1-liwang@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Mar 11, 2026 at 11:47:22AM -0700, Yosry Ahmed wrote: ... > > --- a/tools/testing/selftests/cgroup/test_zswap.c > > +++ b/tools/testing/selftests/cgroup/test_zswap.c > > @@ -594,18 +594,88 @@ static bool zswap_configured(void) > > return access("/sys/module/zswap", F_OK) == 0; > > } > > > > +static int zswap_enabled_state(void) > > Just zswap_enabled() is good. +1 > > > +{ > > + char buf[16]; > > + ssize_t n; > > + > > + if (!zswap_configured()) > > + return -1; > > Return 0 here, zswap is disabled for all intents and purposes. > > > + > > + n = read_text("/sys/module/zswap/parameters/enabled", buf, sizeof(buf)); > > + if (n < 0 || n == 0) > > + return -1; > > if (read_text(..) <= 0) > > > + > > + switch (buf[0]) { > > + case 'Y': > > + case 'y': > > + case '1': > > + return 1; > > + case 'N': > > + case 'n': > > + case '0': > > Can a read really return any of these values? Or just Y/N? On my side it just returns 'Y/N', but I use more chars only for safe/compatiable consideration. Maybe we don't need others. > > int main(int argc, char **argv) > > { > > char root[PATH_MAX]; > > - int i; > > + int i, orig_zswap_state; > > > > ksft_print_header(); > > ksft_set_plan(ARRAY_SIZE(tests)); > > if (cg_find_unified_root(root, sizeof(root), NULL)) > > ksft_exit_skip("cgroup v2 isn't mounted\n"); > > > > - if (!zswap_configured()) > > + orig_zswap_state = zswap_enabled_state(); > > + > > + if (orig_zswap_state == -1) > > ksft_exit_skip("zswap isn't configured\n"); > > + else if (orig_zswap_state == 0 && !enable_zswap()) > > + ksft_exit_skip("zswap is disabled and cannot be enabled\n"); > > As Michal mentioned, skip the test if zswap is not enabled. Sure, that would be simpler and we can remove the enable/disable_zswap() functions. > Assuming zswap_enabled() only returns -1 if it fails to read the > module param (and zswap_configured() is true), then we should probably > fail instead of skip, as it means something is wrong with the test or > the module param. Absoultely right. Thanks for reviewing. -- Regards, Li Wang