From patchwork Mon Apr 3 22:03:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13198873 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 83870C761AF for ; Mon, 3 Apr 2023 22:03:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9C87900003; Mon, 3 Apr 2023 18:03:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D4CDA900002; Mon, 3 Apr 2023 18:03:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C13BD900003; Mon, 3 Apr 2023 18:03:45 -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 B330E900002 for ; Mon, 3 Apr 2023 18:03:45 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8F58A1407D9 for ; Mon, 3 Apr 2023 22:03:45 +0000 (UTC) X-FDA: 80641457610.17.4FC1C7B Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf23.hostedemail.com (Postfix) with ESMTP id BEFA3140022 for ; Mon, 3 Apr 2023 22:03:43 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Qd1B7SbD; spf=pass (imf23.hostedemail.com: domain of 3Pk0rZAoKCK0lbfelNUZRQTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3Pk0rZAoKCK0lbfelNUZRQTbbTYR.PbZYVahk-ZZXiNPX.beT@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=1680559423; 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=9Hf88QAEgRalaH3f7thcio7vExcVqqDxAYa/aCaE9Jc=; b=J+WK9m/OlK3mS27TcDmzOeUWOtaUZF9wMqeM0XzQ0n47bRf33VZpEvaxXG7VR+pbsSeLga vUgrMkH4t8HHKLk1maz15HT9thVuupnaAZmuHxxNXEaOGkpmLz4vaoF5GS8t1Hb3zdI5/r xmm1blf6F0Yd7v85M1Jlx+ZhzSmXucU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Qd1B7SbD; spf=pass (imf23.hostedemail.com: domain of 3Pk0rZAoKCK0lbfelNUZRQTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3Pk0rZAoKCK0lbfelNUZRQTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680559423; a=rsa-sha256; cv=none; b=wC+G1KT0HTw/ks14ye4da6+NWHPiRFFcrsx7Hj+neRankdH7Yjowx+vlh38JZHaSlI2OeO U/cosRpGyYU/13PjJyr08T2qnE9VqKYvwTIwgsgjjaEsf8XPaGJFdwvIBAd5bhDRDpQ/sW QGz7IlXbCt0HNUMoPUzXNtS8n09AIpc= Received: by mail-yb1-f202.google.com with SMTP id k199-20020a2524d0000000b00b7f3a027e50so15032662ybk.4 for ; Mon, 03 Apr 2023 15:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680559423; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9Hf88QAEgRalaH3f7thcio7vExcVqqDxAYa/aCaE9Jc=; b=Qd1B7SbDQyGizezUFQyV/0tO/bOhj44AtZ1VKHtgOG9TbJavAnnMGZmO6zQIpqIoK7 5cj24hiW5m5RcceJDQ1KEplDfhRxIe4M8gmfj3L+NZAuLHvyis3MtYjzW6MZhBerb1QT JbsSvLpI6syO5GW80nsYNqGOYj2kCCLCJxDrHY++EHRBCuORnOG3ZRIIIY9qF02f9mrK 7QKQBjFz8zSpKFSQE5ME0/wr0Ah4Zv+Tdpoq6l9nLH2lZJPiIROIUeme5UI6HVL7rK6b PMhT9C0HP1QYba587rjt9xa6OsG8uX3e11ytS9ZKFnspyAhVnb6ce2SHS6u9IWMy0H74 szug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680559423; 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=9Hf88QAEgRalaH3f7thcio7vExcVqqDxAYa/aCaE9Jc=; b=rBx4n67T0K6P9Z2dlSp8j9/YVTXzB73i8s0BkNmFxK7PbomxPQ+Qh3DJsw7UM6HSH1 YZbJClnO07QyvfQRwAK9KOwdz1I4usO0CO4ehr6pbAwvA06+IbYnkSVTdtiwakmVjdLO wme4HsUT4v0Q9lBu2CeDXLa49tH7iXRyqEoFqLR4LzkELr2GaGSQ6Xp+XKbmU2ah6RUq vHqqnK/reqJQYJKnY+9C7dx4UPwZactnk/3gN6dg0mp7Q4VlK9haJ1Hy0On6f0AJiHv3 fH9TWSFNPUL3jj8z1NUG+Pq6npYDKHCNryMzGZ0xxIgI82ULEPeYdtebmfb6f9m0KtOh vOyg== X-Gm-Message-State: AAQBX9e7gmOpdqXizYUQL/ojoZaIpRMh89pqsFfbsTuXE5nfXjdNfekq ASEYfwlVK4VUKcNdFuEtMoobR50XyGXTMPiP X-Google-Smtp-Source: AKy350Yk7PN55oyTS/2Ex0GZoWZBdH4qO4jUdn7c2dJd2J2mTTnpo7+qXB1LBcPp06lmU8+Do/T+aXIn4r5a27Uq X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a81:b60f:0:b0:545:bade:c57e with SMTP id u15-20020a81b60f000000b00545badec57emr288637ywh.5.1680559422857; Mon, 03 Apr 2023 15:03:42 -0700 (PDT) Date: Mon, 3 Apr 2023 22:03:34 +0000 In-Reply-To: <20230403220337.443510-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230403220337.443510-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230403220337.443510-3-yosryahmed@google.com> Subject: [PATCH mm-unstable RFC 2/5] memcg: flush stats non-atomically in mem_cgroup_wb_stats() From: Yosry Ahmed To: Alexander Viro , Christian Brauner , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BEFA3140022 X-Stat-Signature: sqwfar75seuxfhmneuiqt7jc493cap51 X-HE-Tag: 1680559423-639458 X-HE-Meta: U2FsdGVkX18z1op+7oPCmiVXsa53cS/0fSQagirbqvgcopRcMJsAzVj7Vzt6JoFnLV+ibAK03xcAlMtHtvvv6YYdlfcpOYdr1M5iQi5yilLKVzOY6+lriqgzMCiVocWG4QO8ju8wPihcSMNdPhSGftruUkVO6OxaMfBYc8xjoI/mJJSHbYFgPImioO4MWX2l0xh96yFZau+4wNi7anm8EQ2RxqjDdwiVnK5GhfoTJdgCUxgLIPQOO5sc6yhCh5cW62UGW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Vw0KnK+zuAYNTyXoB8ktd0lPeyJQpJ2/jNaQDH5DifTa4rHIFKgJxWk+xxLtDcxi2dMl51TzMD7rZfO81d+fW/GFjbePpBtqZ/ICERPu166WHlqaNu1cU/sXcEngtww1L2yxhgoA4BabVgYh21hMVor4CuxYIZFeESOevV+kbZxetpL184u0LhOvqKozVO0RKaWABNGUDWDAtrXdQkLBNSIgUT27BbZjA1Bj4IjsrWOnkb3G86MCX4QHBrFWe0ypILzWzIsZeg/DOJ+WQVC8uf0LuNMxt4fWvhNi+e3IH/nre7dZrXpoGLhepJReqA3grC36vpCgX5YKHzshATXdcFzWrC1ts9MlpiFNK9UsiuXGNPfDyH8E= 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: The previous patch moved the wb_over_bg_thresh()->mem_cgroup_wb_stats() code path in wb_writeback() outside the lock section. We no longer need to flush the stats atomically. Flush the stats non-atomically. Signed-off-by: Yosry Ahmed Reviewed-by: Michal Koutný Acked-by: Shakeel Butt --- mm/memcontrol.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3d040a5fa7a35..bdd52fe9e7e4b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4637,11 +4637,7 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages, struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css); struct mem_cgroup *parent; - /* - * wb_writeback() takes a spinlock and calls - * wb_over_bg_thresh()->mem_cgroup_wb_stats(). Do not sleep. - */ - mem_cgroup_flush_stats_atomic(); + mem_cgroup_flush_stats(); *pdirty = memcg_page_state(memcg, NR_FILE_DIRTY); *pwriteback = memcg_page_state(memcg, NR_WRITEBACK);