From patchwork Thu Mar 30 19:18:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13194757 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 EA24AC6FD1D for ; Thu, 30 Mar 2023 19:18:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E834B280004; Thu, 30 Mar 2023 15:18:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE4B1280001; Thu, 30 Mar 2023 15:18:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC2F6280004; Thu, 30 Mar 2023 15:18:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A9FC7280001 for ; Thu, 30 Mar 2023 15:18:19 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 705BA120B0F for ; Thu, 30 Mar 2023 19:18:19 +0000 (UTC) X-FDA: 80626525518.27.9B0E4BD Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf28.hostedemail.com (Postfix) with ESMTP id 9FDC9C0011 for ; Thu, 30 Mar 2023 19:18:17 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ltNePRXu; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 3eOAlZAoKCPcxnrqxZgldcfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--yosryahmed.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3eOAlZAoKCPcxnrqxZgldcfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680203897; 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=xcUaqJ6BFfuwa7nRJSvBlAwhhxeRf5mk+29EPOCHz/Q=; b=Lb19UDqhfDy/a8OaiYD5WpJMczSegSigAyiuTXnXBiOTVsrPOmgLwl7v3gEvem3x2328iF YIG7JCMwoIbYKiGclof8ZZJ1a15cs2ilHm9br8ZosCrSXzP+KWNElSk8bJzf8mnoX/7KXU 2pFALjh/zlEYu4lbytBtLWLbLEJFK/E= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ltNePRXu; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 3eOAlZAoKCPcxnrqxZgldcfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--yosryahmed.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3eOAlZAoKCPcxnrqxZgldcfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680203897; a=rsa-sha256; cv=none; b=2taSBBTxe2QVrj5d+dOfFEtVxcDHCjnwshjp5xI+QbeuzSZttj1cpPgm1mD7lEQNONsqEp 1VZO0GREsfV2YyUMFUy8K2MTOrFXSw91gVZj8BjLvxgf05K1k7dPIgoA0FGPT8vgLegX95 xccr/Rz8JHg2PMtIS7QJ8jVAwnz3X38= Received: by mail-pg1-f202.google.com with SMTP id s3-20020a632c03000000b0050300a8089aso5681150pgs.0 for ; Thu, 30 Mar 2023 12:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680203896; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xcUaqJ6BFfuwa7nRJSvBlAwhhxeRf5mk+29EPOCHz/Q=; b=ltNePRXuZIePvYweAMHUj9ZiAeC5qavTrptvs7HWUZy4ZQjHtls0D9eRHEg0pqkaqA 2rj8RSL+AK/a3iTAV1slsfA/XO8i87DoFdpL6M03j+wstTxD0gNLM1Eo1e2c6UpyLkfA 02M3+F6NXEWgNHJDDpxLzGC2sGDBHCNs+LO2yZgTc79ihpz2oe9Gkrj2oQSZRb8nP/pk DTjpgFJ4LNEzmr5tCkDpR0cOQrENPev1JFpwtylRIUOchlXAi5bgsrxJgKXBgxobydtr bGBrN9gUtdaDKVSRv2j9cJxRBN0C3BLXf8CobNS0sZxfbCzcE+BakwfvTig0jcnVMYxC dA2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680203896; 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=xcUaqJ6BFfuwa7nRJSvBlAwhhxeRf5mk+29EPOCHz/Q=; b=cbFew21ud2DxnzwWktWnvefOzzqZGY0G92qYiyzkN03uzseEP7ZurMckNbxth/MR8u fD6/xQxajXGxHGEJaKvJ4tzQaj03ifPHEMwJePvBdzz9+iOsuEuiajtoIqNeDFLQogeo LeRYKZMizzo80Wy4VbYtUOeo80OmQvDClIvAqVqix27j/V7RvCXuq7C3n21lzOb0et19 gJ8oDmFreFS1L/EQT1SUiv33gBrGJUpN762rtD5ZNAuZTPH13kixyPOhZ8+gqr7ZjeS/ Vh4qkqSr0LsdJLI+a5mGMJb0xFCOLnzD+Ng2Dx+UX2qNBjOdXdFEqMKrY5P2EPrjlfAh /nbQ== X-Gm-Message-State: AAQBX9fyD0AUZMF+BipWnszQfOW5ckerHo0lGkCf6Vltt7PSAu5e0vJH gG0wd0r0HQB5//dMvXGWziEUVabfF1vmhhC4 X-Google-Smtp-Source: AKy350bGhjPkePduCVIwuMcmgqQ6a76256SvlUw7LUz9ChuwvjB5lA7RHnWs+sTxxUB3GpOtDLTlb1QCGdSZixrZ X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a63:40c1:0:b0:4fd:5105:eb93 with SMTP id n184-20020a6340c1000000b004fd5105eb93mr6667473pga.3.1680203896567; Thu, 30 Mar 2023 12:18:16 -0700 (PDT) Date: Thu, 30 Mar 2023 19:18:00 +0000 In-Reply-To: <20230330191801.1967435-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230330191801.1967435-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230330191801.1967435-8-yosryahmed@google.com> Subject: [PATCH v3 7/8] 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 , Michal Hocko X-Rspamd-Queue-Id: 9FDC9C0011 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 9niu5quakad8wfmt9u611bjrxn44tqzx X-HE-Tag: 1680203897-354730 X-HE-Meta: U2FsdGVkX1/rqmq5sSmMQofwRF8lCgWiMPNGqEKN+EW+G2Losky0xxYtcOi978LwsfSHxSJuY/Bcf5qvYYwW3m72UmXiE0r+G52TbNiMog/pAtzp3hBCAAlC5AO8Mbc52Ywnqg7EEs99SPbtn3KUltA7Kk4B0BVSbWi8XVQdj0VvOyUcU4MjOXwRCiKXQNobFxk6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rqwIAcQ8i2cTCeXMXNhXiI/D9+gV6RpAfRh+j59epnU3WrkwUK+LjRgnbDnham+GOoUJbhrPE38Iy16gWQOMG2+5yRwUfoAbiOCL0m5n0S2aJELmg/gV38hYgcVNlK/Xq2TwPX82NeHVxshPa8y6ZT9lamVQxTa3mYzVzB+gTSKVLvmysMvkzE8OS799pxgHL0ZM5A50gejyVHoLujTvcCH3XAKZ5j52G/nktFb2hZy4Or00tf5oY/b8gJJF/hXb5gxzJFEeTDvBCvAD4PYGPkd2KlUcwWbSwAWpgDTXjjVm2JBSrPFC1L3aLVq1EaRcwNX+tCBZMBCZ0kZgIBgIfa+tn4dbuNmVSAv3EiT6y795Id1i5EIvGO8If4ABUfsPkeTCt8OolbcA4qqmYmgVPSdqRAq0Ck1pf11EFcJ6/4F7PZc31/mxyIV+YTJLZPui+Vq4TvXjNV7ca7xkV+9sepG6DhI+OeG5GI+IP1gDG7fdhU/V/hH6ya5KJHQ== 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. Flushing is an expensive operaiton that scales with the number of cpus and the number of cgroups in the system, so avoid doing it atomically unnecessarily. 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.