Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp912089lqt; Fri, 7 Jun 2024 02:26:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV98ZT+uowsynJiMlXfg+mUc8NWw7ct9Hxw9fcHJjMV377o+acEfa8Q2khYp1XI3ORJjE6tm26NexcPawBC9IthoZ6GRYV2MfSywmrd1A== X-Google-Smtp-Source: AGHT+IFqstyo/r2X/7x36vsasLyIlh9KDhByO2ePxIlLJG1XUCHTiQMMebVZSFP5eHH6VihoiMP5 X-Received: by 2002:a05:6870:3282:b0:24f:ecd2:b753 with SMTP id 586e51a60fabf-25464e9ecdemr2038726fac.43.1717752402552; Fri, 07 Jun 2024 02:26:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717752402; cv=pass; d=google.com; s=arc-20160816; b=AmjQwFqSwlhP93ClSwpy2s98ns2/RbupZXi+RHVobCbdzWOSSYKychv+r218KUprMO IPUoE/oEX6L5juuFn0LUIeDhtebLQF40WJnSH0yxHCANA7I55Z9DoL2eRbHxVLrg7wfu 9bDOMYQWZRxuYc1Hn6eIhwRN/4wrY6Tdxz3wyAzWcgMF653+HjwZJ6Onf3GCLht5HGS8 qxOpYJwYKupujLjR43AXYhXmEF8uSAsKluMN5VUKaOVQ2Ozw8Mb2ZEbOXRlkyGXo52dC glfr9Blm2e8DTZ5P6IMOLKiak2WrSpr8v4UsQte+gYz/miJk3cOM3kZO4hC0uD4kcIrw C7RQ== 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=eIozoC5nwYY7upU/SpQMJJZkDEb64YetkVQTfRBe02U=; fh=kk5/BgTz2ndjkfsT20OjIEZYR87WpeswKs1hsjWIdBk=; b=McqnoFsj2UPWN6VdrgTO7l9q8LHM3UC3IU7IJdFdUeb/7itTC4Cu03XbpQS6E9peoL j//3PKPwLf4FFxhhgp7Q0chjPLv2vXIgewTXlhgXK4NI5Ym7wHZhHrkt/8tTIiTrqrfN U9u3xH16gloVxAnl0PF/XADsuRsF0N+HA1/zomPi1dlg2448W7mJ5UFXszyDadsasr1o s2DJzfPf4bFubz+SO1Mz/wN6f669mrKWwP9PGp6QRwEG0gFgupVLinKMNl4AKwa/psRH O4q21mPcbU3G+Q7D9P5IYnvAe2bGPjikRjEy6ST5EajyRYYLc0WbIrdohdiNfSrFyONL oIgw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fW2gcdnR; 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-205721-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205721-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de28860390si453966a12.579.2024.06.07.02.26.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 02:26:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205721-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fW2gcdnR; 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-205721-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205721-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6DADF288A6D for ; Fri, 7 Jun 2024 09:26:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E05BA15B986; Fri, 7 Jun 2024 09:26:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fW2gcdnR" Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (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 B744615B577 for ; Fri, 7 Jun 2024 09:26:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717752376; cv=none; b=hr7t4J4lnuMjhQ+sOvxi1rPpFOBqDjNsvnXcvYoyPygYUw6HFHJju3PWFpgPSPz6N+7XIDfi82PRbu5EHk5KJ0EHIbkFbI5uFzweErI2CGQU5/dWF58ffL2cDwTHFiOQo5OynQDlq9oQasSbwPucup8RkhClueoMcvdLMYx7eN4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717752376; c=relaxed/simple; bh=qiQBad0hXLeHHqlaTx1LR++dN0H67gnsXnKq8sMaJPo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=rwPma2KM0HIG+7YMuMYHucQGe9bdPMfzjhKYvam0SQlcwrhISEfm90S0xjqb0CDniqXi7k044lT+RIhSlqIC+N1WYYJh3CUq2lesoc58M4G8VXCOEfHrE1HsQKjrSLNkYcL+kVtCbxestpAhqLRkXhJC7inWuErr54zUi/lUnZc= 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=fW2gcdnR; arc=none smtp.client-ip=209.85.219.45 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-f45.google.com with SMTP id 6a1803df08f44-6ad86f3cc34so10210986d6.1 for ; Fri, 07 Jun 2024 02:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717752373; x=1718357173; 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=eIozoC5nwYY7upU/SpQMJJZkDEb64YetkVQTfRBe02U=; b=fW2gcdnRyOTMiRMu2xTQTx3zXV/aWzxmEvoIax/yZskf1xo6BME6MUA0TtoixkAxbW ote8VkpJdG9AWVQLDW+j3P9vXs0ykyldAR4YbC8YxAmj6rn7KBqlNhHCgulwHtRPff65 Lc0Mj63xRTjRr2tSHLznxW71+sXFc6fXprJppI3hQ7dbBMBSxW5fYGipJCCcfcXnIJIc R2W3n2YgH37C58uwUUX/zJXgohnbTEM21uBKxG5r2qPEvtp9QJcNP9a3fNvijkt/Ciez K5ZoaPBy7kf+QDB7r543uapzynYQx/AStrvNpCpexCNHjd18aLTt1cBAJxtQKYgrfjc+ MdqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717752373; x=1718357173; 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=eIozoC5nwYY7upU/SpQMJJZkDEb64YetkVQTfRBe02U=; b=HBvsCp/xsj8U2TlqaKz52eXSQyy/ABs7Lxl3PPJJVLSK8GNgQfUhBWQIW8bgYRDNgz 168vMJPdn7FkVoDmiXe+PSuNkCYEk852KIcrV4Bck2hdnq3CaVXsai17ZWL5Z9YDeRu8 1rCV0z4nzxLSWO08sTAnY+93tgqyrqxL8VoMkzAUEVQ1L1GrTgfdDDeHhH77cUHUCTcY qhe70U2TASyLa4IVWzhz5pO1ToQ0fZEQQgELPOyM77Najc48lU5kx8xzVQCnhLFenKJ6 KlPOFjx6xpZ/89LJrEk7CDAF69StLtaM9iVu/iBjBkcwqO3q9yCuHrmWGhhtF5U1IJ8S 6lpg== X-Forwarded-Encrypted: i=1; AJvYcCW+S904Gzs69RbIcPD5tlhhHYVgAY/i/Iqz2p3x5haDBE8TYVKeATZU3eH8wZ+0605uXXOec8sHRFtor6h2OqQNeH0jj8woxv6JR/Zq X-Gm-Message-State: AOJu0YyVU779zJZ38UJNg+ffdp+ib602SfD1/72rT1gHRQKk7rV9YMgY 3R4d2iRwrRwX9saP2LqUtETnjV0CNYVtk+sxnP3wKuKMRtc1LlIwAX8l/0Bszsu5yGRVso+VLrT gD+6RE01HZbFkPeFVDbeAQV19pAc= X-Received: by 2002:a05:6214:3d9d:b0:6af:c66a:d5a8 with SMTP id 6a1803df08f44-6b059f65400mr21667096d6.51.1717752373411; Fri, 07 Jun 2024 02:26:13 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240606165303.431215-1-flintglass@gmail.com> In-Reply-To: <20240606165303.431215-1-flintglass@gmail.com> From: Nhat Pham Date: Fri, 7 Jun 2024 10:26:02 +0100 Message-ID: Subject: Re: [PATCH] mm: zswap: limit number of zpools based on CPU and RAM To: Takero Funaki Cc: Johannes Weiner , Yosry Ahmed , Chengming Zhou , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 6, 2024 at 5:53=E2=80=AFPM Takero Funaki = wrote: > > This patch limits the number of zpools used by zswap on smaller systems. > > Currently, zswap allocates 32 pools unconditionally. This was > implemented to reduce contention on per-zpool locks. However, it incurs > allocation overhead by distributing pages across pools, wasting memory > on systems with fewer CPUs and less RAM. > > This patch allocates approximately 2*CPU zpools, with a minimum of 1 > zpool for single-CPU systems and up to 32 zpools for systems with 16 or > more CPUs. This number is sufficient to keep the probability of > busy-waiting by a thread under 40%. The upper limit of 32 zpools remains > unchanged. > > For memory, it limits to 1 zpool per 60MB of memory for the 20% default > max pool size limit, assuming the best case with no fragmentation in > zspages. It expects 90% pool usage for zsmalloc. > > Signed-off-by: Takero Funaki > --- I think this needs benchmarking. Theoretical justification is nice, but I'm not convinced it'll translate neatly to the messy world of real life systems.