Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3697775pxb; Wed, 13 Oct 2021 11:03:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZsKCsHn63Qu4LjB49H4h/UM5fPll9cXWPZp7lF4wWJ1MR6Iea3k2HjLQrrKT/jy1qdOTX X-Received: by 2002:a63:7f0e:: with SMTP id a14mr495342pgd.49.1634148216134; Wed, 13 Oct 2021 11:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634148216; cv=none; d=google.com; s=arc-20160816; b=c164VRLIyYcfTtd3WMPR6E6YQqrh+0mxfHZE6liWjWnr7FMTw6e4yNATqqhvTk5iLE WRledAHXzEN+KVflNo3TCrfpsYXTi5yihEj+nI0aRuaBQnbhwwC19GxIrilNIZ3B70DO d3H2ZGc80vKg1WJRaqakJxHd50ePQGwfGPxBS09GBJizGQ9oN1aQ34t4PjidaP61V6FB 6xLoFBcpDB3b15vc3FNyAYbzvtt2XQKqmhrRMNGcUv7q7VvsW5zs/2Pydsfne+QVeqLo eID4VDbvAxE9stzJ6ABpnInA2CnFSYUOQAO4gD+822IL+7faA0pF10F4CmHMs8BuTn3S YdVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bnGWW8txEiGiwfqJHyEBYUwfb5etYjAXJP0AbtxNWE0=; b=TXFJw4WiFg5agrAFbWRtbE8/A6OqaB9vOHzGyxXI2E04n8x6A13wzITkPJrjTn5xwW /GDWsj3SGx7/OtNCAmX2YSM3tlPG/nTn39LyGUpWK2rqe/Mh7MHXlhN53W7MLIPxLyjU tX+tMgbmCfkMcng+9ujMraJ4mozAMDW32O2WXHXGInIo593VyJx50xNleKaeTWZwjNBl 2zsVyTWGab7+DMtr9uQ11BlCZCuK8SCCZgK0NiAql7AiurgjauVFi65xcUIjSTZV2E/p dE3pJK+Cf++rvk3ZsicUVr6EYMAraW0vtxTscqcqpXD+znF2ZkK1yOpwd97+vSufksr4 5JBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=PRCA6mW4; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f17si8756917pju.79.2021.10.13.11.03.18; Wed, 13 Oct 2021 11:03:36 -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=@suse.com header.s=susede1 header.b=PRCA6mW4; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238275AbhJMSDg (ORCPT + 99 others); Wed, 13 Oct 2021 14:03:36 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:54630 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238202AbhJMSDf (ORCPT ); Wed, 13 Oct 2021 14:03:35 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8381920240; Wed, 13 Oct 2021 18:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634148091; h=from:from:reply-to: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=bnGWW8txEiGiwfqJHyEBYUwfb5etYjAXJP0AbtxNWE0=; b=PRCA6mW40Xj9Xc312LnvvnDJ6HOaWqe1Gh/O1mgyfxcbtckTD1MXC4JkbNTLPidMAV33zL 9O2ZgrWeLF/cs8gPkqOfNTx2lLX1UkIapks1huu23KL9Aw+JEdyyx82RbnQT0mYl4jo2ln NZH1Lrb38EY1aKBLkY0PiX0VdchuvEY= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6A73D13D10; Wed, 13 Oct 2021 18:01:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8et4GfseZ2HFPQAAMHmgww (envelope-from ); Wed, 13 Oct 2021 18:01:31 +0000 Date: Wed, 13 Oct 2021 20:01:30 +0200 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Shakeel Butt Cc: Johannes Weiner , Michal Hocko , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] memcg: flush stats only if updated Message-ID: <20211013180130.GB22036@blackbody.suse.cz> References: <20211001190040.48086-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211001190040.48086-1-shakeelb@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 01, 2021 at 12:00:39PM -0700, Shakeel Butt wrote: > In this patch we kept the stats update codepath very minimal and let the > stats reader side to flush the stats only when the updates are over a > specific threshold. For now the threshold is (nr_cpus * CHARGE_BATCH). BTW, a noob question -- are the updates always single page sized? This is motivated by apples vs oranges comparison since the nr_cpus * MEMCG_CHARGE_BATCH suggests what could the expected error be in pages (bytes). But it's mostly wrong since: a) uncertain single-page updates, b) various counter updates summed together. I wonder whether the formula can serve to provide at least some (upper) estimate. > +static inline void memcg_rstat_updated(struct mem_cgroup *memcg) > +{ > + cgroup_rstat_updated(memcg->css.cgroup, smp_processor_id()); > + if (!(__this_cpu_inc_return(stats_updates) % MEMCG_CHARGE_BATCH)) > + atomic_inc(&stats_flush_threshold); > +} Neat trick! (I guess there are no benchmarks complaining about this (yet)). Overall, Reviewed-by: Michal Koutn?