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 6670ECD11C2 for ; Fri, 5 Apr 2024 04:19:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E83656B00DE; Fri, 5 Apr 2024 00:19:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E33606B00DF; Fri, 5 Apr 2024 00:19:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFA776B00E0; Fri, 5 Apr 2024 00:19:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B34946B00DE for ; Fri, 5 Apr 2024 00:19:49 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3A10E1A10B6 for ; Fri, 5 Apr 2024 04:19:49 +0000 (UTC) X-FDA: 81974174898.20.136550F Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf23.hostedemail.com (Postfix) with ESMTP id E7939140011 for ; Fri, 5 Apr 2024 04:19:46 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=SCUBI7AH; spf=pass (imf23.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=yosryahmed@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=1712290787; 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=sSGNnX9g8ICe/nI+9fFx+tzAM1H87qSuQwEdqixVCdE=; b=Ez3p5tneBAodvFim60L3mQRfGcdA86NSxhV2LizEjpqY4OybTZAyRE4cWCL89VHJ7Y/3+3 xmURp3c5M4nIFb8ccGZiAoVAwmb3OvJmyAWdQlSViEisc3Rf+oXAyhwx/Ln+R5VeLAg9xe /2Y03Zbs3t2+8063tNYRIwBJTkwqtE0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=SCUBI7AH; spf=pass (imf23.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712290787; a=rsa-sha256; cv=none; b=rpIeXTsk/UowSuexuFxTbB/gOQszJ1JnQ61pmype+O3j5v8sVCdDDAjDWwjZrRHI4gzmXO oK8aJpk7om5NGBoT9lGqmrWivJCsCsIBmdURDbqv05MeK2J0euaXx+OJus/dukXb61mOzG L/stkkVjZXJKs0rM6hX2iT+0nZdkopc= Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a51a7dc45easo9461566b.2 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=kvack.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=SCUBI7AHG+JqdQNEj842Cs7DumU/gq3I8PwIKyJg86ziZKZqlU2KxqSAM/o0qLFmlo skH9kAWH5clUw5rHxfsrVX6IMOjHPTG0AQyaSIH25lroPjgl2iSUKA6S5qyIys97Y3mH 0r1u2jucC3rGHIuB/qDcu+nxwiCRLW9dJ7PZHvQXLdXjbPtRGjwrCwxl2FrjelrbWQHR 07CmCrKuo+bku5vufTAM14QxU1rrqOh1z46HMiB6TQdLn4M41Fmnqk/0EkV3eB+9aiXU vuPfdktC6LwpVJ5Eje4qYarqstnidpR79/+1KFIFmtp9HF6cB1w//IRdlWEgZZ8MBs0u 4P0A== 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=dcFmUNG20eIF2y95Rc/QwTguubk7+iqwLQOYTSLEEKbGesKgluc034I/CijdGtgyPx 0US946I/Hm0fhwI5JxkdjujihBR3VhxyUASQgmDkmKU943fAeD2qNovMWyH1Hthfx8+l 9O+8pUWfWTXQLpfRLvEN1fFclqwUwAKtc3JklUIP4cVrCL3MzBD/s9Ut4a4PLEcf31Yz ysOKC+kLTvXb3QPxZlM/iLMTnYR468hV/Itg+7awWGHXajDCg3F43RAlFtBfJTChmAMe TowT6NVKT+mW3DlgpWRAC3u4vrOD5SfKHfyCXLHCXUXlnbKcUSS1ybXzyc09YMjFGCJh mYRg== X-Forwarded-Encrypted: i=1; AJvYcCUQRFRixCbqkAzn4V3Ax0E+tH1s9McH46148CQFBuHXO92kBGZU/2hVLTGGt5hKB8CsHpk0BOyzfzotmqJ1XOeBqlI= X-Gm-Message-State: AOJu0Yw+4spoXR/b3YNE3boSF26q1ReBD4B66Dl9XCpv+/MQfulDp19a xOq9fCOHlN7kUDeJ+xZPKEds3keBkS7VkoErj3wzeFq5WNFfwoKmVLwzN6DPCy5WRNAPzHXzaNo yp+hJOK9V33HxHRCX88AlGCnrbm+VF8X2nyoQ X-Google-Smtp-Source: AGHT+IFXMl3gfPQFdp7tMwxJOn6+If6j/Vz+aioCA2I13CRmX4cfmooI0lKiHNqqVayWCY/2U3ydDK7mql0067i5GY0= 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) 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 X-Rspamd-Queue-Id: E7939140011 X-Rspam-User: X-Stat-Signature: xi41fw3je8um9qekn6h9tdwi4ehy3kda X-Rspamd-Server: rspam01 X-HE-Tag: 1712290786-313894 X-HE-Meta: U2FsdGVkX1+cmJRehaSB+vQSIraNzOPEBEa3ZRwM2QNPA96DpiSjcLvqwJh7TF3lc/dpHlBvqq42d7tzHyPhgxLZhL+GbrXB1k0bELIOHt1okLzGn940MMPbDaCBFnL2kP+XyaUv26QsBx52kHNh2avLbncJxg2/I4mZxOg+cfInA7LO+ViWEGDAaNnn3+9H/kjdTxjNGsuxP0T/wAjo+jiD94n4yYwWSPBaWept4JQ4ytShfYKDB/RjNSi69C91ScqlhmGiEzrNOFLwPMFqYr6ot5NiNBxazZ1Iz8Wu8B/lyA4JsM+1Cdr6AthocmeaTdEhkTZ/fabbnylm5Y5K61xMvN6YeOOP7n9z+UVDw/TZbvOUTQc/qE/OCk5BWE9HQv++ye7vVprM9xaUUOlYUp89Jy9TSkqOT5poGfESmD7WiSuFzE+rborrJavc3q/qjlfK/Pi4Ogf/hlwEwkuf0bC+v52dbjEoxOdwWY9WyLsvHF1Unb5OPqskPboEHL7wg13dpved6OXBsF3Njk/I6cIUv7cG3U+GE15mnFk+nbG5DhtMg3TJapQ9uXNPxakhysjXq27vjJy3BAHoYZnRdnm3ImjIBT7dAt9dETnBxZWaMt+DzozlUf+lXAB896SdzXy6VGv8xlBkI+kNpZBiXUfgMtcbH5h46vRtnhgTfhiyFr0pzj3wV1Mh8AGhJnZWr+DvTznfYCQ9jiBC4qBPh1gBjlNToM00FkzL1kP3Dhmf/MJPmjxyOSrI8OdeJSypJutl9E6psiQsniKC/Kfy20GtJcSLt91jyOEUIWqgIne7rLYOFkT5lSL1QrY3fgqVdZWVSfTYC7y44iROCaoWdK/aCrKftVGB8G6sBHchcBEENEC5WIU9s75NsSYem9WN0+u+22PHZIR5+Upf4Me2PeMSCuLovDdD92QZHc2IRd77bk8lLWJOzTqGKuVuIioAtzH3XC+eMxeJTBN1JYc NTtxxy+8 TfV8C0/0mIzb7JWoGz1CC2wlw0GfUhNESDRsEQTHW6xS3f1ZPbLyjjvB/fK/hCv69MPrXFGX/c3b35zMhoULzSHAw5alsuOClryL9QLwMpwjoZOQ+HGErd2dNOQphD/Gj2H+l3uO/DBXZOzh4NCtbn6v2ZJw7Pt8dLzcLrSkGRUUH7TaY99eddvDYMxOmamZy6fZHNWW18syy8hxhgdd04ad0k1H2DCL0P42xDYQcgUtGN+h5xc1em6ZBDx7yhUUYyttFzV2h+3QhqjM56Wyp6YzfmazMTSeBPWzxlJ+eyvnTDnmi4T4zdha42g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.057939, 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 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.