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 DF615C2BD09 for ; Thu, 27 Jun 2024 10:36:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 535F86B0088; Thu, 27 Jun 2024 06:36:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E50E6B0089; Thu, 27 Jun 2024 06:36:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35EE16B008A; Thu, 27 Jun 2024 06:36:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1656D6B0088 for ; Thu, 27 Jun 2024 06:36:42 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 882EEA4234 for ; Thu, 27 Jun 2024 10:36:41 +0000 (UTC) X-FDA: 82276315002.26.07079D6 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by imf21.hostedemail.com (Postfix) with ESMTP id AF3DA1C0012 for ; Thu, 27 Jun 2024 10:36:39 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=2SVFvjeR; spf=pass (imf21.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.169 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719484586; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LmmTw3VCwIDGot6aMjbOAraGI3hpxG9i1KkAlI0khG8=; b=7sCS0GEK2eFkm+LZjxjiT0Vklz5+2D7K5Yu16w869GWcj6Z5rJMZcZACRtvFCKYUWbpSRQ qXjv5b0zYjzDMecdVR7lJSv/+SIc/9KBBXVhEfseAnjKYYhqXRSNgAtxRajFsSE+167HHc 5ST4ninj0HtAkCq6cSPRVXSavbgL0hY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=2SVFvjeR; spf=pass (imf21.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.169 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719484586; a=rsa-sha256; cv=none; b=jZKPe0QRfQ/RhjGZURNCQor3pGeNw3Fpdga4c1FrZCzBs31ZFMzs+NEiUKgMSyoJZmlQsw 0zXcNDnK8pe1rvIYmPe3PRLuTzmuF+SGOIjXuRRreu4v6xBlANv5dvnWZAgrxDZGLlh01i fKTizya2EFmn34cama1X/c88AIKLE20= Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2eaea28868dso103860861fa.3 for ; Thu, 27 Jun 2024 03:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719484598; x=1720089398; darn=kvack.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=LmmTw3VCwIDGot6aMjbOAraGI3hpxG9i1KkAlI0khG8=; b=2SVFvjeR5/F/jUbtT2Qk6QiGK/DdqiZGeNVD9Kq3R7zufK4Q9QY3h+e42R7xSCUoQl U2qCz0KODOAqEwiRtSieQjblXknb5HOAHSUJSFndtTfQIDpKWHoSk+KsTcTmUgnSdgBl NtjcPB1yCABX1vXk4evU3ob9c15z9oVhknyssCxmDwTkp/LpNAYVtLbSfyPqDjrTUW4V K8/f5Fv3YbPiOCiOXK1uNoFN9YnzKGfJzgnU/vKMDnKGoRyWs2m9zEmn4+6Pw5j6Kyty Pqe3bV8TOkVuszKHt914vY1mhuBiL7iTsa7zaTOpdVzsT26IN9wDIWYVuGQOdx9/CGR2 hzXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719484598; x=1720089398; 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=LmmTw3VCwIDGot6aMjbOAraGI3hpxG9i1KkAlI0khG8=; b=gdp4pm0yYG18loFeOSkuaNyuTLdndHuLWc2K+qmayusdYM/Y5FYmyU1b/VdAV0mu0a /n+gMPenZQCKDCLyDCrBad3u/47OLtuHkjnM1gk2y4tj5Bem8d+I7S6igkaYWBafsLc7 bW51g1cd2kn3ucnMDZLqI9Rc85rEU6cjKR8cGZVHDVoQQxDefdjQhFAKrMzZqD4O3Jtu j0f8zrafOcD1EbFgRX1hoZEbOHE537L7S/NWCK6dlJ6opjvqF71HsXMXzXZTJmWOQVCQ 93pLOdFEWo/B/njsP1WybIXq8WfRvj8CoY7FaMnvYxFT5P03z7JjiKXtU2czlZJiAyRx kqIg== X-Forwarded-Encrypted: i=1; AJvYcCXV6dZYYcousCvKSKXN0sltTfRA6rexORwJN+WgKliCV+JZm3pzmggfTDbrCRo0umtbSMJBUxIJmcycSiLqmyuOhSA= X-Gm-Message-State: AOJu0Yy2caD4tpKSFduAPw9PH80aa834sW+Elin087i3thwajp2f4UUk yUBe1wSXriDvUcG3z4Wc70U+AyFgLdAhxVNLLXrBqgSWZEamKQxnc2GqtrKcRZFDVqITJpVRpZ0 kY34beBS0I1mwiEuYu2UFBzYpR2k6dwUTGFyj X-Google-Smtp-Source: AGHT+IHRuI3bm5oLeNY23Y3s5LjnQgEJkd2uPyO/1Xl0pgD6QXuNuygP4qwyIwyLSKtflIcqEWxFFIXImPdDuWrJedk= X-Received: by 2002:a2e:9213:0:b0:2ec:5843:2fb8 with SMTP id 38308e7fff4ca-2ec5b31d126mr99844701fa.42.1719484597470; Thu, 27 Jun 2024 03:36:37 -0700 (PDT) MIME-Version: 1.0 References: <43732a44-1f90-4119-9e52-000b5a6a2f99@kernel.org> In-Reply-To: From: Yosry Ahmed Date: Thu, 27 Jun 2024 03:36:01 -0700 Message-ID: Subject: Re: [PATCH V2] cgroup/rstat: Avoid thundering herd problem by kswapd across NUMA nodes To: Jesper Dangaard Brouer Cc: "Christoph Lameter (Ampere)" , Shakeel Butt , tj@kernel.org, cgroups@vger.kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com, longman@redhat.com, kernel-team@cloudflare.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: eii1iboktwhq7h7oo3fp8fz4pbomgqnu X-Rspam-User: X-Rspamd-Queue-Id: AF3DA1C0012 X-Rspamd-Server: rspam02 X-HE-Tag: 1719484599-795333 X-HE-Meta: U2FsdGVkX1+SrnDAM9yWAp5AFz5kb2Bz6L7Zf/IKxHd0OSF3xbM9ezVlwIpXeRER6UfxMfEiaeWk62TVtJGWL6Bd5/1J1zkRXgBVIzHl8965XmHMG2RnFwl3sHhjqtU/z5NwZyqfs/E7CUefNi9K6ATWWR+4HEKwuVFsvRtdVcivEvu9grjSW5se3UHFI/3+/MghfV2kNMvURSRXUyBBHquGdvl4DFWOjp1KXwKhxNV6SaxIa9V5nrwi9BN24xoIaRCyk6fOUrg3AUstk2MWwYLIUXEYoLoGf6FPVZeDSP/+pm2lS2O//OFzQxpNcINb4PLF3NQugJoeFLTEvFucAnmOKhVMTumCcER7/3Qt9pNGTdQjdVTDz8vQBjl5G5R+H17GAsP5Zzx/IotLcgv6ZfMn3G/qPK7OXgACLwho8SoIXnRudYSq7Gr4ZLtvHrwUtgEB3CInhz0yI7MUDC7O57oPNfYt/WSsQpS1z/SOehomoMq0X8hSgNhzhxffqYUebiK618bflbm3Uy35xBngbJi3JNy/E0jrG7BWWS305IDCqmUUfHiZUE3hEBpFE51MuWSz4pTjnVEjDsYaX1lOmssW2cLN2I0BqV92RyObHoa1ELrQc9XPvRAt/AA7gI9vfxt1613g5bUzLqZ7BHyw/MYCUsMeA8gnqkImwKOwJRKposeMKms40GW5D+lFR6PHZcqwXPdnCpG43+5u8yy56DbQ8j67bQRl+GEfMzq1znGKDMgOrXYcB3OmNMl+y+bJ9683iU4EKBaPamWKltc5Lr1ra9nWEFB6XKQ0uFEiZQHqMkosXe9IQOdlKZFZik9fWPeZP8k7IlPEdrBjWZjW5TbwTQ77VbSvt/igBOioXw6ICTaUIlOfGF9a4jeomwUIYKa6QMvQzq/jkYDy0+Dv9CJXc4e/kPHKcIloNL1s1TDeHyhjVxZqVOsOTLVaYsyVvc1wMXoG3NU9zG1fbXR sXAvuzBq jZT2zie/+gRx4fNHOHuYGFIZwqBsQDxI2px7poispVtD4ohRZy95MaRxP/RDfpw4uJ//EMYb+1EtX452yCvRAYnGfaB9yVtqs+QFbdOdL13i2iQn3y8udT+dOatFse7jnlQ5emWzCxXmVQAspmPPR1n5rpznxMjsbbzOlbPb9gv+YhwwOPRohzXaJvN4rhJETgY9U5gE8O4sI/Kgm0StomXl90KohauU++LIRYYU3l/wOv8c2R+5zhUfKiyXRkWHuStUpjx9MgmSj0JRCphWzsrBcMJ67aTk3bl0+ X-Bogosity: Ham, tests=bogofilter, spamicity=0.008533, 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 Thu, Jun 27, 2024 at 2:21=E2=80=AFAM Jesper Dangaard Brouer wrote: > > > On 27/06/2024 00.07, Yosry Ahmed wrote: > > On Wed, Jun 26, 2024 at 2:35=E2=80=AFPM Jesper Dangaard Brouer wrote: > >> > >> On 26/06/2024 00.59, Yosry Ahmed wrote: > >>> On Tue, Jun 25, 2024 at 3:35=E2=80=AFPM Christoph Lameter (Ampere) wrote: > >>>> > >>>> On Tue, 25 Jun 2024, Yosry Ahmed wrote: > >>>> > [...] > >> > >> I implemented a variant using completions as Yosry asked for: > >> > >> [V3] https://lore.kernel.org/all/171943668946.1638606.1320095353103578= 332.stgit@firesoul/ > > > > Thanks! I will take a look at this a little bit later. I am wondering > > if you could verify if that solution fixes the problem with kswapd > > flushing? > > I will deploy V3 on some production metals and report back in that thread= . > > For this patch V2, I already have some results that show it solves the > kswapd lock contention. Attaching grafana screenshot comparing two > machines without/with this V2 patch. Green (16m1253) without patch, and > Yellow line (16m1254) with patched kernel. These machines have 12 NUMA > nodes and thus 12 kswapd threads, and CPU time is summed for these thread= s. Thanks for the data! Looking forward to whether v3 also fixes the problem. I think it should, especially with the timeout, but let's see :) > > Zooming in with perf record we can also see the lock contention is gone. > - sudo perf record -g -p $(pgrep -d, kswapd) -F 499 sleep 60 > - sudo perf report --no-children --call-graph graph,0.01,callee > --sort symbol > > > On a machine (16m1254) with this V2 patch: > > Samples: 7K of event 'cycles:P', Event count (approx.): 61228473670 > Overhead Symbol > + 8.28% [k] mem_cgroup_css_rstat_flush > + 6.69% [k] xfs_perag_get_tag > + 6.51% [k] radix_tree_next_chunk > + 5.09% [k] queued_spin_lock_slowpath > + 3.94% [k] srso_alias_safe_ret > + 3.62% [k] srso_alias_return_thunk > + 3.11% [k] super_cache_count > + 2.96% [k] mem_cgroup_iter > + 2.95% [k] down_read_trylock > + 2.48% [k] shrink_lruvec > + 2.12% [k] isolate_lru_folios > + 1.76% [k] dentry_lru_isolate > + 1.74% [k] radix_tree_gang_lookup_tag > > > On a machine (16m1253) without patch: > > Samples: 65K of event 'cycles:P', Event count (approx.): 492125554022 > Overhead SymbolCoverage] > + 55.84% [k] queued_spin_lock_slowpath > - 55.80% queued_spin_lock_slowpath > + 53.10% __cgroup_rstat_lock > + 2.63% evict > + 7.06% [k] mem_cgroup_css_rstat_flush > + 2.07% [k] page_vma_mapped_walk > + 1.76% [k] invalid_folio_referenced_vma > + 1.72% [k] srso_alias_safe_ret > + 1.37% [k] shrink_lruvec > + 1.23% [k] srso_alias_return_thunk > + 1.17% [k] down_read_trylock > + 0.98% [k] perf_adjust_freq_unthr_context > + 0.97% [k] super_cache_count > > I think this (clearly) shows that the patch works and eliminates kswapd > lock contention. > > --Jesper