From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E34AC83F34 for ; Thu, 31 Aug 2023 17:18:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15BC0280003; Thu, 31 Aug 2023 13:18:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10AED280002; Thu, 31 Aug 2023 13:18:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEC39280003; Thu, 31 Aug 2023 13:18:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D910E280002 for ; Thu, 31 Aug 2023 13:18:40 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A9B7FA01FF for ; Thu, 31 Aug 2023 17:18:40 +0000 (UTC) X-FDA: 81185059200.09.67E011D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id A30CA40017 for ; Thu, 31 Aug 2023 17:18:38 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HSjWTSUO; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693502318; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=jBklFU3iiv7RvzlkD14uYmQsEA+NjOWwBhgNqF5FB9A=; b=HIFmSFekZYtTWLZyE3jJ2jN0FaHOn97gejjTkfCFDLRbe6XUO7gp0dQMwX6QFncV9+ROti LKJDR7frGV2nuAWfgIKTP3cQazRCct4HaeN8xBrrbys69i1noeuHB3PlCd8UWiWEyUeV7e wtJDBbwpgV4i5JUjggSssOBrLTJ9vhA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HSjWTSUO; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693502318; a=rsa-sha256; cv=none; b=h8BDDpKT23FLnjYXmTrO152P6T2ivEm48x5fSDquT+Gxkswq49jPS9pHaHxm8SP9YBiuPT b3868vtfqcXeeZZfgvN6IuByF34UZ+kUB/ygKwpWlUL49wdiAxR/TitWgenxmsSwFmXy8t exYHqHvEKjAf0yx2aOeR6vhLNlUvt8I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693502317; h=from:from:reply-to:subject:subject: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=jBklFU3iiv7RvzlkD14uYmQsEA+NjOWwBhgNqF5FB9A=; b=HSjWTSUOBzATvb9nWzfCqbF+UkTq+aUksicXnhQ3/cEUhsiEaPHmzVUJOOLsk0U1MWG/HT TWkG4JP1Y54Sas9WZ8BFfRhZhqNQ5F6TtKDu0Oq2Oi7IeyeNULs44CR/YDxk/RBXX5XjDW pan0noP6b+9mhnt1KV41Gk3M5iR3Q1E= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-599-Fouv2VfFPIOGfNHhFeDIRQ-1; Thu, 31 Aug 2023 13:18:32 -0400 X-MC-Unique: Fouv2VfFPIOGfNHhFeDIRQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20E9D3C11A18; Thu, 31 Aug 2023 17:18:30 +0000 (UTC) Received: from [10.22.17.50] (unknown [10.22.17.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 302C74021C8; Thu, 31 Aug 2023 17:18:29 +0000 (UTC) Message-ID: Date: Thu, 31 Aug 2023 13:18:28 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v4 0/4] memcg: non-unified flushing for userspace stats Content-Language: en-US To: Yosry Ahmed , Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Ivan Babrou , Tejun Heo , =?UTF-8?Q?Michal_Koutn=c3=bd?= , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230831165611.2610118-1-yosryahmed@google.com> From: Waiman Long In-Reply-To: <20230831165611.2610118-1-yosryahmed@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Stat-Signature: pm3zrc7yznqegwz9ecw8uqhuyqphesxj X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A30CA40017 X-HE-Tag: 1693502318-953240 X-HE-Meta: U2FsdGVkX18Vif5bVyQEUnkGO0CGZPVP7Agv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hy8xXnAmZsyD35XoXqwf8qyoDycvDNOg0jJRm9K0WLRlh9yOcKIaoVpbzvde9A+uRxU+NJjDHVJQhHEOYRvN0/PapZsvW9RppveHEkzJK8kmM0bg6V+aYMFpGbcReoPz2ClqGPwJz9wMIblxSmBb/Ux2Uac/95PEsf8yZot+Z65xmv2CfCGCgrf4NFdFNzuDRtMaR/vflBsfLhB5byc0n1O/IlQuizVsXvWQ9S0fWp+m9aXrkuVtpJAvz3PHKj7nw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 8/31/23 12:56, Yosry Ahmed wrote: > Most memcg flushing contexts using "unified" flushing, where only one > flusher is allowed at a time (others skip), and all flushers need to > flush the entire tree. This works well with high concurrency, which > mostly comes from in-kernel flushers (e.g. reclaim, refault, ..). > > For userspace reads, unified flushing leads to non-deterministic stats > staleness and reading cost. This series clarifies and documents the > differences between unified and non-unified flushing (patches 1 & 2), > then opts userspace reads out of unified flushing (patch 3). > > This patch series is a follow up on the discussion in [1]. That was a > patch that proposed that userspace reads wait for ongoing unified > flushers to complete before returning. There were concerns about the > latency that this introduces to userspace reads, especially with ongoing > reports of expensive stat reads even with unified flushing. Hence, this > series follows a different approach, by opting userspace reads out of > unified flushing completely. The cost of userspace reads are now > determinstic, and depend on the size of the subtree being read. This > should fix both the *sometimes* expensive reads (due to flushing the > entire tree) and occasional staless (due to skipping flushing). > > I attempted to remove unified flushing completely, but noticed that > in-kernel flushers with high concurrency (e.g. hundreds of concurrent > reclaimers). This sort of concurrency is not expected from userspace > reads. More details about testing and some numbers in the last patch's > changelog. > > v4 -> v5: > - Fixed build error in the last patch with W=1 because of a missed > 'static'. > > v4: https://lore.kernel.org/lkml/20230830175335.1536008-1-yosryahmed@google.com/ > > Yosry Ahmed (4): > mm: memcg: properly name and document unified stats flushing > mm: memcg: add a helper for non-unified stats flushing > mm: memcg: let non-unified root stats flushes help unified flushes > mm: memcg: use non-unified stats flushing for userspace reads > > include/linux/memcontrol.h | 8 +-- > mm/memcontrol.c | 106 +++++++++++++++++++++++++++---------- > mm/vmscan.c | 2 +- > mm/workingset.c | 4 +- > 4 files changed, 85 insertions(+), 35 deletions(-) > LGTM Acked-by: Waiman Long