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 53C16C2BD09 for ; Mon, 24 Jun 2024 17:33:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3B2F6B0398; Mon, 24 Jun 2024 13:33:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE97E6B0399; Mon, 24 Jun 2024 13:33:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB1376B039A; Mon, 24 Jun 2024 13:33:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A9FA16B0398 for ; Mon, 24 Jun 2024 13:33:01 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3F348A3976 for ; Mon, 24 Jun 2024 17:33:01 +0000 (UTC) X-FDA: 82266477762.05.5A82E93 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) by imf15.hostedemail.com (Postfix) with ESMTP id C3BC4A001B for ; Mon, 24 Jun 2024 17:32:57 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=MjEOPGr+; spf=pass (imf15.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.186 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719250370; 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=qBtGnhkgSmOG529IQPloUgvMKxbYourH7LyKKUJBK0E=; b=OwTcPaFDxoq9GqZG/k7loFSyYx2lTjYZzTMtTK2XqtucGZ8A3v1pArH4hYK8LuPomPKUz7 k5DRlEZXVvPJ+539+9tJ5e8TsZ6xnEJQ0EumdVhrACP8F6MrgL34idIm6Cf+tM3E8UsDXf VEulaWTq6s2k/ux9WtYzkxPZHqihF0g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=MjEOPGr+; spf=pass (imf15.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.186 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719250370; a=rsa-sha256; cv=none; b=MiQaX79Q/uVSUzFGZxCnj2RTE+ufKXouDaToRWFu6ZNZME0oDL/DjxNNorunANu/SwO4ZI 3xQtmE5PmF/g68hOgo4Eoxm+M/rquJNYdJJHG24Qj6LDMAINXltaSzO7Kxp7CCUGPRg/43 IhvyIV9bSmFoR8p/nU1be78UOjPYDow= X-Envelope-To: yosryahmed@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719250375; h=from:from: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; bh=qBtGnhkgSmOG529IQPloUgvMKxbYourH7LyKKUJBK0E=; b=MjEOPGr++lnCIcGfZw73gaSpAHuny4FEV82lD7HnQCficdgny0vyBaNFA53FDiCGORW98X YaOHHthGwtqeTp+ugPnBFG6VfXj+lEu/S1ZRv+Quc1jK+YqjmVnTr5h9gndERrxjtbQvvt DEIl2+lmR+23/LiysNJWd8hbx5lB220= X-Envelope-To: hawk@kernel.org X-Envelope-To: tj@kernel.org X-Envelope-To: cgroups@vger.kernel.org X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: lizefan.x@bytedance.com X-Envelope-To: longman@redhat.com X-Envelope-To: kernel-team@cloudflare.com X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-kernel@vger.kernel.org Date: Mon, 24 Jun 2024 10:32:50 -0700 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Yosry Ahmed Cc: Jesper Dangaard Brouer , 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 Subject: Re: [PATCH V2] cgroup/rstat: Avoid thundering herd problem by kswapd across NUMA nodes Message-ID: References: <171923011608.1500238.3591002573732683639.stgit@firesoul> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: C3BC4A001B X-Stat-Signature: bf88cg4ri1ujukh9h7rr8jw9wxgg8qsa X-Rspam-User: X-HE-Tag: 1719250377-889269 X-HE-Meta: U2FsdGVkX1/6/2wkVkzVjGt5uTkyvLwiVS68k8TwX8PBUoUHyiHGQ47xEG9L+QONotjT0p7SKaEir4cKWz2niDRmQDfOzXUqHxjIcM5GYbNQkC5nlYmtDBzJx41tG4Qm5ZGCjcw7sxaoRjrgJQ3nFRpxEUN7FqlFgIYJuZi0reXtJZNUlOjC6lYhuMRbFID11ytbbt6h7PSUYL/8Smpkqh4IvOAvXWu/U6EuRLJ2Jz4OVXuAScIQPD+pBGX9xfoNmTc4y4UJ/JRepQYpXIsLbcSVRr73iPT6HPcMaosNI+QY4n4gl5l5ezEaouACWBHKSRa8cziIJVyI9bHwO1RKbJsPvLWMs6PJPp7mY91yFbRT7nJem0j5WoDjzShR7nvHPbzsVKgtKFMWj+jJe0QcWy17PDuqSK4KOTk4k1984HTMTwdUv/eNk0u3DKjScyeKpJxY30TiUbJ/YQUqmg3t/7EK6vT57SuMjIPS1LLDs7OQUwb12InkNafaTAW+bUkU7ILOr3wczhs3uD9IrCU05DruKqornBLS7ikBXt8UXOO+Ova/jBMmw3Xx6AsEm3qJTJpiGhc9vPsorIeYBP/5kIWvxJ7kpz/12xtetCXXozn2S3uEFSXVPLbOo6yh+osFNwf549R68zzsi1gooxX9N8dxYutAgaPHzxpG0aRbDee/BLo0vWLWoTS5QMcs9h9CphuzzVfAR+M80aGvwoS9ok8k72a6p3s+N6eFm4/BkNah+vgNX/dj671n5OUEqSCC4PhvhFrlRA0BFXDPIZ1CZOMs7TtrKPCieXEIMXavw1v+C3ssjVjw3vzztSRwcvUb0P/FELapZCYq3lohafAQprYscUEIjadDdw94eHx5ju54daLrLCeaYIQ838pW+FT/HqhjFL7cpZvqJWjk833EtziqMquemAYFe2FXCwWP7C2Dgg/OFw+6ZN67t9pqPPJ3Lej22WIomlt6hrn7Ij3 1MJVmkU6 V9CsYSEyjZfXYnaYcbLVaR9DSEYhtn11DVccT6nx3RTgNPiowbzV6XDc4sL8BjBQnxi84hxx75izLJ2cC+O5ksix9D5mwRblUz7Jsv6/mEk+VFBLOy03S6lQI/oA+C90uepwyzUwq+u/3oZTls2AMTBRCFzLMzUn05K0nDX99Cx23W+SiFnom27Rp9CxIw9hN7ozS8xehl/vJprE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000533, 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 Mon, Jun 24, 2024 at 05:46:05AM GMT, Yosry Ahmed wrote: > On Mon, Jun 24, 2024 at 4:55 AM Jesper Dangaard Brouer wrote: > [...] > I am assuming this supersedes your other patch titled "[PATCH RFC] > cgroup/rstat: avoid thundering herd problem on root cgrp", so I will > only respond here. > > I have two comments: > - There is no reason why this should be limited to the root cgroup. We > can keep track of the cgroup being flushed, and use > cgroup_is_descendant() to find out if the cgroup we want to flush is a > descendant of it. We can use a pointer and cmpxchg primitives instead > of the atomic here IIUC. > > - More importantly, I am not a fan of skipping the flush if there is > an ongoing one. For all we know, the ongoing flush could have just > started and the stats have not been flushed yet. This is another > example of non deterministic behavior that could be difficult to > debug. Even with the flush, there will almost always per-cpu updates which will be missed. This can not be fixed unless we block the stats updaters as well (which is not going to happen). So, we are already ok with this level of non-determinism. Why skipping flushing would be worse? One may argue 'time window is smaller' but this still does not cap the amount of updates. So, unless there is concrete data that this skipping flushing is detrimental to the users of stats, I don't see an issue in the presense of periodic flusher. > > I tried a similar approach before where we sleep and wait for the > ongoing flush to complete instead, without contending on the lock, > using completions [1]. Although that patch has a lot of complexity, We can definitely add complexity but only if there are no simple good enough mitigations.