Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1015855lqb; Wed, 17 Apr 2024 19:05:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8YRLrq1LvJE7GfMP+igfcrAjoFIdHSZCLVgcDBslAvIhlc6dvueOHiUsD1X8fjLq+880vAO8PbN2Xx18P976Vl3jFQvPnfBP6fIkteQ== X-Google-Smtp-Source: AGHT+IHs/faZaPnntDxQ/vsjNxjcCuAgJflYEXxwuJZL76+onz+Ihmzqm52H7fEnbBBcTCZ2n1Y7 X-Received: by 2002:a17:902:aa85:b0:1e2:c8f9:4cd7 with SMTP id d5-20020a170902aa8500b001e2c8f94cd7mr1340560plr.64.1713405945763; Wed, 17 Apr 2024 19:05:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713405945; cv=pass; d=google.com; s=arc-20160816; b=FBMTVaHrb/Vskj7fLcFBx7U0zrJDkilz6IBkB2kWshwcHb3nCjRJVPl3hveh87CZ66 /xLRsUy13VTDzy7AeNFzV6aNLSLKXccx6qWiJcluyOJ5Nz2BL2SslIeSUfSX9dVTOTQM d0aLYHuM7vn9GFwOOU7/lLlhixTS34bimG2dfdTH3SKVrUjPUD2s8yjKM0Ug5n+VrlED ogG4ilZWCff8k2ri2bRL79jeKUCIW4MGUA7ymTuUsAEavjbosgs6Z2bHlEaENd2KsnMs QrrRYreZCpPvhyv4J0XQEokddGNwnbcVmliUXxDgYZgEJU2zGcAdHT4+z96zI5lSjrMU UmDw== 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=T0QnjAhdYrmACiuwAPDxnR5HIy4p9penGkBMygu+5uU=; fh=WLk8VJYrQFI1Vjw7kHiiwUIjuQXZpvODHvtuKUhYBoE=; b=ymC71AXP5xUJiHYpFVD4kWKB8NpIdGO6egJsFKVvUOzSt3P6MqO9yT0ho2NoJmq1B9 muIvrZyOVe0Us6A+iB34ZtOHgnMnmv7ULKSIBKyRqFNkAcwHCO1aiA0GPPgmfxMbpvV2 3nXCNc/n6BWPH24Z8U9rm0vKo3MXKH3+dFohtsBi7Q6blOssjrdFKLW2PFMdciTW5jI4 5+Tgd+Vm6/ZQ0NQ40qC1DCsuTku8//4ojnkpjxYn6QAAAmnMkrt4cxlr5C9xLP3qAPBj SO7XRgIxO1E7ZbRd0ngytNobp084L8IE+PYiER9AWmhObmt7VF81vyaXzxnlpV04bD9S oIGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iaQXswJS; 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-149426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149426-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f15-20020a170902ce8f00b001e0d0b2ced0si467725plg.328.2024.04.17.19.05.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 19:05:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iaQXswJS; 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-149426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149426-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 61C6E28219A for ; Thu, 18 Apr 2024 02:05:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BE003A1D3; Thu, 18 Apr 2024 02:05:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iaQXswJS" Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 073E22AC29 for ; Thu, 18 Apr 2024 02:05:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713405930; cv=none; b=q+jrOwyb3gXF5cnjAYh8j+WxlEI7mQTfQRS3Jym11dGCJoKGdJhQEF4525dC3jK1qGI18hERwG2HiWiCBhCYoKIXTHpPoh5cIdnYk80t0skxEnrwMAveOCfJBPp6jo9d0n14jjwL1UUj6fGB6twG1cyQzktzJ8nuTybe84zEOrk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713405930; c=relaxed/simple; bh=T0QnjAhdYrmACiuwAPDxnR5HIy4p9penGkBMygu+5uU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=tB1GoSJKraM3+uoPbTf0Jml3jqWd3Ae/nXj7g3h/aY6q1RWvvR1DRBxdnO9uEUO/7+/Zquh2PiWo4s2DPR2T30TLr6LZ+bLc0desCRN2X6XoZUBzdKGhvnQlWfGtppj9NqJRjksEyNbzyIjQ5VpfaoBtWX7TotYyWGFF8n0+8D8= 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=iaQXswJS; arc=none smtp.client-ip=209.85.208.173 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-lj1-f173.google.com with SMTP id 38308e7fff4ca-2db2f6cb312so6776931fa.2 for ; Wed, 17 Apr 2024 19:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713405927; x=1714010727; 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=T0QnjAhdYrmACiuwAPDxnR5HIy4p9penGkBMygu+5uU=; b=iaQXswJSwbd6W25fe4Gm0Pjcaxlny+oZVrwFZ5yeQDqUCqctGQ0oJzeErLjcaqSVjQ c5rROx3N5EHWyGn7GYvncjhJ2MW+mzH4mfu0FnHyvfU/krB54BJpgMR7zL7aXg3gHt1h Cix3sRYVObXpzTpratyv/GQAbufq/aQo47i5wFdquZDGtwXA1bRzIChHOiU9gnz9YgWO pVtgb4K/M67JhK2l5S2DYN/nP1WKudwWA/AFyov3uh9pQgyGoFU2m8gEh9/1UdgACd/e /VoLNfpm6mfQJYZ3SJRs1JomoDjYLJ055rtMehVwPTfjEW5/Vs2/KqpkVDlMUOR2Prfc BuBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713405927; x=1714010727; 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=T0QnjAhdYrmACiuwAPDxnR5HIy4p9penGkBMygu+5uU=; b=EMOyYZLpQjC5eLDtXBMB0eTWX/09ger7KH65Y1HK0p26tmuk5Q6B65pbypQV8Vxnad 5ugwigWy1uLvJrBzfGJ9D9WeaHi6UDvDnnOGX+3aSQi5YWcTPNpazkGUJebXVBJ1JW2y IVQA2b5jeQ/TcDo4mDjvY/0Zyi9nEioOmdmoGvFEzhiaIKioylak1Zt8cJ3ue08SS7b5 oV28FCoMlbd0sGS27YzBiH/2Ml8Jw6odTIQqjzB0lNFxhCcs5I7oBAOt+dTCm6AhBA7d n5AHnXotNVOQJ0JQZcpa/VK9MSOXq8kHcVr+J3KpFH7yYjr1fvvfu052qFGhDCDL+URA P6dQ== X-Forwarded-Encrypted: i=1; AJvYcCULA3CZ4hDFaui/21XXKGAR4zR9r/0dok7S12F90DcnRoe+vztvml5z8FokEH+0LqNkhPzYzDqZxfcznXL+nEjbdRM9zlLige3DsR7Y X-Gm-Message-State: AOJu0YxJG6Gfpramd3vCxTWN2h0CH+Kgz9hasHvAUj+gYyYjhPJyhLE7 zyHfTV1bTZpduOKPiFqUD1FIafrt13MTRYpbxCBZ9noFSN/TS+5qN/9Pl+oRe1LIeaG65FyGdti OxAP9UKEJ+pjPhqscEVFGc/62EABqTnh6Sl+C X-Received: by 2002:a2e:9003:0:b0:2d8:bda5:c5f5 with SMTP id h3-20020a2e9003000000b002d8bda5c5f5mr644366ljg.35.1713405927096; Wed, 17 Apr 2024 19:05:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <96728c6d-3863-48c7-986b-b0b37689849e@redhat.com> <4fd9106c-40a6-415a-9409-c346d7ab91ce@redhat.com> <75d837cc-4d33-44f6-bb0c-7558f0488d4e@kernel.org> <9f6333ec-f28c-4a91-b7b9-07a028d92225@kernel.org> In-Reply-To: From: Yosry Ahmed Date: Wed, 17 Apr 2024 19:04:50 -0700 Message-ID: Subject: Re: Advice on cgroup rstat lock To: Shakeel Butt Cc: Jesper Dangaard Brouer , Waiman Long , Johannes Weiner , Tejun Heo , Jesper Dangaard Brouer , "David S. Miller" , Sebastian Andrzej Siewior , Shakeel Butt , Arnaldo Carvalho de Melo , Daniel Bristot de Oliveira , kernel-team , cgroups@vger.kernel.org, Linux-MM , Netdev , bpf , LKML , Ivan Babrou Content-Type: text/plain; charset="UTF-8" [..] > > > I personally don't like mem_cgroup_flush_stats_ratelimited() very > > > much, because it is time-based (unlike memcg_vmstats_needs_flush()), > > > and a lot of changes can happen in a very short amount of time. > > > However, it seems like for some workloads it's a necessary evil :/ > > > > > Other than obj_cgroup_may_zswap(), there is no other place which really > need very very accurate stats. IMO we should actually make ratelimited > version the default one for all the places. Stats will always be out of > sync for some time window even with non-ratelimited flush and I don't > see any place where 2 second old stat would be any issue. We disagreed about this before, and I am not trying to get you to debate this with me again :) I just prefer that we avoid this if possible. We have seen cases where the 2 sec window caused issues. Not because 2 sec is a long time, but because userspace reads the stats after an event occurs (e.g. proactive reclaim), but gets stats from before the event. [..] > > > > > > > With a mutex lock contention will be less obvious, as converting this to > > a mutex avoids multiple CPUs spinning while waiting for the lock, but > > it doesn't remove the lock contention. > > > > I don't like global sleepable locks as those are source of priority > inversion issues on highly utilized multi-tenant systems but I still > need to see how you are handling that. For context, this was discussed before as well in [1]. [1]https://lore.kernel.org/lkml/CALvZod441xBoXzhqLWTZ+xnqDOFkHmvrzspr9NAr+nybqXgS-A@mail.gmail.com/