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 D6A86C25B75 for ; Thu, 6 Jun 2024 04:32:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1F096B009B; Thu, 6 Jun 2024 00:32:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCEC06B009C; Thu, 6 Jun 2024 00:32:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C70F36B009D; Thu, 6 Jun 2024 00:32:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A9E596B009B for ; Thu, 6 Jun 2024 00:32:06 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 46F3DC02C8 for ; Thu, 6 Jun 2024 04:32:06 +0000 (UTC) X-FDA: 82199191452.10.56D03F5 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf21.hostedemail.com (Postfix) with ESMTP id 4E3FC1C0005 for ; Thu, 6 Jun 2024 04:32:04 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=eUW6pPAK; spf=pass (imf21.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.44 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717648324; a=rsa-sha256; cv=none; b=nBtD3IuQZ7jeD+3Lc8/ZSrJX0ILBE96PKGs4gGjStuLEbC61Dbag40gMa/lmiU2l/o8L+i t9Rm8vgly3+DyZofD8wEsGK08rH9YtpTo6fI8g9jBdgPOAsgOsoes2JHm9JYw6vbcSH+XP 65ypwZWpXTfbqqdP6kJKkouBtgLOhpo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=eUW6pPAK; spf=pass (imf21.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.44 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717648324; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=e5O/KPBawU1WK3EGBuiDZMDOrb6/M6TI7wnGL7CoNe4=; b=KfO80EL4iar8D06jzk0iOdu5DQAShgY/jqAPKahJO3xl8Cvs8Xx9r4ZY0/VfSS2tEF+6mP 8ciWA94CG1dhCteldXRGZPYwf0ytC4EnHEbluhboOaAw50pbAeDbTi0RGnr0SO0p3OvPK+ Id41RD4wrvGYnqiSJfr03kZrUdCGFAQ= Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2c24115469bso1226756a91.0 for ; Wed, 05 Jun 2024 21:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1717648323; x=1718253123; darn=kvack.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=e5O/KPBawU1WK3EGBuiDZMDOrb6/M6TI7wnGL7CoNe4=; b=eUW6pPAKvz2uj8/V4IeQJZ/9R6kSzB+jGYPCwq5D+oWfJVQV+p067QQkSCfxzTG7oS uEX7L5T2OTnjpoioIm8hA3STB99ZVD8/G9jOtUhJ2HvayMpe4k9Doc4GmjdTNaDmN25i gWhab/lPF64mBggMGSLkze60v5/80/9TICheA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717648323; x=1718253123; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=e5O/KPBawU1WK3EGBuiDZMDOrb6/M6TI7wnGL7CoNe4=; b=r2hY6mBEQl/nQF5tres/JToUTnypcdAXy6V+3Aqbq274a91MPFU8xaLcgwwQDjYNSv v5jWyg1Z+DjVWy2BiBFfK8rPWKvgj1OKilK1opn8/cylrI9gLwstDYE3/VjfYNxSr1AZ SgvW3zJjKLchzGYOXHw9i7ojrcvjNTHsvLutYSgJM5urIKdx0r7Shpp4eWLelw5BNDjC jaq7o56EHsRDK5PMQic/JUM7iwYDIZdKDv8JDCRIhI3zwzxdhrPgFAYMYkV/KdSNTFFE 6ykvSeSxP6+Njm/0q7+I3jLnSuyf6R9si6h/um2Mm/hzVIF/yNnfZ9W3ULEEvoFwWIm4 83GA== X-Forwarded-Encrypted: i=1; AJvYcCVRyXv/weZtqZgPwmnf9tY9YFvLsvAnswq8qs/Y3bO4+AKNkWO2DkR2VBAR1aocWOw9JVag7u/pMkFnTwsv7ntLZk0= X-Gm-Message-State: AOJu0YzR2OIxQGunw/5Qn2IgpsfeZ0KDxcyhKYAf+80aCOrBAAluCvzh izLGtmOYvV0izNMuxXHaa8d9e4gaGsiOuA9A+dZC4J0+x+H+807oEYbIyZewQQ== X-Google-Smtp-Source: AGHT+IGeGRNGy0Xw3Akts/lPFVIgXije/S+Ayuxc+gSupT7N6SirKbQGyrs2QN0KZ/uVluqHP+feAg== X-Received: by 2002:a17:90a:ea8f:b0:2b4:329e:eabd with SMTP id 98e67ed59e1d1-2c29997370cmr2096719a91.2.1717648322998; Wed, 05 Jun 2024 21:32:02 -0700 (PDT) Received: from google.com ([2401:fa00:8f:203:22f8:8e4a:7027:de56]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c28063a7fcsm2418151a91.7.2024.06.05.21.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 21:32:02 -0700 (PDT) Date: Thu, 6 Jun 2024 13:31:56 +0900 From: Sergey Senozhatsky To: Chengming Zhou Cc: Yosry Ahmed , Erhard Furtner , Yu Zhao , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Johannes Weiner , Nhat Pham , Sergey Senozhatsky , Minchan Kim , "Vlastimil Babka (SUSE)" Subject: Re: kswapd0: page allocation failure: order:0, mode:0x820(GFP_ATOMIC), nodemask=(null),cpuset=/,mems_allowed=0 (Kernel v6.5.9, 32bit ppc) Message-ID: <20240606043156.GC11718@google.com> References: <20240604231019.18e2f373@yea> <20240606010431.2b33318c@yea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4E3FC1C0005 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: ujh4undhh9at1kwfzgghyozxb37w7szo X-HE-Tag: 1717648324-180590 X-HE-Meta: U2FsdGVkX18ptuTMvbfJCkcczoBqJGvnLLz/g9u6xhzM+3m6HF7yLUg4h7VVA7kjSETX7O13RWiwEhNZ8Oai9SAYnACXvPi1ZhVHsmOgGsA0Ur2VTFAFVdNKGwR2PXTr/6vggP/OE6Vtm6bwQ7LqXzSVPRfAU9ECbaGrd4vRIkEmNLzCtZBJZZ9EkOB2kt0jmzZbJxWU1USUtwhExjVTrOHGlN/0Vz6ve1TdRX9xdkOCQtzW6KNopBDYQj9GNZQa4AZ8l1oQ4/6M6J9nrwJGAbY8U6QhJGVzljcuWl8t3ee89w6IWlO6GzfhHSOhYJbeGEMy/ZnLdmK5Wqyi7XdnhFokwa++eg+bWFSOAE8P7Xhvkgkx84U4jh12RAjwZXoTwivHoLUBU581mUcGrDbQo6RvAEowWNwYeXtnXjkZzj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VTfFg+fk69xxqE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 (24/06/06 10:49), Chengming Zhou wrote: > > Thanks for trying this out. This is interesting, so even two zpools is > > too much fragmentation for your use case. > > > > I think there are multiple ways to go forward here: > > (a) Make the number of zpools a config option, leave the default as > > 32, but allow special use cases to set it to 1 or similar. This is > > probably not preferable because it is not clear to users how to set > > it, but the idea is that no one will have to set it except special use > > cases such as Erhard's (who will want to set it to 1 in this case). > > > > (b) Make the number of zpools scale linearly with the number of CPUs. > > Maybe something like nr_cpus/4 or nr_cpus/8. The problem with this > > approach is that with a large number of CPUs, too many zpools will > > start having diminishing returns. Fragmentation will keep increasing, > > while the scalability/concurrency gains will diminish. > > > > (c) Make the number of zpools scale logarithmically with the number of > > CPUs. Maybe something like 4log2(nr_cpus). This will keep the number > > of zpools from increasing too much and close to the status quo. The > > problem is that at a small number of CPUs (e.g. 2), 4log2(nr_cpus) > > will actually give a nr_zpools > nr_cpus. So we will need to come up > > with a more fancy magic equation (e.g. 4log2(nr_cpus/4)). > > > > (d) Make the number of zpools scale linearly with memory. This makes > > more sense than scaling with CPUs because increasing the number of > > zpools increases fragmentation, so it makes sense to limit it by the > > available memory. This is also more consistent with other magic > > numbers we have (e.g. SWAP_ADDRESS_SPACE_SHIFT). > > > > The problem is that unlike zswap trees, the zswap pool is not > > connected to the swapfile size, so we don't have an indication for how > > much memory will be in the zswap pool. We can scale the number of > > zpools with the entire memory on the machine during boot, but this > > seems like it would be difficult to figure out, and will not take into > > consideration memory hotplugging and the zswap global limit changing. > > > > (e) A creative mix of the above. > > > > (f) Something else (probably simpler). > > > > I am personally leaning toward (c), but I want to hear the opinions of > > other people here. Yu, Vlastimil, Johannes, Nhat? Anyone else? > > > > In the long-term, I think we may want to address the lock contention > > in zsmalloc itself instead of zswap spawning multiple zpools. Sorry, I'm sure I'm not following this discussion closely enough, has the lock contention been demonstrated/proved somehow? lock-stats? > Agree, I think we should try to improve locking scalability of zsmalloc. > I have some thoughts to share, no code or test data yet: > > 1. First, we can change the pool global lock to per-class lock, which > is more fine-grained. Commit c0547d0b6a4b6 "zsmalloc: consolidate zs_pool's migrate_lock and size_class's locks" [1] claimed no significant difference between class->lock and pool->lock. [1] https://lkml.kernel.org/r/20221128191616.1261026-4-nphamcs@gmail.com