Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp420218pxv; Thu, 24 Jun 2021 10:48:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBxmVV7wOyKAiU2GWTDeP57MZVm2FU4Y2g932R3cIrLk1IZS72uZKFPVHFmhokraOA0aia X-Received: by 2002:a92:6f0a:: with SMTP id k10mr4443098ilc.105.1624556880897; Thu, 24 Jun 2021 10:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624556880; cv=none; d=google.com; s=arc-20160816; b=BoVUrFwvGX3qeB2IIxBMkMvRbhlm00YIgJNlabxq923HHxys3g+D8zM3yWCq4Hcq+P 8fx9B/rfkZwuc0nsXlwnbdKFyR1iO/KR5OLDumapyg1XxdguIOlAJJugZgZs+iMowWby ahKdticg5ncDmgEHl5yzOrTaRDNbeFml4KAdUy3fDfJIIvEKyPqaOttADxgIzLlWFFhv 5njy4KO2n7j/T+p9q1cThPex9K8f89TfKJTOWGZvCNAUdQR1zEO+D4PJLly5D1MqQDUD mgdSI5rXhjuZUW/h8Hasm98mn8SaqSqgasaCoCAO2s5vx99Ko3ODDbRxhw1HM5rbLV5q cD1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=znmbspe43gdGgRV/upQrZxOnaNJ/GmfYqjXiwM9oleo=; b=hWDaFH1wL5qU2+gCooC0JW9hBNyNENpw4BCh0xKml7ZGfcSeYgkghS5Q5ouuczwajl c9S58WXg5vM0wExPv93233ZcJ4ZxvicFGHsuu3U15ExuIGJDH/zopZtw/z9lG7v8147L aqE7CEE3LADKQolsnljR/TLj9KJ86XdxgbG4Olz4h5SBX89xFLQflPLYkEtiWvZNx+FS g3LQ1d9eCg5KuUoGkQWXCo7ABZUsfRgGPq530tQxel5szWW6EHNzAjaUL4GouMzxWh5p xqGBnOPGdVcpK9qx+QhkylMYwosrkyHkrhumqNoDdeWos4L3v6wk4JcH3VbMGrfQol2X j0mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=ELA+Ybvk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v9si4306077ilu.78.2021.06.24.10.47.46; Thu, 24 Jun 2021 10:48:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=ELA+Ybvk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbhFXRsz (ORCPT + 99 others); Thu, 24 Jun 2021 13:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbhFXRsv (ORCPT ); Thu, 24 Jun 2021 13:48:51 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCD2FC061756 for ; Thu, 24 Jun 2021 10:46:31 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id k6so5791402pfk.12 for ; Thu, 24 Jun 2021 10:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=znmbspe43gdGgRV/upQrZxOnaNJ/GmfYqjXiwM9oleo=; b=ELA+YbvkUh75ll+mDif4Kq+XgYyX0/XvX6qHn5DIZ3JSdG7TIpCzYTJ7CNH0KRs3JQ Qgkx5zASyU7ccV7yFcYLKO98UIOlSU5t+3oC08J51aQ6VDKmSsmosrLP5mK5XKZH4DOB rc3sA+6PfyO7SBkqCTHaxwRQ27zE+saKJVPSYZHYjWq2lEfUYOLFqXc2sZ2Ik+iPfLd1 +PNPOaXQeDUQOdkgYW1f99+LpTjBPMyir979HxcahAH9czGxYic2o+kRWVQPLdp7iHiA dkMXuOkUP8YzBUGP5HW3nSC2tU3ODM4u6gwHL+4RLZB1cqymZxwwHxcn0u5rX2uf3IqK neKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=znmbspe43gdGgRV/upQrZxOnaNJ/GmfYqjXiwM9oleo=; b=cV+iGw8ouDc/7ZpnmJSJTVe9YBF3JQ1LWw5idb4goCkCU1zgL+FGiNSeaeHuOOFIhz mYZPC7fIDHLswuOh37kPw6AT+roYW0Qj9XI5Uisl4mrvLVkKTe6UQ+6uirnwuG7o5HgC PvbToRodLRhTuYipYZe2aBkLPiUl2aTjmNX+Py1WAAez7H6lqg0mS+fTZI1MA7jfUlIM nZMP+fE/u69741j8ad+cgrGPKNnDbVKx2ug8hRZvJA2eEYhFNOUoPVo+uv4r5MNO5Iuu ed/00iD/c5yrlXGBYm/57dNpNaDMXIOKTDNGQ4BokP5qK2j8zzHOiscFHmdhsDWFrmF9 R9XA== X-Gm-Message-State: AOAM533dynr/MnWfxRlZMzIxFBMlNBr3QaAhiY7GaavGCP9WZOefdwdL CYOKWu22AzcfM9DG8LgTLrYdKg== X-Received: by 2002:a62:830e:0:b029:306:3c52:2a74 with SMTP id h14-20020a62830e0000b02903063c522a74mr6305156pfe.50.1624556791303; Thu, 24 Jun 2021 10:46:31 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:52cc]) by smtp.gmail.com with ESMTPSA id x6sm8861654pjn.53.2021.06.24.10.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 10:46:30 -0700 (PDT) Date: Thu, 24 Jun 2021 13:46:27 -0400 From: Johannes Weiner To: Shakeel Butt Cc: Tejun Heo , Muchun Song , Michal Hocko , Roman Gushchin , Michal =?iso-8859-1?Q?Koutn=FD?= , Huang Ying , Andrew Morton , Cgroups , Linux MM , LKML Subject: Re: [PATCH v2 2/2] memcg: periodically flush the memcg stats Message-ID: References: <20210615174435.4174364-1-shakeelb@google.com> <20210615174435.4174364-2-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Shakeel, Sorry about the delay. On Tue, Jun 15, 2021 at 02:52:37PM -0700, Shakeel Butt wrote: > On Tue, Jun 15, 2021 at 12:29 PM Johannes Weiner wrote: > > The way the global vmstat implementation manages error is doing both: > > ratelimiting and timelimiting. It uses percpu batching to limit the > > error when it gets busy, and periodic flushing to limit the length of > > time consumers of those stats could be stuck trying to reach a state > > that the batching would otherwise prevent from being reflected. > > > > Maybe we can use a combination of ratelimiting and timelimiting too? > > > > We shouldn't flush on every fault, but what about a percpu ratelimit > > that would at least bound the error to NR_CPU instead of nr_cgroups? > > > > Couple questions here: > > First, to convert the error bound to NR_CPU from nr_cgroups, I think > we have to move from (delta > threshold) comparison to > (num_update_events > threshold). Previously an increment event > followed by decrement would keep the delta to 0 (or same) but after > this change num_update_events would be 2. Is that ok? Yeah, I think that's fine. Or at least I can't think of a real-world application that would inc and dec the same counter over and over and so would do much better with delta spilling over event ratelimiting. And the ratelimiting should already ensure by itself that the cost is at least acceptable when continuously updating and reading counters. > Second, do we want to synchronously flush the stats when we cross the > threshold on update or asynchronously by queuing the flush with zero > delay? I think flushing by worker is better because we can see updates from all sorts of contexts with all sorts of locks held. That could make for some difficult dependencies and latency sources when serializing those on cgroup_rstat_lock.