From patchwork Tue Mar 28 22:16:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13191621 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 1355FC77B60 for ; Tue, 28 Mar 2023 22:17:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 220FF6B0081; Tue, 28 Mar 2023 18:17:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1817B6B0082; Tue, 28 Mar 2023 18:17:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC77A6B0083; Tue, 28 Mar 2023 18:17:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D74C66B0081 for ; Tue, 28 Mar 2023 18:17:07 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B2FEF1204E8 for ; Tue, 28 Mar 2023 22:17:07 +0000 (UTC) X-FDA: 80619718494.09.0EA95A7 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf01.hostedemail.com (Postfix) with ESMTP id F02C940013 for ; Tue, 28 Mar 2023 22:17:05 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=s2Rhy6bh; spf=pass (imf01.hostedemail.com: domain of 3YWcjZAoKCOQeUYXeGNSKJMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3YWcjZAoKCOQeUYXeGNSKJMUUMRK.IUSROTad-SSQbGIQ.UXM@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=1680041826; 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=AvW0vRtvUGz6RfpHjuJf5DcrLtUCw4uDLtzj7kPXkaI=; b=sT10cfpzk9V9W2cTNYc9Jk1gwaDHG21+j5Aup/YnNafzkBztWJGbGmGmXQWA5b5yis4ze2 1GnSBzfZHHCz9vbZHr0YswdkzAvQ7Xcdy/xiv13I5+kYyzMJ8ptmyyuJ8qFkbRMDWQM4gl xr+rirw536dhhIVPT7PnMTExefgSrhw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=s2Rhy6bh; spf=pass (imf01.hostedemail.com: domain of 3YWcjZAoKCOQeUYXeGNSKJMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3YWcjZAoKCOQeUYXeGNSKJMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680041826; a=rsa-sha256; cv=none; b=fof3oGczjNrdnN3K8cxBlN8KH32cBSpa/udG2smTFaSnYnSlm7kPJz1e7XBofmzeB69U7B idnNHwcNBTsKaDxavw/tmP7MzkIy4y2/bgHojz7/dBPRyfjH9/AWOAjLMesUxhPV5C2xfC pS3gEUUcr9BxPtCJavy9n8gSXvWqXT4= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-536a5a0b6e3so136900407b3.10 for ; Tue, 28 Mar 2023 15:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680041825; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=AvW0vRtvUGz6RfpHjuJf5DcrLtUCw4uDLtzj7kPXkaI=; b=s2Rhy6bhmsxOtwUgNmtWPZ1OIy2px3+ZgcKdui8SYbOasl9GBmkC/HgOP+eca1phsP jP5oqLAVmD71L+yTcF9Qf7RNoZtsSSFPX0S6Mq6S5HfUed3nW8TUcaJtaUm/tsI8O9Am d5OJg/swbll5+1GgM/EDnx0GyYjs89Yzqk1B1Gc+8UCS388fxVzDgMBm93/UJRyrTJYr f1CeTGEfaowg6ARY0FoahfZMcN2kOGoi1UzCuTmmzShA86ZvRPo5Rcmo6znhWB9xOjYc VRAX/Gquhhjvyizfw+QszvCjk77JT0+yZFVam4Xqz3PGsmr5F2QrldBe6NoQ8SARTtvR pWDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680041825; 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=AvW0vRtvUGz6RfpHjuJf5DcrLtUCw4uDLtzj7kPXkaI=; b=Dm5/CAySmkrxApGXmakl4TS5kEpAnPr795xHyEx9VriJfgnUUeXMFkEH4sRopw419s 36KOhNWVrtOyA8VocHPojLQwUGwLlGa42x1hfRIJKmGuoTSJsw74+Wjgae0MDgDlohgy fLGW4Vee6aLMDslcde/8f16Yr8LRvEHWgA25uAa9l1AS5ag0cokLiEG2D7lo5pdVo1/x /SpmudfiO9x/vAKzk3Veyu7u6LiAj24nUZkvsgCQ+3drkCKg4Rj8ohbIZRwWpErCouEt 5ao8ppMrvFAAFAG27rVrOpedPdxHD5KDLCmAE+ro52Hcan7NeTVCiVL4ZEjXGwTdKb9m 7nDw== X-Gm-Message-State: AAQBX9cIHPDq60Qb6/NC8RzM7f3iqukzVhitHC9fH3cjt68fpvC63a/0 75I9ULuALkgn5/pDvhVoerwJroY+p6tt7rd2 X-Google-Smtp-Source: AKy350aC/5JUEL/+7c/dIUP+7KT0Wk9JcWhzZQ4Xw7OfNYXAfRzlQJVntfC4MTRTs3t2TIUHulQT5W2wJHMWSZ0v X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:722:b0:a09:314f:a3ef with SMTP id l2-20020a056902072200b00a09314fa3efmr10887537ybt.12.1680041825151; Tue, 28 Mar 2023 15:17:05 -0700 (PDT) Date: Tue, 28 Mar 2023 22:16:43 +0000 In-Reply-To: <20230328221644.803272-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230328221644.803272-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230328221644.803272-9-yosryahmed@google.com> Subject: [PATCH v2 8/9] vmscan: memcg: sleep when flushing stats during reclaim From: Yosry Ahmed To: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , " =?utf-8?q?Michal_Koutn=C3=BD?= " Cc: Vasily Averin , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, Yosry Ahmed X-Rspamd-Queue-Id: F02C940013 X-Stat-Signature: siaip7r3bt8t3y1ww98pzar4broktjci X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1680041825-162608 X-HE-Meta: U2FsdGVkX19wyVJ+7a1Q9qNT3BTmhd+SZgc74qds4B+p9iA+aHkc9pFKD5UIiG2xlFccCTFcLkba7cwfZWzMpchE/JX5597M+EOSfzqLSF7dzqJxujf6/Pc4gXlqF1E/Cb7h7/PFSe7e956iNhEJUGjFI81iEOGjbRYk4M7/R5W26chmyisM4If9TYDYhWGMEXWOqPTtzzw2lGP6zgE7R1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8G9QzcLCltL0nJRywcnS0fq50gQlV3ri2R272comAmF6glqu0iHpe+U4z4NBEOmdA+NUHn+1GOH3CGtGNwLGgTg7Cj4pBupM8iz8KL+olxJXyMMQcQdpWT3sVI1d8vA5f8HOMzMe+VmcqUXcAy/PnQScUYeP1+l280q83wQPG+9dxVKp3m1O0ydhKQro5e8WbiXuGN79jBMPiM6CvRNNG83yrJBYPQb+ksUp2GS5V+/eLCK0oruGFq+7wmgxFLDe6vsB4XYWmeNdyDI2FUXhsESRozvIeJMCYb2wWzWTjowGz7q8fGMGfNLzcT5G1SNnQgoTvhcjD3CxpwEmr+pHl57PFFlmkVnGxpfbJxLS3FKr1TbAWitayB9voyRoUdFCyNCupEC7q6gYZ4fj9mQn92TkgUQfGtkTFBUjOU//q9sWyENMG5Ji9/jcbA== 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: Memory reclaim is a sleepable context. Allow sleeping when flushing memcg stats to avoid unnecessarily performing a lot of work without sleeping. This can slow down reclaim code if flushing stats is taking too long, but there is already multiple cond_resched()'s in reclaim code. Signed-off-by: Yosry Ahmed Acked-by: Shakeel Butt Acked-by: Johannes Weiner Acked-by: Michal Hocko --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index a9511ccb936f..9c1c5e8b24b8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2845,7 +2845,7 @@ static void prepare_scan_count(pg_data_t *pgdat, struct scan_control *sc) * Flush the memory cgroup stats, so that we read accurate per-memcg * lruvec stats for heuristics. */ - mem_cgroup_flush_stats_atomic(); + mem_cgroup_flush_stats(); /* * Determine the scan balance between anon and file LRUs.