Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp56853lqt; Wed, 5 Jun 2024 17:14:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWU91eUcyNVp77DVRLWNcMLbQ42lzG+gYImuSxtfwcWnwPp7w4tsPueF5GxH6LMiTPt2gXPwWWTZ9/MUfWOkIAQHhNYVQOIs3Xa3b5FTA== X-Google-Smtp-Source: AGHT+IEODZLPu0JiBBYLgFUwBeNMa/LxZYYFus0KoVi39yEAXWAVlrBRMwUWr25DkSL4sj3G4YRY X-Received: by 2002:a17:907:900a:b0:a68:cf56:aaed with SMTP id a640c23a62f3a-a69a0017b52mr233760766b.74.1717632884810; Wed, 05 Jun 2024 17:14:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717632884; cv=pass; d=google.com; s=arc-20160816; b=eIzzYBck4bUMOGJN/sW/R2LU5TXeLoP15V2G9MTgq5UITFUYMNFCOFZCJErpba3jQZ 13n9GaKnucMSXt5BYJQ1i0aHeaKbhc1yMWacOQe6oXyB73xivEaPNWUS8hcoP55ITt0G zuxO1y6wocwhVN0Z47CT5E4k6Hz2cVPBQkUmpbO4JIFfWVE/geT5ycNOaOwpfRCnEvKz aRs00wy7BXdYQlKaumKry6P+lLoxANp65pMZFa2iI2h7hOY3mIYh5P7rwI9ERnaYbjjU RdZAf+HiV/MTvxflcTdVGhnvnpGR+Wz8gCpKLtRJHa7EZJ9kXzZFFQnyJcVJrBCgZVEI ukew== 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=odPagFywCeLVckyJ7u7Ej1gNPxTHuemqTZ9yer+TyAs=; fh=FJLPapjYJHbOeT1y4G2cKyrxc5IkIqnfNXqsVhE0yLc=; b=KkMzlvGonqfD1FYe17ufJ2Wmw7VLCvmznI+TIxVvvxIBzeWnPY4rnZDGGlAxqps+kE 7C1D6CjqJj/eLjYGdI2SmF0U2P+g+lqNgd57q17pEnRgAy/2+GZvzS9l+8Zv9IjoOPmJ 8a8M3XZLnCd3a67XBD00uw6Qdbbin276e8adVbQ5hYcM409wmqH4ixwRIzN6fd6XO6xN FIMWwEMG/OSqUomQHLnOYV08qKL5m6pPQ9101k1lUlbvFwcRE3YMa445XQRFmIzh8DK6 qgsy5mZQDA2J0jtZGClJ0dxYknVHypCiz/34vuQ3lx/c/cxW1PwovDn3EfJwz0ci71Bb q8XQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=LyLBvvYs; 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-203435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c8058d561si7564966b.163.2024.06.05.17.14.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 17:14:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=LyLBvvYs; 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-203435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203435-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 588211F29150 for ; Wed, 5 Jun 2024 23:55:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B03D5169364; Wed, 5 Jun 2024 23:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LyLBvvYs" Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 17C0B168C0A for ; Wed, 5 Jun 2024 23:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717631595; cv=none; b=iYXx2D4XAglQ7SAoMKnTSMRqIdX9pIKSOULdPLcND/rfl51e7Sjc6XW6+qOLg5ikgqk/9J5iiqfa3OhX9gu/+/LvgnCaihbORQeKSstPX2KoLCquizGELG+btWRO/bKSQ04lYOyVn3UbUr+KNf1OoAe3YEQb0mH6HutE5Va8c8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717631595; c=relaxed/simple; bh=odPagFywCeLVckyJ7u7Ej1gNPxTHuemqTZ9yer+TyAs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=k44NL+THN4JYMe+8Ow8Or7FDSxEv81jk7Yx3s1FQZV+aRQHTGS2xb2SimJ9k6naxA+lU3Xzx0DIi4xdAxoYr07IQHiwfeaAO0O59C/dd9J5wXtghi0eNeRcqQxLQIzGAD4pGR6TKQxknQ1BIRD0D4nmKiDH0T1kKXyz3sgc1knw= 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=LyLBvvYs; arc=none smtp.client-ip=209.85.128.48 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-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42152bb7b81so33155e9.0 for ; Wed, 05 Jun 2024 16:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717631592; x=1718236392; 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=odPagFywCeLVckyJ7u7Ej1gNPxTHuemqTZ9yer+TyAs=; b=LyLBvvYs72ZG0wd8n5nNZQVQoeZW2nz9VXT/p3xru9l6wnKF8a3bGC+PkWKQ/GVI1R XGE9FH1VQgYmKhdC3JkpBymc04QBqhm81fUflG7TqXlaySzc+nT7/167CAU+PsjafHNf hFrKMGqvOykbrQtvzFkNAxFQJ+qCz0sDrN6fEKI3XFBr+6ApkZtVdNaPlFg1/+n/zjhn VOuXqXC6VbK42yQieaG65zxBANarFwYR4H+mUpvTjuNKdvOv3zFx6hhW0iSnbGr+eWGM TO4iYmfl3i8L2cO5ytp3b2av25whBqDFVPuPe+P6+VMk+VLK7zJ0aUOu4GUSb6O7X7sl y0Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717631592; x=1718236392; 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=odPagFywCeLVckyJ7u7Ej1gNPxTHuemqTZ9yer+TyAs=; b=cnmjPMaug1gp71jtXet+o8OGrGb3dF6DborTb4v/+9//Tw/QajIP9GeevkLeiN9mOS /PqfGmHambPRgP1fRaMH08Lzr3R1pMhIDrPhWRVBITpQAb2xrFq7TpEoCJTpxXS0dWy/ yKGiFa5IdDc3J3Ar3DKMbLqppK5966HdD65HaA8BeCgCV35YjGyP+9ZX8RMqL4x+tcal o6iTrrw9yTVTjymlB/yMZklGachE9TbNoYupYqbTcPw6sQtMHNj/2roVa+0NYo7RLSc7 Ezh7APj4rQk3jwxAyLpodBAY4YgUBznLMbDOvwAOyfbe1FOukUGE7SpboiQhsj/1r4VN e2tA== X-Forwarded-Encrypted: i=1; AJvYcCWO8jxLbbyj1vhe02c/omLICCnIB2c54LMecUMIOLudTZZSzlkRcOVxuLVxXIU0WFHYnXqtBAbazWZm12SkHjzLIm0au0rvRrXqg56N X-Gm-Message-State: AOJu0YxfU8lOnNci0gPNQaTnhIUSFOvUBoZ/4L6mNruQT6bZBnZw1tL1 4t3NVE4w5xO3bBhXfY1rZfB1E4AHeCk0XlcjS/zFsa5CXlZSP+0Boz48B6HZlBVF3HeoCfRILix yiLADWKQoBZl/lXYQUTe0ACDObFcP+iA9XCHL X-Received: by 2002:a05:600c:3ba9:b0:41c:ab7:f9af with SMTP id 5b1f17b1804b1-4215c0da3e7mr514005e9.3.1717631592034; Wed, 05 Jun 2024 16:53:12 -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: Yu Zhao Date: Wed, 5 Jun 2024 17:52:34 -0600 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: Yosry Ahmed 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: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 the > > > 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 the = dmesg, a 'stress-ng-vm: page allocation failure' later on, another kswapd0 = error later on, etc. _but_ the machine keeps running the workload, stays us= able via VNC and I get no hard crash any longer. > > > > Without patch kswapd0 error and hard crash (need to power-cycle) <3min.= With patch several kswapd0 errors but running for 2 hrs now. I double chec= ked 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., 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-rc2.= dmesg of the current v6.10-rc2 run attached. > > > > Regards, > > Erhard