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 D5E25C36014 for ; Tue, 1 Apr 2025 15:46:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FE95280002; Tue, 1 Apr 2025 11:46:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98638280001; Tue, 1 Apr 2025 11:46:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 800F6280002; Tue, 1 Apr 2025 11:46:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 62DFF280001 for ; Tue, 1 Apr 2025 11:46:58 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4E91A80420 for ; Tue, 1 Apr 2025 15:46:58 +0000 (UTC) X-FDA: 83285903316.06.3448461 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by imf01.hostedemail.com (Postfix) with ESMTP id 499AD4000F for ; Tue, 1 Apr 2025 15:46:56 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Va3ogcJq; spf=pass (imf01.hostedemail.com: domain of mjguzik@gmail.com designates 209.85.218.52 as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743522416; 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=2exn8/g/zCy7m9Fb6N5nhJsO1TkWXtqg+gMexa3uIWs=; b=XjDxkw2cjcCSq8J4iJPDikHPXpCXvZ7vzV0nOpmvc2cjndqxKROcqohxOz6MAYs+UGlZhu jLpwveJi3PjwCa4x0aTTwwl9Wo6jg0TPbin9+mG24cfMg4DfkBh6K2ztpBZVfPCeHv0b1n MxvJw2IFDftTlYYEYKieS6qNwm380O4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Va3ogcJq; spf=pass (imf01.hostedemail.com: domain of mjguzik@gmail.com designates 209.85.218.52 as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743522416; a=rsa-sha256; cv=none; b=hS7zxY3+xyouOCI0ujvso/eO7NW/wLCTEj3gY4wxqSArRlYnLa2c9F8YVg3sAE/9GmkF00 4aiGsoEhECkK6XR4DVv5DymHZrHy0enXdvGwSqcFVBB2VhwEeH6Pn5TCR3QkTv58FbUeMq hyrXJW8LZVInVlAyuQpgXHyuJLlMI18= Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-aaf0f1adef8so793633066b.3 for ; Tue, 01 Apr 2025 08:46:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743522415; x=1744127215; 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=2exn8/g/zCy7m9Fb6N5nhJsO1TkWXtqg+gMexa3uIWs=; b=Va3ogcJqoebbzk82Ns1Luj9yfO4y0PTJY5yXyV358SteUIUTtD8qFDWLhr4nxwU7it SPJFJ/nzocJ7lKUQtjFH2F4QZRpKAEWTqpZPCanBMDI9GBnIwDxUZWyDkWu9iICqDQBn w3ZP/zBRIJx4XVVgH25V7C4KzyQBb2wm7E4YDMEud4a6tQDXemby9vJdt3rtQX0r/vR8 fN2zFzwm2LvLMXYCmnioiyOTCSKlM3d1venA2mqeHxkz2NAcWOdfNfk7uRjN52cV5uMX UtA+aDyF77zFoi/hC3QkVACuI/id0N7OK4mTR5M+RR32M9EP6t1MbVVpJmfhIO35DI1C Vm4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743522415; x=1744127215; 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=2exn8/g/zCy7m9Fb6N5nhJsO1TkWXtqg+gMexa3uIWs=; b=FyBtk/X9rLyjyhJ8CbeEed7yNdc06pjI4ovUQgAMFZlhtlA5eU/BnNxxYn6W8UH8KX 9795tY+dR5Z4eBgEGJwV4Gs9bLLL6fEEGq5NrK9EOMmCnD447ju3/ASErhRDa8P+GF/R EncOfB7WeqUjIqGO6TxG5aTYNlPjjZ4BU2ID6GKEKFtX2MnS+kUqY8Fm5D/C4rCNfip/ idrJJbE8t+TSGoL+/KlOdBo+qM3Euv67yS3ROD2Q1XCZveOWaAmGyETBlqW3E6GESnC7 KbZsK5SgEJjdbNHvXKIR2LNum81mWR2bCv6bZ4qoPGu4hZO6tZnjIEvVJmUy1eJma+PY nX7w== X-Forwarded-Encrypted: i=1; AJvYcCXLwbD226NBVEmu+fuapefgW+GZ/3B6a4kqZHZlVf5T+XYyNScmGNAQUhnzYDJiLziAVbarJFufqA==@kvack.org X-Gm-Message-State: AOJu0YwCfiQp4pTRpQUAefxcDP9lg5SLtOur7P1a3SWROK/HZsXRcN1t QGJ4mrErIECvoSyMNFnJdLwTRJwbgJmDygx0f0I9WwI/VbfBTAhl6Z2Zbw2llGNQTCbeiJYKVDy wD5bzd6//6IsfzTS1iCO06cet01U= X-Gm-Gg: ASbGncu7lX4p0/WaRtHxiUPINQRH/fI+psYaaCaN5RW4GiCala3qqWrG11doV67aX4k Cw0TXC3nPbPHBZ5e4pGn4JWpJczBVvy9KdUxyxNyPrrKwF0KLlT2OSoKuTh0B4SaOC2+J+dhn/G qy5bDK95Fw53QMf7lrdeRP9WPd X-Google-Smtp-Source: AGHT+IGSXvxdUrXZ2lnN0iPLAZDup7IGf6ZivA21FcXJjLnKJZtugd48GzBDlIr8iWl2CmynQ0cCnPmD28rAQZoUcj8= X-Received: by 2002:a17:906:6a22:b0:ac2:88df:6a5b with SMTP id a640c23a62f3a-ac738bacaffmr1205063266b.42.1743522414446; Tue, 01 Apr 2025 08:46:54 -0700 (PDT) MIME-Version: 1.0 References: <20250319071330.898763-1-gthelen@google.com> <2vznaaotzkgkrfoi2qitiwdjinpl7ozhpz7w6n7577kaa2hpki@okh2mkqqhbkq> <3mc7l6otsn4ufmyaiuqgpf64rfcukilgpjainslniwid6ajqm7@ltxbi5qennh7> In-Reply-To: <3mc7l6otsn4ufmyaiuqgpf64rfcukilgpjainslniwid6ajqm7@ltxbi5qennh7> From: Mateusz Guzik Date: Tue, 1 Apr 2025 17:46:41 +0200 X-Gm-Features: AQ5f1JroPhysgzd0ze9vsDBMoC1N2D5djQFkh-AXd9efTKxzlVR50N1KCOUO7dA Message-ID: Subject: Re: [PATCH] cgroup/rstat: avoid disabling irqs for O(num_cpu) To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: Yosry Ahmed , Greg Thelen , Tejun Heo , Johannes Weiner , Andrew Morton , Eric Dumazet , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Eric Dumazet Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 499AD4000F X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: m4ppywdnucpkusnqidu1a5cyhje8rs9d X-HE-Tag: 1743522416-299587 X-HE-Meta: U2FsdGVkX1+JaG5UZJ9uwYdhBbOfCzG3uOssSE3+phP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0+wMP2Si4eqDDdbHqGPKBf1gzEgVCigzE4WWkff/MblCvXFn3/mNzMZVCcgDxeP/QgZfm4eaMiIRSTBU6bki8oV4NFNT0frRzhZ3m13o0KPokqGhxv6aOMlx3KnNpbtSkUi/Wv+FbwjO0Ppu31DbI4xhig9Kbjzl0gnj08g5+4ThbuV/pVy7nCI8M2LaLsRsqEuZedySyvu0B7hyOeKshhtsrdgrD5yaJkjrourjtldeYmZZLDferx8tmTBvse76/5rWlyk+yLWmAEfZ88GQFehy9NqRSTYpYo4vKAOPR8QDA2VUiXyonslFB9aLpkLUGOt X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, 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 Tue, Apr 1, 2025 at 5:00=E2=80=AFPM Michal Koutn=C3=BD wrote: > On Thu, Mar 27, 2025 at 06:47:56PM +0100, Mateusz Guzik wrote: > > I feel compelled to note atomics on x86-64 were expensive for as long > > as the architecture was around so I'm confused what's up with the > > resistance to the notion that they remain costly even with modern > > uarchs. If anything, imo claims that they are cheap require strong > > evidence. > > I don't there's strong resistance, your measurements show that it's not > negligible under given conditions. > > The question is -- how much benefit would flushers have in practice with > coalesced unlock-locks. There is the approach now with releasing for > each CPU that is simple and benefits latency of irq dependants. > Toggling every n cpus instead of every single time is trivial to do. I'm trying to avoid sending a patch in hopes of not getting CC'ed for unrelated stuff later. > If you see practical issues with the limited throughputs of stat readers > (or flushers in general) because of this, please send a patch for > discussion that resolves it while preserving (some of) the irq freedom. > This is some background maintenance work and it should do what's feasible to not eat CPU. The stock loop was behaving poorly in face of a high CPU count and it makes excellent sense make it toggle the lock in *some* capacity. I just don't believe going from 400+ CPUs straight to literally 1 every time is warranted. It seems the author felt justified with the notion that it does not add overhead on contemporary hardware, but per your own e-mail I demonstrated this does not hold. Is this really going to suffer for toggling every 8 CPUs? that's a 50x factor reduction I would not be mailing here if the change was hard to do, but it really is not. it's literally a counter in a loop getting checked. > Also there is ongoing work of splitting up flushing per controller -- > I'd like to see whether the given locks become "small" enough to require > no _irq exclusion at all during flushing. the temp changes like the to stay for a long time. tl;dr I don't believe going straight from 400 to 1 was properly justified and I demonstrated how it hurts on a rather modest box. at the same time a (likely) more than enough improvement over the stock state can be trivially achieved while adding only a small fraction of the overhead. that said, there is bigger fish to fry elsewhere and I have no stake in this code, so I'm not going to mail any further about this. --=20 Mateusz Guzik