Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2530475rwl; Thu, 6 Apr 2023 11:31:28 -0700 (PDT) X-Google-Smtp-Source: AKy350avpDWtWNOtX4PvCsE9EHzmXAMYpyLOko+HIn7oiHfpmha5/RfkOR7OQgIqQbc2DYLGk9B3 X-Received: by 2002:a17:906:b359:b0:933:6f83:fd87 with SMTP id cd25-20020a170906b35900b009336f83fd87mr7010828ejb.57.1680805887980; Thu, 06 Apr 2023 11:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680805887; cv=none; d=google.com; s=arc-20160816; b=kKau5m05T6pUFqs1FAzWjCcfQJwIJIdaxX5xaduK7t7spr1m/+/eyf1/fR3tcsHW7/ sjPBOFHraB8U5B2UAzGCBgc42EJaZv7DxFrXaphbpGQTelZOFgj5rCUaOWWpe756SVnE ZTEyINx90PopPRC5V60vNTYV4FK18Faj6H8o41X3q5pLMV2NunDJqgmffEvHygbGJEfp UORQ0Bx1kd/hNPq6E1IhChFrsyeECum7VJ6zHIUSrW64C1UIxXG5q+74zeG83ZlJQ4X6 qbulRKh1T+mKWIu/96Kv7aAvXZLGHZXRidIejOoHgtplVS8Ue8yhBbxSb5n4i7tCzEiS 2O0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=lZDJHtj4ZdvJcDQ5TOp/nyb03vogrfzZp2ItB5B/rlA=; b=p2zZxW0QJtTcYIsa5nFTQtw6LH1vxAmKjbzrD9XRhXidhCQWK0o+qG6j0pAOAKdmRM 13RWDSstRMZQLohafe/SkVs0rQY8oBrhb81Qe4NEIA0wRW26keOQxG0SZfA+fr7fqO8a h63LMvabjiJTbvaz5Ryx3M8z4G1VIy8DhHWrQFP8wnZzq8rKCaOQUPzB/K1VlxSSzLeP 5/3/IDTdlKYCZOePX7rkh+QGz9c6O5+39gd8k8dpEFk2b3B1cbxyxnECjBEFCVAo0p6q ohDJh8e65FYcsei8ZB/8bSxJlxIPeR22KfHDWlH2P1ky5RDP+5RvJA0JnpMBwW7FHKuv 1AhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QpKcGCkv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a1709064d5000b0092fdec58af8si917419ejv.430.2023.04.06.11.31.02; Thu, 06 Apr 2023 11:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QpKcGCkv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240103AbjDFSX6 (ORCPT + 99 others); Thu, 6 Apr 2023 14:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240009AbjDFSX4 (ORCPT ); Thu, 6 Apr 2023 14:23:56 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3706C6A6B; Thu, 6 Apr 2023 11:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680805434; x=1712341434; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=rQafWPpN6SSrt4t7Qo2/D4943r4B6SApT9bspraHldI=; b=QpKcGCkv+JlVQ1ubcyv674/0Gjslv/fONM35uyG10HTvI7M79ww71R37 +zdU04qNKFuZod5GGAr63QHRwFV9Zp8S2n2ugiN1ro5XHG8Vcz6rh2NvF GWtqt+UL6MfHl5EDQ1c2OaBojEz/jAVMvhylf+aGjad9jfw/9BzPnKhu/ uxZmN8PNq9d1/RQmARdPz1ZIR3d14cDe9Rspv1/dot87zjOvX9xIWCaFL vd2/RJ5AlGq2Mih4NWO33hxzoDmgQcfyirOisOJON/e8mzMChSZUzEKwo 8uu/Z68HCX8CUqxUSNLMVsc6FmsYd1kfJ3pnmayQ83wkHMsFqGCqN1xyj w==; X-IronPort-AV: E=McAfee;i="6600,9927,10672"; a="323184546" X-IronPort-AV: E=Sophos;i="5.98,323,1673942400"; d="scan'208";a="323184546" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2023 11:23:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10672"; a="664576653" X-IronPort-AV: E=Sophos;i="5.98,323,1673942400"; d="scan'208";a="664576653" Received: from ticela-az-114.amr.corp.intel.com (HELO [10.251.3.106]) ([10.251.3.106]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2023 11:23:46 -0700 Message-ID: Subject: Re: [PATCH mm-unstable RFC 0/5] cgroup: eliminate atomic rstat From: Tim Chen To: Yosry Ahmed , Alexander Viro , Christian Brauner , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Date: Thu, 06 Apr 2023 11:23:47 -0700 In-Reply-To: <20230403220337.443510-1-yosryahmed@google.com> References: <20230403220337.443510-1-yosryahmed@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2023-04-03 at 22:03 +0000, Yosry Ahmed wrote: > A previous patch series ([1] currently in mm-unstable) changed most Can you include the link to [1]? Thanks. Tim > atomic rstat flushing contexts to become non-atomic. This was done to > avoid an expensive operation that scales with # cgroups and # cpus to > happen with irqs disabled and scheduling not permitted. There were two > remaining atomic flushing contexts after that series. This series tries > to eliminate them as well, eliminating atomic rstat flushing completely. >=20 > The two remaining atomic flushing contexts are: > (a) wb_over_bg_thresh()->mem_cgroup_wb_stats() > (b) mem_cgroup_threshold()->mem_cgroup_usage() >=20 > For (a), flushing needs to be atomic as wb_writeback() calls > wb_over_bg_thresh() with a spinlock held. However, it seems like the > call to wb_over_bg_thresh() doesn't need to be protected by that > spinlock, so this series proposes a refactoring that moves the call > outside the lock criticial section and makes the stats flushing > in mem_cgroup_wb_stats() non-atomic. >=20 > For (b), flushing needs to be atomic as mem_cgroup_threshold() is called > with irqs disabled. We only flush the stats when calculating the root > usage, as it is approximated as the sum of some memcg stats (file, anon, > and optionally swap) instead of the conventional page counter. This > series proposes changing this calculation to use the global stats > instead, eliminating the need for a memcg stat flush. >=20 > After these 2 contexts are eliminated, we no longer need > mem_cgroup_flush_stats_atomic() or cgroup_rstat_flush_atomic(). We can > remove them and simplify the code. >=20 > Yosry Ahmed (5): > writeback: move wb_over_bg_thresh() call outside lock section > memcg: flush stats non-atomically in mem_cgroup_wb_stats() > memcg: calculate root usage from global state > memcg: remove mem_cgroup_flush_stats_atomic() > cgroup: remove cgroup_rstat_flush_atomic() >=20 > fs/fs-writeback.c | 16 +++++++---- > include/linux/cgroup.h | 1 - > include/linux/memcontrol.h | 5 ---- > kernel/cgroup/rstat.c | 26 ++++-------------- > mm/memcontrol.c | 54 ++++++++------------------------------ > 5 files changed, 27 insertions(+), 75 deletions(-) >=20