Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4036005pxb; Mon, 4 Oct 2021 15:50:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOkIL6BkJV63zlJJBUTYXkYHEm7d80Lx+libZsl3+++F3zqWWUjipzx08+f3AKVolenfdd X-Received: by 2002:a05:6a00:88e:b0:44c:c40:9279 with SMTP id q14-20020a056a00088e00b0044c0c409279mr22565386pfj.85.1633387834473; Mon, 04 Oct 2021 15:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633387834; cv=none; d=google.com; s=arc-20160816; b=nBbXgGNgd++ZjqG+x0C0OCJqLtrFN4njnYaMWK61NbEfj4WSfT0bS3wXYih9CR1nAr C7DAK113bIVdPfaZPtNeflm2tiMoKk3UTQtuSy3mFBHbp+fJqC4f4vYc1ga63th5u6Zn IYdxKUUAHbPQfnkC1wQ1HL3N2RCCTBpLVxG6gH+sCWYqjq8MWThJQqItbhPEGzVt/zBJ f7G9fnRQoFfUakffUqxCgsGWV0gsWL9JA+hhfcJ5UaLl7FfCQNezlCI7oGKQGARAaxea f/uiseDetdlZd/24/eryOfi2Oa6ztAu2LQ8cB5O8Oc4bxoxCHuE0ex/hNCDGjg/HIAAe BdHw== 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:sender:dkim-signature; bh=pqoXBReWZTHvQNJRRiye0Xfo5/CYCSyS20QIvLAs+Oc=; b=pj87RDld344WSMBXio3sl6TTAxavfwDko7rh+qwxXf1ZhONAPIQXzT7wNVry+P8qv5 Crcw6BcigqSnH4qp/jI2zw1nft0RQd1Pvze7iRW8xrkwVMcxW0p7YB6BjlP8xeEP/adI sZoQYUf7GAiBN1tUWxxEQ9lhD3B56636+NaRTVbMM6i+aV7jNRCEjdo0mpVOhUJTLB/W 4HvFb2rGZGkUyXeX4SaLRlgAlH8Kh4P3HUnW6i+lRFdCJvmGAJwNzfBGPHDDZHugOnUB jmlrCwsxb2L3brc55priHuFNgbzEij5uq9/BHqCjMofaX1upCZ9H+0ZwEkkAcFlnGL/1 SGig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RNg9WE6g; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 15si20577216pjt.0.2021.10.04.15.50.21; Mon, 04 Oct 2021 15:50:34 -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=@gmail.com header.s=20210112 header.b=RNg9WE6g; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237992AbhJDRC3 (ORCPT + 99 others); Mon, 4 Oct 2021 13:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237982AbhJDRC2 (ORCPT ); Mon, 4 Oct 2021 13:02:28 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CED43C061746; Mon, 4 Oct 2021 10:00:38 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id h1so4358626pfv.12; Mon, 04 Oct 2021 10:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pqoXBReWZTHvQNJRRiye0Xfo5/CYCSyS20QIvLAs+Oc=; b=RNg9WE6gurFAuclja1md8Z0NgpR7kRF419Lfq/1FBEY4FvTK31TnekkHmWasNe+C81 2Qf24+qnVfqCnBg0pl5JqIUNn59KlKxY5SE2ATXqXyduo1FxV2Xeh1OO2kubNdwNtjAG UJm8LWP4NkJzpKHwR5RMCdClAlMDlQgqf3bxnhmk1oWWLHaFxrpyOZkeXcZC+qtCv1pj INwuFn3eMzaewx9I9bsaLSnK3FtI4iqkTTdaeomSYzFf5J8USqmB60JPQKAZHaYVbMx0 6Pn3qDDShj9beVqCvMwxJQRZmRgdDAQ6C8SdugwvvlDnnjdMOQjhDXtBm/mNQ4o5YSMd Tujg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=pqoXBReWZTHvQNJRRiye0Xfo5/CYCSyS20QIvLAs+Oc=; b=FxEneqrR7zqTCHsiDXKHW9uNKM2/P0uLnTMbMUbx5LdnDPQmtKtMecqV4NHZHq97AX SMznq6pk7xekMdC9SeUCMqJwLBkrvsO1ztPAPaetlWCGLLEMHL/nsZaoe/0afYfYwpsv HzOtz6H2WZBThdvcOhqqlYxoF96MhcpqG4Hx1+ngRpCdFLg8XaFNAEnCOVlQR5mdOOU2 Bv9jbPZJ3qsPo55w+wdYFdIfIEQhKRkAgbcZX1wYlnzbetjcPzOe0NmI/wOkc71SI1pq tJJjUaIpj7mg2rTNIFlPNChGVXTWuzIBHlV8YujH8NkeCxRfBiJHioFjK4RPVA4OqfFy 7Jyg== X-Gm-Message-State: AOAM533CRYnvjjgSe9LsP89vtmrzcGIjRf4jx9fKY9LvQSCZDi+HHxi4 fv/7xTQEOqI+pRv/Mc0PHGPqYKRPXj8= X-Received: by 2002:aa7:93d2:0:b0:44b:e5e8:f89e with SMTP id y18-20020aa793d2000000b0044be5e8f89emr25864519pff.52.1633366838049; Mon, 04 Oct 2021 10:00:38 -0700 (PDT) Received: from localhost (2603-800c-1a02-1bae-e24f-43ff-fee6-449f.res6.spectrum.com. [2603:800c:1a02:1bae:e24f:43ff:fee6:449f]) by smtp.gmail.com with ESMTPSA id u19sm9594742pfg.18.2021.10.04.10.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 10:00:37 -0700 (PDT) Sender: Tejun Heo Date: Mon, 4 Oct 2021 07:00:36 -1000 From: Tejun Heo To: Shakeel Butt Cc: Johannes Weiner , Michal =?iso-8859-1?Q?Koutn=FD?= , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cgroup: rstat: optimize flush through speculative test Message-ID: References: <20210929235936.2859271-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210929235936.2859271-1-shakeelb@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Shakeel. On Wed, Sep 29, 2021 at 04:59:36PM -0700, Shakeel Butt wrote: > Currently cgroup_rstat_updated() has a speculative already-on-list test > to check if the given cgroup is already part of the rstat update tree. > This helps in reducing the contention on the rstat cpu lock. This patch > adds the similar speculative not-on-list test on the rstat flush > codepath. > > Recently the commit aa48e47e3906 ("memcg: infrastructure to flush memcg > stats") added periodic rstat flush. On a large system which is not much > busy, most of the per-cpu rstat tree would be empty. So, the speculative > not-on-list test helps in eliminating unnecessary work and potentially > reducing contention on the rstat cpu lock. Please note this might > introduce temporary inaccuracy but with the frequent and periodic flush > this would not be an issue. > > To evaluate the impact of this patch, an 8 GiB tmpfs file is created on > a system with swap-on-zram and the file was pushed to swap through > memory.force_empty interface. On reading the whole file, the memcg stat > flush in the refault code path is triggered. With this patch, we > observed 38% reduction in the read time of 8 GiB file. The patch looks fine to me but that's a lot of reduction in read time. Can you elaborate a bit on why this makes such a huge difference? Who's hitting on that lock so hard? Thanks. -- tejun