Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp49548lqt; Wed, 5 Jun 2024 16:59:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0d0EARNff2xVOqrxWWEd1Se49mhcP0vV5PuVYjejizcnS/jzHoxotOYHVGAINDSvZfI5fwxytMhRwWmuC4PCPeW1objpL1ZsfNhMpqQ== X-Google-Smtp-Source: AGHT+IF/JNznRQJcdC7yc8b3VVbkEY+gwY51hxri8oRw1wu59aBotTwmvp82KBf7ijJJkfvMdzig X-Received: by 2002:a17:90a:6581:b0:2ae:78cd:59fe with SMTP id 98e67ed59e1d1-2c27db53202mr4591672a91.31.1717631945632; Wed, 05 Jun 2024 16:59:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717631945; cv=pass; d=google.com; s=arc-20160816; b=WIAA+A73mgU8zYHX9JJ/6MyANIq7CXiGnoLf0uxth5KMYOkp6/oIeV9x007SNm0WRM vdYuJljfe2Rcfs6oNI9qhIDPOdzt/8hZhAnwQTZ6I0mpDY91J7boLqPdxfjbMuHGCG6r Ma8DpEJK2GEHjaxmCJDzebjY5pyzM2oHu2G7FK+p+/BFSt7cVZgkYjkFcSYYLFKjhQE1 pbt0TCH40STCug8S13FjAb4uQH7eahCgB/DdEjqhrt5FrqZZSN+jO8BfbaVtNeZWRc+3 gqRNuEwFJzxNLzto3tmgziGNh96hN8oGUfcu4AzwIsZXT55O9ISbqnwSAZc5FQQnJyu4 kT2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=Sf16gINAoan45PEw6aWCMW995aicLFXyStP7EDjqDE8=; fh=pqHc/ZPwv21l/SPBO1el8CfGTZR3Sbsp7B7bJfAycJQ=; b=QMFgCet12wAYNT2iqrnYdRPfqeNRNSPqA9sRFDb3yUYHwQvne/U77F/IsRASt9wydY cQdn0A517aKjWKdddXS2/xb49ieHHY0Cr9b7UH1LYEBNdBZRUddZcyo3A44p52ENWPL4 e1K+Ofsiz156Y9PYTsespwv6hsQlvAOfakiVLeZTeRV9nN+vsOJEYbe3KiiqpKuNPuBR 675r5ie2zd8BDk5j3PyIJ92ftgi2PHNhUUeU45g7aNKl/gZhul9OJ6WzZml+FhiiucTS f/A03Ft7qFNYYWobHkqCJAgkc0vEu4TWgP18virV60HcpAocY3OQPysQqK5z8YsubWxz TrBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EtTDplp8; 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-203438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c29c203590si207666a91.28.2024.06.05.16.59.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:59:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EtTDplp8; 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-203438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203438-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D4049B23167 for ; Wed, 5 Jun 2024 23:59:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAC8F168C1E; Wed, 5 Jun 2024 23:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EtTDplp8" Received: from mail-vs1-f41.google.com (mail-vs1-f41.google.com [209.85.217.41]) (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 5A28A15FA6E for ; Wed, 5 Jun 2024 23:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717631934; cv=none; b=t4Rbe5buF2iLI9uhOhxgLNwrbYjDW8AhUxXj7S8FCKMJaC0rVll6dcFe6OgodQ8rECd10UVoaNLhyO9//oJjPuIIUgAXLfwsmN/BbsyNmz50jLpk3g0SuALpspk2/Np7eUVmUhhA8FaYR3M+d4vwYVnEn8o4MtmMAndDG2+IzFY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717631934; c=relaxed/simple; bh=QPBgqVspIBUwRl4IGY0o6ZY+Mv81DcBFciWQfumKt0o=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BKi8ukdzRURQamEqULi/LqgTRASHsBeQWOAOAYXrYgiPj3tmiX1iV3+6C3hUo2FwD4uNPp+1LUf8aWm4K4zE4g+knUvu+BpYpnesXQY+QlNZh4MCoNEy4ZtBqj/6aaGmZI1JdTntkr63TiB22LIWkACtDZ9Z++j95hfkQ06pFcM= 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=EtTDplp8; arc=none smtp.client-ip=209.85.217.41 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-vs1-f41.google.com with SMTP id ada2fe7eead31-48bcd69919eso172072137.0 for ; Wed, 05 Jun 2024 16:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717631932; x=1718236732; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Sf16gINAoan45PEw6aWCMW995aicLFXyStP7EDjqDE8=; b=EtTDplp8mzgL79C36CvvEfB5wa8dEbOqPoQafkzKHrQQFIrSTiolZpvsO73ehpYTa6 BZJ0gYnS46yKGS0zWg3t4NBpETNjo0Dm0sbaQMhzrviMGQhRWdjtFjnwcxioC6I2IBo6 b7iUraD7p0JK3Uw+vSqhkZZqAjvzzQiQradF84ZyDHGWlw9MZA2oEv1Ce3MGe73gI9XM sLJrTRJFC2+bc+9UiNqOYDfNMNSrGxI49igViXuzF2Y2Lc65jTenZU0XqMoJBhhgZ7UE Ejs76l6xOUs2VIZriNDwU9Lku/Lhl4bOMwN6v16Ofw0JaGINi25cpX41UABUbf1sE9NE y4MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717631932; x=1718236732; h=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=Sf16gINAoan45PEw6aWCMW995aicLFXyStP7EDjqDE8=; b=hON39YgJlrGm/9u/EVYSk8LG78AEaMVG29hp/J/hKUh/iSTcj/EBVkZZFdUZ5UyhjY YHNpdmZgZ3WhEdIY9ryog24W5koL3mzJf58sqt6yeOYWia/76wLbbgEXj7SabEfWUGFd BPgOrV46IUtUNrcdEjejRV3wmZY8xCQMvncHJ4kGgK54oGTqZ9e2NLs9pwR+kVjFVCIK tx65hLEWLsFmiUsJsLdj4EoTrsRvLejZrHCWAweeGhhZC9ubQJvcaNIrJna/PQe8Byh2 DJza5C8W9z8NbzZuh/EWHaxoq85KR8GOVA2P1TDojdo/vgQq6Bm8z/igXjExtd9ezFKr FyGQ== X-Forwarded-Encrypted: i=1; AJvYcCW0T2HasWLhAKg9uAo58maQcqJh9PKxEp86tNbLw7NS4MgbpTx8aSGmE3xKO34jkzJAqSxXKpNu7P/lL6ks/nuPV72F1OKuk3Kvv9qA X-Gm-Message-State: AOJu0YyVM6cli/vBT5WIwMndVyCmmTVUC/8eZYDJwuU17eHMovoOGtsc HtLcYMfpud93x8qTsfHeZ2296EynvNqtrgR/WVsfvRjs7itcnVyh77qbCjDLpY2rvBaZKxP4eMA PTXIRQ1OvQhkvXINH4eYrG08WR/UB5BIMkqDj X-Received: by 2002:a67:f58e:0:b0:47b:fe0b:a92e with SMTP id ada2fe7eead31-48c04924d62mr4753406137.16.1717631931930; Wed, 05 Jun 2024 16:58:51 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240508202111.768b7a4d@yea> <20240515224524.1c8befbe@yea> <20240602200332.3e531ff1@yea> <20240604001304.5420284f@yea> <20240604134458.3ae4396a@yea> <20240604231019.18e2f373@yea> <20240606010431.2b33318c@yea> In-Reply-To: From: Yosry Ahmed Date: Wed, 5 Jun 2024 16:58:11 -0700 Message-ID: Subject: Re: kswapd0: page allocation failure: order:0, mode:0x820(GFP_ATOMIC), nodemask=(null),cpuset=/,mems_allowed=0 (Kernel v6.5.9, 32bit ppc) To: Yu Zhao Cc: Erhard Furtner , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Johannes Weiner , Nhat Pham , Chengming Zhou , Sergey Senozhatsky , Minchan Kim , "Vlastimil Babka (SUSE)" Content-Type: multipart/mixed; boundary="00000000000029497e061a2d592e" --00000000000029497e061a2d592e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 5, 2024 at 4:53=E2=80=AFPM Yu Zhao wrote: > > On Wed, Jun 5, 2024 at 5:42=E2=80=AFPM Yosry Ahmed wrote: > > > > On Wed, Jun 5, 2024 at 4:04=E2=80=AFPM Erhard Furtner wrote: > > > > > > On Tue, 4 Jun 2024 20:03:27 -0700 > > > Yosry Ahmed wrote: > > > > > > > Could you check if the attached patch helps? It basically changes t= he > > > > number of zpools from 32 to min(32, nr_cpus). > > > > > > Thanks! The patch does not fix the issue but it helps. > > > > > > Means I still get to see the 'kswapd0: page allocation failure' in th= e dmesg, a 'stress-ng-vm: page allocation failure' later on, another kswapd= 0 error later on, etc. _but_ the machine keeps running the workload, stays = usable via VNC and I get no hard crash any longer. > > > > > > Without patch kswapd0 error and hard crash (need to power-cycle) <3mi= n. With patch several kswapd0 errors but running for 2 hrs now. I double ch= ecked this to be sure. > > > > Thanks for trying this out. This is interesting, so even two zpools is > > too much fragmentation for your use case. > > Now I'm a little bit skeptical that the problem is due to fragmentation. > > > 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? > > I double checked that commit and didn't find anything wrong. If we are > all in the mood of getting to the bottom, can we try using only 1 > zpool while there are 2 available? I.e., Erhard, do you mind checking if Yu's diff below to use a single zpool fixes the problem completely? There is also an attached patch that does the same thing if this is easier to apply for you. > > static struct zpool *zswap_find_zpool(struct zswap_entry *entry) > { > - return entry->pool->zpools[hash_ptr(entry, ilog2(ZSWAP_NR_ZPOOLS))]; > + return entry->pool->zpools[0]; > } > > > In the long-term, I think we may want to address the lock contention > > in zsmalloc itself instead of zswap spawning multiple zpools. > > > > > > > > The patch did not apply cleanly on v6.9.3 so I applied it on v6.10-rc= 2. dmesg of the current v6.10-rc2 run attached. > > > > > > Regards, > > > Erhard --00000000000029497e061a2d592e Content-Type: application/octet-stream; name="0001-mm-zswap-set-ZSWAP_NR_ZPOOLS-to-1.patch" Content-Disposition: attachment; filename="0001-mm-zswap-set-ZSWAP_NR_ZPOOLS-to-1.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment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