From patchwork Tue Oct 10 03:21:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13414776 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 2FE86CD68E4 for ; Tue, 10 Oct 2023 03:21:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EBC66B00B5; Mon, 9 Oct 2023 23:21:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96BB66B00B6; Mon, 9 Oct 2023 23:21:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E3AB6B00B8; Mon, 9 Oct 2023 23:21:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 655AE6B00B5 for ; Mon, 9 Oct 2023 23:21:23 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 37D9CA04DA for ; Tue, 10 Oct 2023 03:21:23 +0000 (UTC) X-FDA: 81328101246.19.3E2D2C0 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf21.hostedemail.com (Postfix) with ESMTP id 94E031C0015 for ; Tue, 10 Oct 2023 03:21:21 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HkAY2PjD; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of 3MMMkZQoKCHkvlpovXejbadlldib.Zljifkru-jjhsXZh.lod@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3MMMkZQoKCHkvlpovXejbadlldib.Zljifkru-jjhsXZh.lod@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696908081; 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:in-reply-to: references:dkim-signature; bh=LVnT/y0R3LkPemDBgYVR7UpcgonMc+8VI5Wxeio9uFU=; b=uJ42XJLfdWS6FQUipzA2DEP07i0uM41dHJKZDsERGOM/VF0Bnugy9eC1M7VQ3Ugtv+bglM lsETGmqfWDeplQ84NL3ukfI4ETNpGYUYpNeth9mw2ABexQ9sw2rivgGPLOGklS5ao0NyO9 2NlKtYdhXPM0EphRppi74Ku6sWwIdW8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HkAY2PjD; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of 3MMMkZQoKCHkvlpovXejbadlldib.Zljifkru-jjhsXZh.lod@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3MMMkZQoKCHkvlpovXejbadlldib.Zljifkru-jjhsXZh.lod@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696908081; a=rsa-sha256; cv=none; b=DgP4k4ATsf+ScY81uETjXJMXgNQzhQRTNsFo4gvHWz6sfOQprrVNVFVFjdaAq7dwSTaLT6 xuJdp2C2teYHArooGss+iV4rXnw9hB0Wncm9Dx7nDcYCROS6kJPus+v+Wi4+Yk7ikPaH1V LYVgm9JTFU28lLqY7CBolEkZxM74UrI= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-d9a3942461aso1290445276.2 for ; Mon, 09 Oct 2023 20:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696908080; x=1697512880; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=LVnT/y0R3LkPemDBgYVR7UpcgonMc+8VI5Wxeio9uFU=; b=HkAY2PjDZJ3DTImd0gok8eQGbWw3TrZ9f55r01ZFv525Ep8Vp/wzJ5/gv7GTz7DrXc Gw2TbT3DL5gP2ggkw3JUYRpzMB1FbhS2f12pIU21FvGf5JE7IamnWoI5U532oDLEHbbL vjBhgVBxf68c4GkLAMMy63fPqZynPyOaRq1tGd3CGTcxz0YjQF86vQYboECZQglkGn7I pwMpv09fAyLdBBC64KCmq8fbuZAR195XSJODMPwVCFeYDnFGlpWgjfzcvTpD8RG1krRL zCCejLJ8uEeVTPjH5FoqXk2k0qOd5PwwN487WQ+1BAuodvF+L4AgM0cy+5wMMPjHfWfK SDSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696908080; x=1697512880; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LVnT/y0R3LkPemDBgYVR7UpcgonMc+8VI5Wxeio9uFU=; b=ne8UydrVPjoixKfLtX8yUy20MtjTMaFI8PBK1enLlOzTAR5RgVlBHPDR3KBLWRC/4O 5S0kl1n2TaJZ9rxqZo+BVBKigp3IeRMO9yUjV6jHqeLojWv+W4EdPVpRCUxkdzMTpBTA fyOpbwa1J3pY097ejjuxsi4O83R0BOOomMiCvLUauHLzhAiO2A5le33xLqwEfdPlAqSg cY1JYs2jrfoa1zfslq/55gwrl0uTbHxDLi3PPKJmISEb7HZipSgu5PBK0Yyi+nDzXLt/ aM5GfnV66UTvlu/GSA16dqiER/NcFnlSqNJq7eSY8T8VgwxPeFU68mji/KTVGCyybjpc 8uWg== X-Gm-Message-State: AOJu0Yy4JyYnbdx9E9WW8mY6ijfAVTgHzO7mlWYN3nlp45I7URMKLH2D obvH27fImHAovst7JVYDNZ/Y//xT4KT+hr2T X-Google-Smtp-Source: AGHT+IE3vlkDF4fIufp9m/nj7AiWytdfnQwhV+zyU/89AVG8IFJdzCPkPyGCN0ywrPgPCo7uBGiS8z9+kD3XQiDH X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:212:b0:d89:b072:d06f with SMTP id j18-20020a056902021200b00d89b072d06fmr265146ybs.7.1696908080471; Mon, 09 Oct 2023 20:21:20 -0700 (PDT) Date: Tue, 10 Oct 2023 03:21:11 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231010032117.1577496-1-yosryahmed@google.com> Subject: [PATCH v2 0/5] mm: memcg: subtree stats flushing and thresholds From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Ivan Babrou , Tejun Heo , " =?utf-8?q?Michal_Koutn=C3=BD?= " , Waiman Long , kernel-team@cloudflare.com, Wei Xu , Greg Thelen , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Rspamd-Queue-Id: 94E031C0015 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 8o6n5878qgoaafgqmnuw5s6gucc5h6zi X-HE-Tag: 1696908081-625426 X-HE-Meta: U2FsdGVkX18t7oJUm74YIeQ0L5qAfw5OIMcF8YVV/j493p8ZDxwk4t39cbP4htcjgQmhkmpGJ2JL1yRdgwDo2vLQ/DR1a5VlYZxy/82Oxa8eT3WIXb1RlFV+A+CH/1sU3KEAN7ikmE2DjyIJkxFe10Hpp4Tu4N779v4aqp1M1HwXlwoanOiWDx0Z2HgXprwN52ASk1TSVJqLOPNG44uoFSaZ02ZexhRUz1Qefs4id2VKUK/MMiGY1lcUf4aVzSjNUPm3t9qnlrnbDXfbmmcwvx7bRrmebh5LGjny12cm05CJiGl6g2C3cp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Fhl/DaqUguxL69oimBjZQH45LafDYwWO7+iu+j6un5cwCISJusTSq6Cj6vjW/umiRbtGBhWy3F9yV1sb44viIZKQzY84f17sA8qKkPrBnwzkSUk49oGs3cyXdLJ4b7vI2DnZ5uvqNdMjCojc8rnc1i3Xhc4Hr20vcJCLmcQElp2N3fXqa4QlWA2AbXdkFCnhD82ekTeYH7dJPwlHpw4yX4eRRf6PN5YmVE6rrjgZTRuYue2jM00DQ2mggP/Dyrm/Tn52rO7jnm45LToHup/93gfEsNQjdPuW283B4hlDAzyapeChGgcqgN X-Bogosity: Ham, tests=bogofilter, spamicity=0.000020, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This series attempts to address shortages in today's approach for memcg stats flushing, namely occasionally stale or expensive stat reads. The series does so by changing the threshold that we use to decide whether to trigger a flush to be per memcg instead of global (patch 3), and then changing flushing to be per memcg (i.e. subtree flushes) instead of global (patch 5). Patch 3 & 5 are the core of the series, and they include more details and testing results. The rest are either cleanups or prep work. This series replaces the "memcg: more sophisticated stats flushing" series [1], which also replaces another series, in a long list of attempts to improve memcg stats flushing. It is not a new version of the same patchset as it is a completely different approach. This is based on collected feedback from discussions on lkml in all previous attempts. Hopefully, this is the final attempt. [1]https://lore.kernel.org/lkml/20230913073846.1528938-1-yosryahmed@google.com/ v1 -> v2: - Fixed compilation error reported by the kernel robot in patch 4, also added a missing rcu_read_unlock(). - More testing results in the commit message of patch 3. Yosry Ahmed (5): mm: memcg: change flush_next_time to flush_last_time mm: memcg: move vmstats structs definition above flushing code mm: memcg: make stats flushing threshold per-memcg mm: workingset: move the stats flush into workingset_test_recent() mm: memcg: restore subtree stats flushing include/linux/memcontrol.h | 8 +- mm/memcontrol.c | 269 +++++++++++++++++++++---------------- mm/vmscan.c | 2 +- mm/workingset.c | 42 ++++-- 4 files changed, 185 insertions(+), 136 deletions(-) Tested-by: Domenico Cerasuolo