From patchwork Fri Apr 21 17:40:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13220541 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 E89BCC7618E for ; Fri, 21 Apr 2023 17:40:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F163F6B0075; Fri, 21 Apr 2023 13:40:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD8F36B0078; Fri, 21 Apr 2023 13:40:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2B686B007B; Fri, 21 Apr 2023 13:40:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A716F6B0075 for ; Fri, 21 Apr 2023 13:40:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6232840588 for ; Fri, 21 Apr 2023 17:40:29 +0000 (UTC) X-FDA: 80706112578.22.ED083CE Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf21.hostedemail.com (Postfix) with ESMTP id 84D451C0007 for ; Fri, 21 Apr 2023 17:40:27 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=evkdgDpS; spf=pass (imf21.hostedemail.com: domain of 3ispCZAoKCFMJ9DCJv27zy19916z.x97638FI-775Gvx5.9C1@flex--yosryahmed.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3ispCZAoKCFMJ9DCJv27zy19916z.x97638FI-775Gvx5.9C1@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=1682098827; 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=ze/kPlw8gotaEo1sJnB2fYrZx8MA/zlu9x0xYHZ+g7E=; b=NFswDiS5zaCfr8VLAyY771xYKKqpAx3oqAjfjFOhntx01Bgj42MVKZqdCpPVgeI5ToLhAJ nkNFO/ACR0kccWQheMN1vDFsJbD7QucMMnRS42czN5dCeA9ZzmZjMhlv0a2OJ0tWWRRdfK /3+yUsgfhKw/ULn9DyutK/tQyIyJrJ4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=evkdgDpS; spf=pass (imf21.hostedemail.com: domain of 3ispCZAoKCFMJ9DCJv27zy19916z.x97638FI-775Gvx5.9C1@flex--yosryahmed.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3ispCZAoKCFMJ9DCJv27zy19916z.x97638FI-775Gvx5.9C1@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682098827; a=rsa-sha256; cv=none; b=eqW/V4ChePAhmqtht6OqSZuB04cztxXX++Ok/RYPFlWZQLYKbvdcwlqyi/fCS5JbUEpSAE 7Z3owKYIXb+i7ERdheACGkUaix+nU8Usac1Chm4CaQxqTIYNYgPfzD7iIEXovsqAPSX9Jn soMMctIjLhzJGM+ZO7lj/Y3T7X6Zctk= Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2476a718feeso2197340a91.2 for ; Fri, 21 Apr 2023 10:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682098826; x=1684690826; 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=ze/kPlw8gotaEo1sJnB2fYrZx8MA/zlu9x0xYHZ+g7E=; b=evkdgDpSyqlLAXON2ZuU2lSGfLM1dQnhdPP+fmyZWeKwGNZTWFCJKPVGhM2bZZGKOC f7YfSGCo2Nf3oXwwYJmGjEDgBvFsw6i76b70QgcRaecrvTKD295qL9CqwnO4UztiMSAR wca4o1fBiZOb2DZIrqp+VDQfAwIcLci5K41MPeROy0/47HRyQgXuMC8OBwZyCxCgwh/S 8f4JUGNY1xeou8G6F0i+W3dKhEWQ3Zv+nckYooRRkUzwRcW77nDMDOwXtSb1IOOWcx0Y jIqwdtbmW/rhz4VKzZZ8k/jeg5TikDCeSv0Wmg2wr9UElKoOoUpGS9AakxlgHuAC0y31 KsJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682098826; x=1684690826; 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=ze/kPlw8gotaEo1sJnB2fYrZx8MA/zlu9x0xYHZ+g7E=; b=lXdB3cpUoL8UWXawtsNKgid8mZrU8aWJQuSm64FNL6gKRm/y3leoj1mOJnHtce/+oc e/pap6pWM6n61cF21Q7/c1LVYCViE8MdEe7C4SgnRJunTH8LeFxb7uOjMXbSiu/IK4yp AHTLYaKh2SNXZVVDf37zc18JMSSZ81AuQP03NDc8J50RtUThdENP4wGmzbV5gho4n68D 41wvbKfQUen1I5lBxXMxj9iTEGsioTblcKTTM8Zv1iEApMxSGTDtcEgI6FulbmddC5lO j9PvK9NrNBTfl1ovchXL6LJkXEPtoaTJ85mY9/yTm6BX/OGa1EWbt1IJi1dSwlVxjeYm UKQw== X-Gm-Message-State: AAQBX9ein8XYWEjbKVJzCUR3ppVRlEpq9dRUCPVnxw9VAMZCuY6vnVsM HQZT8P4zvDfTIIEml4z/BPx9YTiFEsrh/n+o X-Google-Smtp-Source: AKy350aoZj3p9w7xLo2ekZAFCbJRpr+XbYHOfgfJjD/OnpfpL06mwTgu6bL4JQHk39cy27rMag7V9/fdDGHimXJS X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a17:90a:3fcd:b0:24b:27db:3cfc with SMTP id u13-20020a17090a3fcd00b0024b27db3cfcmr1409596pjm.8.1682098826505; Fri, 21 Apr 2023 10:40:26 -0700 (PDT) Date: Fri, 21 Apr 2023 17:40:17 +0000 In-Reply-To: <20230421174020.2994750-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230421174020.2994750-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230421174020.2994750-3-yosryahmed@google.com> Subject: [PATCH v5 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 , Tejun Heo Cc: Jan Kara , Jens Axboe , " =?utf-8?q?Mich?= =?utf-8?q?al_Koutn=C3=BD?= " , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed X-Stat-Signature: jowp6ezqw68m33snsyucf37wbarn964s X-Rspam-User: X-Rspamd-Queue-Id: 84D451C0007 X-Rspamd-Server: rspam06 X-HE-Tag: 1682098827-771563 X-HE-Meta: U2FsdGVkX1/yUmoKIGnJGSdwzxqnxe/2BcJ4XRNki70S/g0QPwRRIJouZa2GktpdPLNQIlo5011gSaSEu5oCd5FNLcZ5hLS1zYVZ/uw7uggySzUzbnqk2V3wx8pS2RwvnilwqHWtw9bo16sGyEEP9ec3Rtc/UOwRdMHC46ShMzzlV/qRLnNc8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nUoX0Bc9TpVXaGmY7dTgFbB8IYzpy6g7/xu6EoYrIfvDl6ZLfMWcVaX+iLi9ln7JkT8FV5fp6syvWEzXdGntHl2PKxPkzCH1FrJtWsQ6DCGqSDEvNJC/bMl/5AGJHYMttJP4GgX12CYcEwObW6m4HGiCk8FjDq2xRNnzf9FPnwitcEyUZpTBjrSC5t96IuWANZbiB3pl/AepJ1vbCoUyoUUB1hEkr7FOHqSR8vWIHB5hb9FF7bJO6k7XitV05o8BYaGPQ3ulijhY6JSsWulhat0ytgzYZvmGLHuYeZYiumGY7y2mo/31T7C2w5ZMeCuI6I/QEf0eLNXPwevkIjd2szpzbcQ/9fvGGsHs/Zu+fy8sKUlE6ZNUEpwR9R4ywkaSvsDuYXR0+d+CPpW1zolFDA5e3DuFJ2l+Z+gEMh2fp2r02Ls2SPyx4q5jwVLO7W9GrsCnxxXsMPOU0ztBC8RXAfei1aOqrWQQMgpPLvRZ+HQ== 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 Acked-by: Tejun Heo --- mm/memcontrol.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4b27e245a055..5e79fdf8442b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4648,11 +4648,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);