Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp466926lqp; Thu, 4 Apr 2024 21:19:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVNeQHa//6mFedociph3kJGNzJK2DDz7ruBeuIihd6xjK8CipG3d+5O5n63PV49dskg1F34x4dVSkxge9Q5TsTNi+6lMxx+6uytE/o4aA== X-Google-Smtp-Source: AGHT+IHpwzi+AtTNoBEakD19K9yVJNt2/enX6z1xp/LkPOalSg/8FLLd7W0envzqgyfEdHGSr4p8 X-Received: by 2002:a50:9f05:0:b0:56e:2abd:d00f with SMTP id b5-20020a509f05000000b0056e2abdd00fmr207021edf.18.1712290797037; Thu, 04 Apr 2024 21:19:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712290797; cv=pass; d=google.com; s=arc-20160816; b=Xm/kgmv98yyzm5B+ZFzotunB5ctqWdlyffB1l4EQ0AqVkbHc7AzJ8RLqk8Us0F4APK yE9nPTbR2QACoFxlha95XVqiH0cIzE/gMkzKKsv3TtlOKeSyzN96Plc84a96MuuTJnoD q9Nuc+LgItKhjR/a+xoVwNxFyvGbIpujkqzHwY94gQ/Zz4WCsZy1lKExdAlnth6SHdml 7R6FBx4NHuIUk4dSkFfNCKinYdTaMM38imb+Ow5ilEvagGqfR9L0Xk5FsfUfDlN7FFCG i88HlSiRqrZ21DZgiafl+lcqppPjmUsUeDpbVz/A4VHw4cST6b2m8PsNogvBZj2lBBfX B8AQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=sSGNnX9g8ICe/nI+9fFx+tzAM1H87qSuQwEdqixVCdE=; fh=ya54GYKG0hy9oD326jR2Vq6wfv6bFBr4WIkY1oNl6DA=; b=E9COcI/O/afjgG0apsHLRS2lUHIwIG7Kzvq7Ut5ghoj5UBoHLkrC9l+in2U2h+yHrA 4NkOc6QQxqLJzUJ2VYSNikajeSdFz6Hb6WxQtE+M47lm+HbJdOfLAtl+We9dOnCZ29jz O5bh5fFjLpCmCztqaQ0ld0i55A499QIbHj/On1CiN8d7VI/yQiy8pyY8U+tyxPohXxL4 PFaj5WwHl8Ocx7x1XrVzb+rysbUdmJJmaBAHIadklc8v+0Dz9owR62UXNFbhqMsuESIv +XZcOLarfl6x8zEPKl4cxdvKrKLI5b/ugs2SdHB31OuiNMjEzvAHq4MOv9FYZAumPXgn oW2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=F7AZFUeX; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-132401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u24-20020a50a418000000b0056e2130ea17si334764edb.473.2024.04.04.21.19.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 21:19:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=F7AZFUeX; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-132401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132401-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B83751F296D7 for ; Fri, 5 Apr 2024 04:19:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B84291CA87; Fri, 5 Apr 2024 04:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="F7AZFUeX" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 365AE1BF54 for ; Fri, 5 Apr 2024 04:19:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712290788; cv=none; b=bELkfSIGnoAYJPUQQGalFa6dcyH7lFZXg+0YY469KCF6ItM3uNiWGB+HH6uHHLCPeKn2VtYZKnOdP7jixy8i3CUVebdVXZsD3gpkhRT4LDP1KVrugCSC8OponFSCljNmJ2Oiq2TL0k2CJvt08V9OaDjfm+egYODU6xnx1P2ZK6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712290788; c=relaxed/simple; bh=sSGNnX9g8ICe/nI+9fFx+tzAM1H87qSuQwEdqixVCdE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=mFGY/hJrkE26RSxsWBiMIp6B1r+Cpv+eLlVCdGkjT3ZZNP3pPKL1nRO/74GAbj/+Rl5NUtrtSHlPXp/m5S+vA0364tL0Y0Ir21glispevGVhQTIGhSBe1KiG7vohK1SRIQmRR42ZQme6bMfMZiaYX2Z68o03ChcF68+hMwj6hJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=F7AZFUeX; arc=none smtp.client-ip=209.85.218.49 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=google.com Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a468226e135so242911466b.0 for ; Thu, 04 Apr 2024 21:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712290785; x=1712895585; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sSGNnX9g8ICe/nI+9fFx+tzAM1H87qSuQwEdqixVCdE=; b=F7AZFUeXaGvjJZ01Zj+8D15Jij+FGVailOzLlv2MkGWBzL4uN7JtDEc2BMGyepznDl esadeINROvMpIdXfUk/T6wMEZj07m5mfVZxjq5/StqrUtQxRdhDzJt8r95vUaB0+AwWV 2F+vd/yYALTpF6iRm3Q+vv9lV4gkm0j586c3z3NachzNwAtx4u5E6Ty6GaCvwWTFEVF5 iuY1n6yU/tBxtgMTs0SwPqtg1g0jEaVwJc+dr9tNXjyQMAqEsdNPeQlss+MyTK0VV2E4 I1nmUI9lndAMHwQD/x89TX/wCYIu+IyXBv871eQpAp4Iq0fH9/H5A2Izq5My0WGYn8M9 BbsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712290785; x=1712895585; h=content-transfer-encoding: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=sSGNnX9g8ICe/nI+9fFx+tzAM1H87qSuQwEdqixVCdE=; b=v2ZwhosS073BBsarKdoX/tkz3fPHeyeyoL79kWb6jh6ITHz/sP6JIzcglcJ7x7w9D7 ri9l+sKaWRukMFoSdstSIzpjsUBll2vA1ODb/N9+v10Dwy+D8GJuKwgbvCIgg1d7NvBt rUB/ty0FPr/TfDo3pX6IOPcuMdznrVaGBL1VVXT3YmKL6dxVQex2sblZ27Ch2zEtc9hY 0NdZEpyfiUdoaQTajwKNkMCDP17izqBXAwEkIy0Gj6dgwbdqcnra5dvvxv61WrVtsTNr dSi8/FJ+7aA5hPCTP96elM+iE4i0wZRCPlDeZO74IGtr/u0O8G0qUphu1MuAF2ETEXHY u1nw== X-Forwarded-Encrypted: i=1; AJvYcCV7q17mGRLweG/zA9wFa8/WpvdRUg0j7GPhBBs8iUj/sdjBdCHPsGczSrL7QH3r4H40Ali6MZNc/i8yjjmCuRpSfBlgqtkGaEBq4fbx X-Gm-Message-State: AOJu0YzG90Dm+6qPF5fpjgQxYfmvDmoMzzNwKaeB3h5IcIOHWOVNnynb NI6qrJSbij0VyDhuq05jvSj+st4CC0Te0idwfE5J7eeB/zzDy+41YJbIEPUMxu+LFwzECQyuaK8 oG0zbSTNlRPEPUtXfe98CKU1ZRNOj0h2RNO6qZNVIVrBzwOtbR5O1BR0= X-Received: by 2002:a17:906:4716:b0:a46:cef3:4aba with SMTP id y22-20020a170906471600b00a46cef34abamr166579ejq.75.1712290785348; Thu, 04 Apr 2024 21:19:45 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240405013547.1859126-1-yosryahmed@google.com> <20240405013547.1859126-6-yosryahmed@google.com> <20240405025407.GF641486@cmpxchg.org> In-Reply-To: <20240405025407.GF641486@cmpxchg.org> From: Yosry Ahmed Date: Thu, 4 Apr 2024 21:19:09 -0700 Message-ID: Subject: Re: [PATCH v1 5/5] mm: zswap: do not check the global limit for same-filled pages To: Johannes Weiner Cc: Andrew Morton , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 4, 2024 at 7:54=E2=80=AFPM Johannes Weiner = wrote: > > On Fri, Apr 05, 2024 at 01:35:47AM +0000, Yosry Ahmed wrote: > > When storing same-filled pages, there is no point of checking the globa= l > > zswap limit as storing them does not contribute toward the limit Move > > the limit checking after same-filled pages are handled. > > > > This avoids having same-filled pages skip zswap and go to disk swap if > > the limit is hit. It also avoids queueing the shrink worker, which may > > end up being unnecessary if the zswap usage goes down on its own before > > another store is attempted. > > > > Ignoring the memcg limits as well for same-filled pages is more > > controversial. Those limits are more a matter of per-workload policy. > > Some workloads disable zswap completely by setting memory.zswap.max =3D= 0, > > and those workloads could start observing some zswap activity even afte= r > > disabling zswap. Although harmless, this could cause confusion to > > userspace. Remain conservative and keep respecting those limits. > > > > Signed-off-by: Yosry Ahmed > > I'm not sure this buys us enough in practice to justify special-casing > those entries even further. Especially with the quirk of checking > cgroup limits but not the global ones; that would definitely need a > code comment similar to what you have in the changelog; and once you > add that, the real estate this special treatment takes up really > doesn't seem reasonable anymore. I was on the fence about this, and I thought it would be obvious without a comment. But you are right that not skipping the limit check for the cgroup limits would look weird. > > In most cases we'd expect a mix of pages to hit swap. Waking up the > shrinker on a zero-filled entry is not strictly necessary of course, > but the zswap limit has been reached and the system is swapping - a > wakeup seems imminent anyway. Theoretically, it is possible that we never have to wake up the shrinker if zswap usage falls on its own before the next swapout, especially with the shrinker in place. I thought it's a nice optimization without much code, but the need for a large comment replicating the commit log makes it less appealing tbh. I will just drop this patch.