Message ID | 20240905003058.1859929-3-kinseyho@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 3975ECD4F4E for <linux-mm@archiver.kernel.org>; Thu, 5 Sep 2024 00:31:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EF4F6B01FB; Wed, 4 Sep 2024 20:31:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02A476B01FE; Wed, 4 Sep 2024 20:31:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE60A6B01FF; Wed, 4 Sep 2024 20:31:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BEC926B01FB for <linux-mm@kvack.org>; Wed, 4 Sep 2024 20:31:53 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4859380FEE for <linux-mm@kvack.org>; Thu, 5 Sep 2024 00:31:53 +0000 (UTC) X-FDA: 82528806906.13.15902D3 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf10.hostedemail.com (Postfix) with ESMTP id 73097C000B for <linux-mm@kvack.org>; Thu, 5 Sep 2024 00:31:51 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=B3fqiMfl; spf=pass (imf10.hostedemail.com: domain of 39fvYZggKCI4205AwGz6y66y3w.u64305CF-442Dsu2.69y@flex--kinseyho.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=39fvYZggKCI4205AwGz6y66y3w.u64305CF-442Dsu2.69y@flex--kinseyho.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725496287; 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=sqTDHTCRiwsvIU2qvmmvg5mPCxzlppgliuAtX0a739I=; b=itANnevBEXl/MkDPD7hz+OWEDukw13UFrVw5D5cDQGi5ja5de4espQYORotTPTMgDeSKMM YpXoWg3D7a7ZSdbWxvHwdzH0bHCmcU5YBLAhQqrLCI+bXdMfMpPsZuftsP2v8CHwx1OGwu 3OfkliKO6G+fVI2Y6CaMqE1dKS33vTA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=B3fqiMfl; spf=pass (imf10.hostedemail.com: domain of 39fvYZggKCI4205AwGz6y66y3w.u64305CF-442Dsu2.69y@flex--kinseyho.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=39fvYZggKCI4205AwGz6y66y3w.u64305CF-442Dsu2.69y@flex--kinseyho.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725496287; a=rsa-sha256; cv=none; b=57QeYotNHj+npcl/desHQOOOd2tVVrnW2bVbsI6PsllOoRSXv1W0gsjeniTj6wTXEfNu2a cHREohKcfslcF2n1+QpLNRwS1JVNAIIalOeeupRvTLHqDnhVanbWyC5IWbjExoCZnlCu6b 4bx3p/9cPsJjrs1LO5BBDhmEbdX3fso= Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-7cd9ac1fa89so285946a12.1 for <linux-mm@kvack.org>; Wed, 04 Sep 2024 17:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725496310; x=1726101110; darn=kvack.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=sqTDHTCRiwsvIU2qvmmvg5mPCxzlppgliuAtX0a739I=; b=B3fqiMflJFPoIMxv7o0rsmFuj4zjKkdLSC/jas+O40+5P92JBJ5A3LBP/kOV89FS1E zpSUxhHISIz8c7jaL3k1GItynfaC7NvcujiHADXG3JhDQtZg81QJR/WsXXEChusfBvI9 K4lPIy1zCANQLn8lSUj+DLMolm+iVC5XhSFBZXzWbOvV2WSLgr2mba1mi09cQ5XiWhbC Ldrlkkny4gFjG5czpDL9JujmhnvWK5hl1tROD6DfheKQ05TpPf3c3TSxV4+SwpCg/Xz9 TZu7e+L29+6IIgDTKuGxwkAd4ER/0GDwbSdPhAUpaozAX7eN48Eh8U/3j88yab3+6nXJ G2NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725496310; x=1726101110; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=sqTDHTCRiwsvIU2qvmmvg5mPCxzlppgliuAtX0a739I=; b=ty02lUyVjR7xEQzaUtZg48DX0/he+jtcJsdadP00f3I4Y+BXuTnhNaRj9qO5JT+IOa RGqtzEJHimEGiqcQYXVPNbalw9gzRdtH/r79B4FUJS53tJyQ4WVkNEQRr0Vx3zoxEvuf 6RHwaGEz8NQvFv5ta0pc8AU3RAFfHxpsS5fpAYge/sGhq2WYggmzZqxtuhWH+VGCfAlu 1YaUCjaIFqpaHZ6Rna1SFzzIJnWf6cj4WKUpnRdcSvEGb/b815oM9WnvluT2RVAjmrrN XxE5zSgq1kiStR3T1NSNmDKmzVum5x8gyY4e68lJ6pRX4E2/qp61o2AyKkll0NA1AzbH mKzA== X-Gm-Message-State: AOJu0Yz/QsH9/aBPxJuBKTHM6/A0hxs6C/byf85wCvnL409myp1XYKn8 msJd323CHDitACAGJpJhjHnhkURVfaiClcm3yYuzhI15e62S7T7bRGN3Mc0kErRon1T3wPXmqqR rXWQTyhPZ2w== X-Google-Smtp-Source: AGHT+IEOy0bHsy4chODc/dIKYmpQwZgXe72gHtWSiqNJNS/vQMmLAYyUUqkUY8wRavMe2EY8pkrILzNoQwJIVw== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:46b]) (user=kinseyho job=sendgmr) by 2002:a63:e34e:0:b0:6ea:d240:23b0 with SMTP id 41be03b00d2f7-7d4c1019e5emr56861a12.4.1725496309928; Wed, 04 Sep 2024 17:31:49 -0700 (PDT) Date: Thu, 5 Sep 2024 00:30:51 +0000 In-Reply-To: <20240905003058.1859929-1-kinseyho@google.com> Mime-Version: 1.0 References: <20240905003058.1859929-1-kinseyho@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240905003058.1859929-3-kinseyho@google.com> Subject: [PATCH mm-unstable v4 2/5] mm: don't hold css->refcnt during traversal From: Kinsey Ho <kinseyho@google.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Yosry Ahmed <yosryahmed@google.com>, Roman Gushchin <roman.gushchin@linux.dev>, Johannes Weiner <hannes@cmpxchg.org>, Michal Hocko <mhocko@kernel.org>, Shakeel Butt <shakeel.butt@linux.dev>, Muchun Song <muchun.song@linux.dev>, Tejun Heo <tj@kernel.org>, Zefan Li <lizefan.x@bytedance.com>, mkoutny@suse.com, "T . J . Mercier" <tjmercier@google.com>, Hugh Dickins <hughd@google.com>, Kinsey Ho <kinseyho@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Stat-Signature: 4rikw65zfopo1k9bc7m3tj84oxn435h5 X-Rspamd-Queue-Id: 73097C000B X-Rspamd-Server: rspam11 X-HE-T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uIiPm0mCPt7vvqAIlkh/So9h/wFCuZ4rI66F4NYGwiUVSDgkk9TpahILfpKrqMABO4dC9sZkNm9lqwx4lNnMh70lSFK0z3LZQMH1zI1BwyWTkvdQh6t8DjX09CO3fMP0AoWgWt/gRI23oMKQFvp2codhqK0ZRlN5tsreRnUF6wv6KXtZnhW+yWWO5hrDrIAsscmabqkqtQlNXuj4nX0GrvZ1toj8uAyXIjW2m9ij5ai3dUsoj7tbJVUGRb5thZpkouZueGiA2owQcD73+J2HZqMniDbg2cEpL/bcytVXpkDMBVCZdwZ9ele4nQenPhFp7ehGOiz7TV1V7r8hGagcG6Rf6waQ4zIyrmNoZToVsnWJsHaQQ6X94i5PT9JIMXFhc6JL70ZKatPi0he1GvpU/k7iWEPSuHiBjK+VW69HHMq3/6GXv6tvR7i+ky04Pm29/DuvXFwojYTpOearok/gIBTqVagI65AMJ67AGNl7RaGbdQySmPR2gzpKXgiALArPGoOZhP9NRaslLLsXKBpShYc65GtlRdtuO6ElgC34T2lJOXJCAH54xWkjuPhUl+j9bIs1CWlGqc5/un1Wq1pm2WEa+D47LK7xtjkZdpDQSUWiJ8UuvVjYzcTDmY468QezQh6IWw2zmaM8GR0wSq4OKnNjfR/0T 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Improve mem_cgroup_iter()
|
expand
|
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index dbc1d43a5c4c..cdd324812b55 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1015,20 +1015,7 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, else if (reclaim->generation != iter->generation) goto out_unlock; - while (1) { - pos = READ_ONCE(iter->position); - if (!pos || css_tryget(&pos->css)) - break; - /* - * css reference reached zero, so iter->position will - * be cleared by ->css_released. However, we should not - * rely on this happening soon, because ->css_released - * is called from a work queue, and by busy-waiting we - * might block it. So we clear iter->position right - * away. - */ - (void)cmpxchg(&iter->position, pos, NULL); - } + pos = READ_ONCE(iter->position); } else if (prev) { pos = prev; } @@ -1069,9 +1056,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, */ (void)cmpxchg(&iter->position, pos, memcg); - if (pos) - css_put(&pos->css); - if (!memcg) iter->generation++; }