Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp218088lqs; Thu, 13 Jun 2024 08:15:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBNCBUX6R7seg+pI7rxxJoqOprDF383DMr+cqEOm3KAy9dR0Q95LtRQyKqiRCn3Oul+qd6Adc71cZZ2jwz56b62l4xMDaklT75qFaxYg== X-Google-Smtp-Source: AGHT+IG1mOIHNMgsta/jSNGKYAqk3KU5ZHpGPe2JPv0SdSwaVqUHFKoE0awban/EoQKLkRLbSYDQ X-Received: by 2002:a17:902:e742:b0:1f7:3a70:9e71 with SMTP id d9443c01a7336-1f8620c0f84mr1682145ad.13.1718291703761; Thu, 13 Jun 2024 08:15:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718291703; cv=pass; d=google.com; s=arc-20160816; b=gq0yJZg1snuDxmn02mrN7J3iWXR64CsCV+7wfkQMMMRtjaKoTGeM9mmTx52NJurGet m941tix/Xrbk3C03CpV8TrTqhXbke3HtBq2ahMuFOZ3KEVGHbgonpZBHXnZvZOWt3mT2 Uei/hBy21Ov0nf3jvHT0IycG4AN/ie98f72KMhxMj2uYg4F/TfHPHJeoCA31C9SDNgL+ 9+0nXPSEOixXHWwMMbYVFGRjvBqF3aPQ8fwLD5q4dExbyfTJP8GwonkoWLREpipQjK8M zIJ+MqQn3/Ui6ZVy37OOB+Lq/OU3WPHM8ssQMH6CFZo7FD+fp07o/GND+2vwQgVJcIte bAOQ== 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=tD51o0Y1ksGPreKO2RCSDyc0HAD564QL05nYWkEYiaE=; fh=F2jV5vyRCKLuRk8s7Nr/+alt+J6XXrSD7GmD7VxPHag=; b=imWiVQQOgoD+ysqKMCG4uFt12Tc+d5sV8PHb+wn7dbYx2r2s4YvJKpRZWUTkDyPXzR xWPu1FxtzUNQr1Ze0KKtdqqN+VrHa2HoDAc4+lMWnmc78AILbt7yuSN1q1Nb98uWaFx0 MFzSK2WMdGd/OtPhpdMhvhIKnX/dFgwKnhGBI1BgHYu/GfXSOYj1NzEyVxHlqe4/3eI+ Kq/N38+Yhu76O0M0PYelVR1dJeeNJsF8unf8qc/5jPryQExPJW6PVBXrJqJ5tXNDlFG8 juWz26JxIo1vNtU/z7aRQsU3CX+jaR614/vzabkBMIluaGEID7h1i7IAA0J407feyQYr E71A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Rhhb8UeS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-213511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f855f0b5d2si15542405ad.538.2024.06.13.08.15.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 08:15:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Rhhb8UeS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-213511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9E8D7B2361F for ; Thu, 13 Jun 2024 15:13:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8574F1474CE; Thu, 13 Jun 2024 15:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rhhb8UeS" Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (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 3F6AF145FE2; Thu, 13 Jun 2024 15:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718291605; cv=none; b=BQcWvnNjK5YHgxw0wlAPJqCRBEEubD5Za9z3SuVLH/PZt1gVGTUiLk79NXbRJuI1oJ/4rtpiVRAvxWpSqH/uvY+xVlgMg2CbTxR/aUxJfXQtd8F8tLlon+1K+nQxuc5+wMmRTMi32nyXvhkUC1baunhN/jaUTjh2NbP119BSnHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718291605; c=relaxed/simple; bh=9H+YgTYmKGS5O+3bHXS0T2zCyE2mUBQG7mMq+T/+KDY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SD3ksbtNgy/4agKDefjYJXJ7HVnlNzMhzNsyJM/roiOZhY8/DebP8pcCwaXfh6CEQgqDE2OJM2sIUQAEVNnAftVn6+yb5NTDWJN7GoDSSDdqk1QEylvvOAGQw8+sIlumgEdmiKseKG6Hs5wQyaxxYNC6ZANch+gvvCJ782B8nUE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Rhhb8UeS; arc=none smtp.client-ip=209.85.219.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6b08d661dbaso20559466d6.0; Thu, 13 Jun 2024 08:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718291603; x=1718896403; 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=tD51o0Y1ksGPreKO2RCSDyc0HAD564QL05nYWkEYiaE=; b=Rhhb8UeS/F8142gK3yBwxQS3q8EKL5XBH4pZLTtMPdRAnuCHOg6qLEyGwOB1n+vp3R o67CjEGKc7Czmyn/m6rFmgxHpnMXM8Nv3JrxSk1G8BROf6T75BG4EmnyI3CJPCJ9ix1u 9umLF1h38iJCvg9H3w19YBsR/OJEXrrQE2Vl76Fbpufr85BKukBnVC7Z6+cI5p5i768i 7nEfp+ye0b5OHnB3FiJZglqG9nyxoM9u16wUz9OP/O86LMuluHO+b7dWQQ2bplTxvVvq N2u7dFvwBcwE4AX5nakZ8QAxZyvi7Wg4EgsFDh30Sy+E2vFdngC56zXAMsME7eRybzHs HFRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718291603; x=1718896403; 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=tD51o0Y1ksGPreKO2RCSDyc0HAD564QL05nYWkEYiaE=; b=ffVtc4YA7sRle42qgQU9rAl4TseL8dfIQJX9VH+rE17u9t2rZHPJKDv/fOhNSZoAmb 0N3VATVYud2UJ9BrGewCOpGMbyD7hgOJtCacmqi5/kIBnZO4trkpxDMA/VwpU/ZUxyIy K6sbkCqHaHfh6cCsnNwCNkvuTX+N7LwUJHgmMDLlem9N3SuPFPtTiJpn9hqmFQ6Nms16 sOaftPAw+O7HCgn+K5EoCkIqU8qlXkA2JJHeSWhqBiHi9P6fjWvlCWmLfTpg4DgSkIjo AqoC+c5NO/ty0P+LuHiVkEbri9dIZEklQpJT18YNUlJqVuu0huG3MjYe4hNgmgXfFX6d RPEg== X-Forwarded-Encrypted: i=1; AJvYcCV543eJq4InAz1QgzjWnVya7LKOygmnQFgDPOS7u1KYivcz0c5fkwDGAya7MgkTP8XDZI90QQUh+29f343Laa4j6yYtGDgzPyVb+St13fQHnpN44Hew0MGufKDXgAmWQmeAr3oz2iuy X-Gm-Message-State: AOJu0Yy1CAvvmRYSJ6oTWGAhCOHKEVWkagSExr+gPaeawE7yWqM40P31 ZnF0iCNOqQIQBEsE+xUJN7Oq4d6Iz/i1z/UBj9LgYUPZ+a9DB8dB8Br0LZCKaEIKB8mHyaF4lN9 woRMNffiUNWoMIhikNbOFSowMO0U= X-Received: by 2002:a05:6214:130d:b0:6ad:753d:45cb with SMTP id 6a1803df08f44-6b2a343d2b7mr49824026d6.20.1718291603122; Thu, 13 Jun 2024 08:13:23 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240608155316.451600-1-flintglass@gmail.com> <20240608155316.451600-4-flintglass@gmail.com> In-Reply-To: <20240608155316.451600-4-flintglass@gmail.com> From: Nhat Pham Date: Thu, 13 Jun 2024 08:13:11 -0700 Message-ID: Subject: Re: [PATCH v1 3/3] mm: zswap: proactive shrinking before pool size limit is hit To: Takero Funaki Cc: Johannes Weiner , Yosry Ahmed , Chengming Zhou , Jonathan Corbet , Andrew Morton , Domenico Cerasuolo , linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jun 8, 2024 at 8:53=E2=80=AFAM Takero Funaki = wrote: > > This patch implements proactive shrinking of zswap pool before the max > pool size limit is reached. This also changes zswap to accept new pages > while the shrinker is running. > > To prevent zswap from rejecting new pages and incurring latency when > zswap is full, this patch queues the global shrinker by a pool usage > threshold between 100% and accept_thr_percent, instead of the max pool > size. The pool size will be controlled between 90% to 91% for the > default accept_thr_percent=3D90. Since the current global shrinker > continues to shrink until accept_thr_percent, we do not need to maintain > the hysteresis variable tracking the pool limit overage in > zswap_store(). > > Before this patch, zswap rejected pages while the shrinker is running > without incrementing zswap_pool_limit_hit counter. It could be a reason > why zswap writethrough new pages before writeback old pages. With this > patch, zswap accepts new pages while shrinking, and zswap increments > the counter when and only when zswap rejects pages by the max pool size. > > Now, reclaims smaller than the proactive shrinking amount finish > instantly and trigger background shrinking. Admins can check if new > pages are buffered by zswap by monitoring the pool_limit_hit counter. > > The name of sysfs tunable accept_thr_percent is unchanged as it is still > the stop condition of the shrinker. > The respective documentation is updated to describe the new behavior. > > Signed-off-by: Takero Funaki Taking a step back, could you benchmark and include relevant userspace-visible metrics to show: a) This is a problem happening in realistic-ish workloads. b) The solution shows improvements over the status quo. before we justify any extra complexity? This goes for pretty much the whole series (i.e why are we fixing this), but for this patch specifically, since we are optimizing things.