Message ID | 20230720070825.992023-6-yosryahmed@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 0DDBBC001DE for <linux-mm@archiver.kernel.org>; Thu, 20 Jul 2023 07:08:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 992A92800C0; Thu, 20 Jul 2023 03:08:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CAD228004C; Thu, 20 Jul 2023 03:08:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 682302800C0; Thu, 20 Jul 2023 03:08:40 -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 48D7D28004C for <linux-mm@kvack.org>; Thu, 20 Jul 2023 03:08:40 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 239AD1A019D for <linux-mm@kvack.org>; Thu, 20 Jul 2023 07:08:40 +0000 (UTC) X-FDA: 81031112400.09.7957363 Received: from mail-oo1-f74.google.com (mail-oo1-f74.google.com [209.85.161.74]) by imf07.hostedemail.com (Postfix) with ESMTP id 313354000F for <linux-mm@kvack.org>; Thu, 20 Jul 2023 07:08:38 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=QdsbdWEv; spf=pass (imf07.hostedemail.com: domain of 3dd24ZAoKCEA0qut0cjogfiqqing.eqonkpwz-oomxcem.qti@flex--yosryahmed.bounces.google.com designates 209.85.161.74 as permitted sender) smtp.mailfrom=3dd24ZAoKCEA0qut0cjogfiqqing.eqonkpwz-oomxcem.qti@flex--yosryahmed.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=1689836918; 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:in-reply-to:references:references:dkim-signature; bh=OzwAcynUjm4TDDZtYUdTlt8GRef6hCkFmXsjGPYLvQA=; b=X/DgpT2K1fQNCG3YhL8LIcTvAwcMPRVBDbbeC1aUEl+CLBj8nlwaqTVrrNCthWy163kk+1 M0bWuYMEoH/9zpOV6+pCrnv62Db9tdhaKFkgR2fseAHkkvvWOi2KD5jDqHERHvNx4hUApA iORdO3/BTRmyTIRYMN6Cnm5qgygC/uQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689836918; a=rsa-sha256; cv=none; b=DbYP8bUpUE4RwroFdphspgTuLFYDu+RGF4Hat+sRo8Qk+pd5Pkb8UjvRbCriK8H/B52YXY Cq25vlwMDeIyA29vKbsJo3N9MTLT6kk/ObKpWy6FWpZ38Mhu4auWaee9FqiKjtBwDppfDV yLXf+I/5iZd3ONFn3HWnRffKctc4xXw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=QdsbdWEv; spf=pass (imf07.hostedemail.com: domain of 3dd24ZAoKCEA0qut0cjogfiqqing.eqonkpwz-oomxcem.qti@flex--yosryahmed.bounces.google.com designates 209.85.161.74 as permitted sender) smtp.mailfrom=3dd24ZAoKCEA0qut0cjogfiqqing.eqonkpwz-oomxcem.qti@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-oo1-f74.google.com with SMTP id 006d021491bc7-565f0c7c243so828484eaf.2 for <linux-mm@kvack.org>; Thu, 20 Jul 2023 00:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689836917; x=1692428917; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OzwAcynUjm4TDDZtYUdTlt8GRef6hCkFmXsjGPYLvQA=; b=QdsbdWEvmo4m7dFreE18whaI10HNxA5U6Eq4dlh5z46nHRuNKvgnmtyQrlecaO4sV8 pWMQ+xztiQx/wc1YGWhMYzOCtuiM6PjW82kZXGkYJ68Xwsx5KrsGhi4OgbRK80gIgcB7 clLYTavc+M9b93VW/QkD9WL4K9KunD/+0BOFjNktnoseyObLt2ro/bWXeUjfsH//HPvv iKo/LdVH7XZs+1rJF1M/AwxhXSl+9z13Axu/a0fHLc9te/mN1I0tCp0Us23Ispa/XUDp ufe5XWIgsZtbi6tiF99R36YBIvSUA+Db8luFMXb3WtMXUvnpGh0pFJrrPbseVvr7ZJUC YeoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689836917; x=1692428917; h=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=OzwAcynUjm4TDDZtYUdTlt8GRef6hCkFmXsjGPYLvQA=; b=F/jep/c1PVlsDZKbWEqiQ0c76esEbbyOR5Xk52UvDC5C4IwHNp3FX5zeciOfMiqfAQ 3PApAk3zY+mF+s3eeMTcxVpPgUFjkip0cdzlsLISmlQRMxLO1BYXuPeIT5DG8E+NGMmR PTG/c6Gv7W1gPoKEj7wO+SFqOgBLy3JxoOAmTBfVooXW7BSw5d72Hzr8QeoCAgnd5hec qcdK5vUjXkVzj9ui4oj3FLqy63GccScxqmqPuQHQgBgciiCT5C0bUTXwdR7JJLGvAsit 8YAhXA879d2ek3TbU+CMuDs1ygLayL0XLJMgEkVKil916FL/VOh+qoFkqrvKfAW2gXQy lZdA== X-Gm-Message-State: ABy/qLaFObdHuGGEcqZyh2ZVWUwt+i+IQfw282P6xU24PMdPOpLkgxUs Xhqz2q5s618PHYr65iCBrrvFnZjaVg+l2oNC X-Google-Smtp-Source: APBJJlHxP5P9yoiXFXdFsa+fxsrJ91qoDIJe3rq084GoRyXYn6ED56dX4GksMdKRSpbhY7hotG9fq78xxc+urVcp X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a05:6820:34a:b0:563:4841:891f with SMTP id m10-20020a056820034a00b005634841891fmr2470502ooe.0.1689836917359; Thu, 20 Jul 2023 00:08:37 -0700 (PDT) Date: Thu, 20 Jul 2023 07:08:22 +0000 In-Reply-To: <20230720070825.992023-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230720070825.992023-1-yosryahmed@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230720070825.992023-6-yosryahmed@google.com> Subject: [RFC PATCH 5/8] memcg: recharge folios when accessed or dirtied From: Yosry Ahmed <yosryahmed@google.com> To: Andrew Morton <akpm@linux-foundation.org>, Johannes Weiner <hannes@cmpxchg.org>, Michal Hocko <mhocko@kernel.org>, Roman Gushchin <roman.gushchin@linux.dev>, Shakeel Butt <shakeelb@google.com> Cc: Muchun Song <muchun.song@linux.dev>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Tejun Heo <tj@kernel.org>, Zefan Li <lizefan.x@bytedance.com>, Yu Zhao <yuzhao@google.com>, Luis Chamberlain <mcgrof@kernel.org>, Kees Cook <keescook@chromium.org>, Iurii Zaikin <yzaikin@google.com>, "T.J. Mercier" <tjmercier@google.com>, Greg Thelen <gthelen@google.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, Yosry Ahmed <yosryahmed@google.com> Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 313354000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7goh9xmqcqgq84rb3qgyb5raard1apiw X-HE-Tag: 1689836918-405576 X-HE-Me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JVqtysO4YoX7/cyr8u2nOPg1JKSTBQP2xfftZJU4nAeQ7+qL7RD/Lr42A/qXGsjRapsoLNAnaFIvIKN9IHSVq2Lebu+lZp0qDgbQ9VmiXB2L9ESa2sQPMxOiBrOjfkO+A/s13YhzPDjQNKh4qdZYfyRfieeQLPB+tygecajp0Nh1dNUyyptGJLg5jWyyBndfonvXs+ZbOpluJyl8L/ZezV2xhVLzJAke1iWYCZTM0PL78TQrX5sAQ5GkWI6qyAbzCaOBTqgisK0umCH3wHWnbx+IoPfxU+/2qjQxojYSUbaGF50Typ4MOesR17nCWWijY6qQgvuRTTw2D3MTlI9JTlQzq45cwAb/8Siv71A4R/xL1qEpHkhr5QiEcYh1Lu1ojzyO8VHhG1+ayiGaCfB6RHlrbhgVFH2FQpLI50zNeG+anX5RxDG/KwJI2jjQpmctqTJCS5iNBt2L9yjy97d9a2BDvrp+LOhH8Fqqu+eQB/GksOmLS+7cTlFhH1ARUUfEyHWb31dA/4mqDKUxweAmVQdjeIsE2wrXMI4ZZ+JwbMpPvfEM= 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> |
Series |
memory recharging for offline memcgs
|
expand
|
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index d3f42009bb70..a644530d98c7 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2785,6 +2785,8 @@ bool folio_mark_dirty(struct folio *folio) { struct address_space *mapping = folio_mapping(folio); + folio_memcg_deferred_recharge(folio); + if (likely(mapping)) { /* * readahead/folio_deactivate could remain diff --git a/mm/swap.c b/mm/swap.c index cd8f0150ba3a..296c0b87c967 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -457,6 +457,8 @@ static void folio_inc_refs(struct folio *folio) */ void folio_mark_accessed(struct folio *folio) { + folio_memcg_deferred_recharge(folio); + if (lru_gen_enabled()) { folio_inc_refs(folio); return;
The previous patch provided support for deferred recharging of folios when their memcgs go offline. This patch adds recharging hooks to folio_mark_accessed() and folio_mark_dirty(). This should cover a variety of code paths where folios are accessed by userspace. The hook, folio_memcg_deferred_recharge() only checks if the folio is charged to an offline memcg in the common fast path (i.e checks folio->memcg_data). If yes, an asynchronous worker is queued to do the actual work. Signed-off-by: Yosry Ahmed <yosryahmed@google.com> --- mm/page-writeback.c | 2 ++ mm/swap.c | 2 ++ 2 files changed, 4 insertions(+)