From patchwork Tue Aug 13 20:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinsey Ho X-Patchwork-Id: 13762479 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 A0CCBC52D7B for ; Tue, 13 Aug 2024 20:47:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 320CB6B0083; Tue, 13 Aug 2024 16:47:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D10E6B0088; Tue, 13 Aug 2024 16:47:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 198A06B0089; Tue, 13 Aug 2024 16:47:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EA80E6B0083 for ; Tue, 13 Aug 2024 16:47:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 97DC4A0AA5 for ; Tue, 13 Aug 2024 20:47:55 +0000 (UTC) X-FDA: 82448408910.20.375988A Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf05.hostedemail.com (Postfix) with ESMTP id CD78C100004 for ; Tue, 13 Aug 2024 20:47:53 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jmsxtWG1; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3eMa7ZggKCDEXVafRlUbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--kinseyho.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3eMa7ZggKCDEXVafRlUbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--kinseyho.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723582021; a=rsa-sha256; cv=none; b=cBbitGw4WUgMB7GHHdbVznAK+4+gQ5/jUJH9FCE0Lx91mEq7EDmcLpZP/xhkzsMf9/sw6j 0q2dW1g8G83n3APwPeXJkUZWv9sPmXBzGAnN+bBEKrmqeXDENUSLPoAsJ4FN72xounEnMt wt1vAECiJioRT3cCl9lEdeMoaZ7HgTA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jmsxtWG1; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3eMa7ZggKCDEXVafRlUbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--kinseyho.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3eMa7ZggKCDEXVafRlUbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--kinseyho.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723582021; 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=6VTAXcSzg2nJxUF/QOoTMCzcY75N5+KjH45iaTDlnBg=; b=AWLUMH2iy16SEiSouaHlidKsDNSivZop2YPXg27oFXsDbM0ZCr9Zjmdpn1YKM6DVDkOM1u OnbLczAAJQgM16hA0opGwfVPkANKoyCCw3+aaBz1eCGI/qh+DUHe/8CHJk8X13GLgggwcT fYrfV72MucLpr2FL0A7W2IRTmKLqWb0= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6688c44060fso136690087b3.2 for ; Tue, 13 Aug 2024 13:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723582073; x=1724186873; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=6VTAXcSzg2nJxUF/QOoTMCzcY75N5+KjH45iaTDlnBg=; b=jmsxtWG1IziCcvPlaQ3YGV+8XFRH4+9g8CTRVKOl/JbGH5pZQ3Qxe/gEemeHdaE6lM v6t4y5zbVHQwyzBKJkzRaLhKOGgAQifXZE0Hwybccx8XHjxWM31/sLh4tps0mNPFzHGy ptaPB3MCUVs0B6c35CQF7oS2vcn4awsFD4Ims+REgYcL6zQsiF04i033FjvXXfWnBbk3 O8haMPhXC9AaNShe7KYQmpdKAoDhLr0aqGnOE5UF84T5WfoSVQoQHKhd6ju214JoQ70b PIt7RzbSuGjh4uqcXpqChwf8P/bbWUai02oYBvYLQfoYtSOP/rx3xzMrh1hTUHZdoekY jw1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723582073; x=1724186873; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6VTAXcSzg2nJxUF/QOoTMCzcY75N5+KjH45iaTDlnBg=; b=Nmd8AnSrpJEnz+wUGQZK1MGrSrnXg6cDFjKX1tbTw/1EN49lCI2nsR2QlGy63R3yq2 C/PW+iamxK2nc+6eeHjF/4wHvGR+5ZssnNrjjG5MIrQ0nCrYam4+SqxO5FtYqLiOU7DZ RjGxz/EE/XFOWliyLevfkCFNPGj7iBj6I20WRkJUtDIPrgY1ZX1fgs5KutI9xNIehLwA oRGMCRFhnIXSK8ESM3JUqwWAPxzeen626IGpJ1xsmlWk8c8RjWJY4D3lxqvuHhm7C1bK Sg1Vwyc9NLcj5Lsy9e/dcJdDX4Ga0luyb+xiQhIwSLil1tqFDsoNXnnxYDC2ClZ0IhK1 vJyg== X-Gm-Message-State: AOJu0YwSaP5rAzgXhqwbyQ8qYv/4nCLzel2flDiM23WTt3b69xjmv2NO LODbPq+FSYUK0OGRiVQOgYR7m9MTJaBegRwZkUOkk0Rc2Mt4qCJkvjYtR1S3NCcizIy86nJYmqX UY2DAB0dkzQ== X-Google-Smtp-Source: AGHT+IFzblsx6HVwSONVyuq1qq/U8tF5umc8wK7YjkPphN9wlYyR7AcobNhp+giR2cU9kqZsxLwEY6K/rtnFFQ== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:46b]) (user=kinseyho job=sendgmr) by 2002:a0d:d385:0:b0:673:b39a:92ea with SMTP id 00721157ae682-6ac997f8a9cmr286847b3.7.1723582072721; Tue, 13 Aug 2024 13:47:52 -0700 (PDT) Date: Tue, 13 Aug 2024 20:47:10 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Message-ID: <20240813204716.842811-1-kinseyho@google.com> Subject: [PATCH mm-unstable v2 0/5] Improve mem_cgroup_iter() From: Kinsey Ho To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Yosry Ahmed , Roman Gushchin , Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Tejun Heo , Zefan Li , mkoutny@suse.com, Kinsey Ho X-Rspamd-Queue-Id: CD78C100004 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: kfho1kwbokhe3zz9qi7xsdj136rdohns X-HE-Tag: 1723582073-416468 X-HE-Meta: U2FsdGVkX1+w5CpsMek3w4o5/MkN6lADYrXPdUoBxNocSN49NvbdfYvzYF8PCy7V0S70nFZ+CJSwu4NnrdimzHQw/NpLMbp4A6uyAawMKusJGaMlLUB1+PYEwEr6Mk/2SBqmo7/MU+CdjjCCJMma9KtWhjoSLHwsJVHDzPcf95QIjt2e18MtJgYuRHXOVjUsBgkU3IKYa2o50wxnAZM84QMD6DjtBSEKwEc/BwGoZkU0MYywuozT1nvxscbnEAieQQcLiFCxs5kg1SySXTQ6WPEGLGws8fhWcA/4jBhnhQ8i4zRj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k8U2oYIaApti3McYnYtGMmIvEZ/UOO4MMz9Tc6DF3xV7MoU+WqeK26nMQUtCMsRucGn0bjbSKGJHDriuHM4SJfqX3MLMTfNkbniEqLihX3SnaZXG41nGke8N4bF/Hzpv/5NNDNP8nUC4IkC92hAaK7Lo3D/CXwobfODwLhYGce+yVGutxf7MGsfdwpgXWizUSvWq50/94bI09f8jRFNclhORhqbUEaU/A4OMapF5n3cBscBvlyzc+t1FAwIpHq+Xyam3lfGZ5HwKSUjQqwl52DY/IBm3/gLjJ2kMFRLLjVR++DxwoJXZzXIxpTnnlKI7bToO1jHW6kEWOsd2VBD3iibGbghm5VCuG3 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: List-Subscribe: List-Unsubscribe: Incremental cgroup iteration is being used again [1]. This patchset improves the reliability of mem_cgroup_iter(). It also improves simplicity and code readability. [1] https://lore.kernel.org/20240514202641.2821494-1-hannes@cmpxchg.org/ --- v2: add patch to clarify css sibling linkage is RCU protected. The kernel build bot RCU sparse error from v1 has been ignored. v1: https://lore.kernel.org/20240724190214.1108049-1-kinseyho@google.com/ Kinsey Ho (5): cgroup: clarify css sibling linkage is protected by cgroup_mutex or RCU mm: don't hold css->refcnt during traversal mm: increment gen # before restarting traversal mm: restart if multiple traversals raced mm: clean up mem_cgroup_iter() include/linux/cgroup-defs.h | 6 ++- include/linux/memcontrol.h | 6 +-- kernel/cgroup/cgroup.c | 16 +++---- mm/memcontrol.c | 84 +++++++++++++++---------------------- 4 files changed, 51 insertions(+), 61 deletions(-)