From patchwork Fri Apr 21 17:40:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13220540 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 834AAC77B78 for ; Fri, 21 Apr 2023 17:40:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A5896B0074; Fri, 21 Apr 2023 13:40:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 156526B0075; 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 F14F76B0078; Fri, 21 Apr 2023 13:40:28 -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 DD4BE6B0074 for ; Fri, 21 Apr 2023 13:40:28 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AEF04AC4AF for ; Fri, 21 Apr 2023 17:40:28 +0000 (UTC) X-FDA: 80706112536.24.7CC9ABB Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf28.hostedemail.com (Postfix) with ESMTP id CF605C0007 for ; Fri, 21 Apr 2023 17:40:25 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=XiTBjh0u; spf=pass (imf28.hostedemail.com: domain of 3iMpCZAoKCFEH7BAHt05xwz77z4x.v75416DG-553Etv3.7Az@flex--yosryahmed.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3iMpCZAoKCFEH7BAHt05xwz77z4x.v75416DG-553Etv3.7Az@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=1682098825; 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=abvwWBWOn0vLHIokwPNC/tHyu1Fa1R/g8ZqTWIaeK3o=; b=WtMmjj+4e6y9XFpMlRAEAH1/JxluFHL3mc0pUNIc8tVUCIhwElp5DZ89ldYbgmsVA9gufg w18EeKKaod3lKvl/DVldFbkifKq0qCX3qEnxMTUWIPemsOAOoc13SI+5iarCjJYosGeO5L WvX+qp4uR1ngmPQdD7yPiwQkBOfrPEo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=XiTBjh0u; spf=pass (imf28.hostedemail.com: domain of 3iMpCZAoKCFEH7BAHt05xwz77z4x.v75416DG-553Etv3.7Az@flex--yosryahmed.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3iMpCZAoKCFEH7BAHt05xwz77z4x.v75416DG-553Etv3.7Az@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682098825; a=rsa-sha256; cv=none; b=aYOblge5Y6Ynb6lrVclvXgc/Y51df0/ovk+H02LFYx1DOBM5BSd2IvW8/71WOdHUbhaOk9 CAs8fOYgjnB2ylBtI3gG7wV/heJQ9VLkvpRaYLr/dMwsM3LO3gXzlxl3DJ4/+b9Hse+Fnj yj9VwFJh6jzj8dlHr5NLlh2/RqSLNH4= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2479c766e91so1391786a91.1 for ; Fri, 21 Apr 2023 10:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682098824; x=1684690824; 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=abvwWBWOn0vLHIokwPNC/tHyu1Fa1R/g8ZqTWIaeK3o=; b=XiTBjh0uy9kBhESmjZrsmo27Fd2heaOUEeGy+wI7JgY+55BFi83KpJfUElFkBAdtm2 /9Y+dOWIDQQOwVTZr/9l2zpPw4NhLuSad5LwurXNF9rM5PxMETajnAk6IdSR9itjleO5 5RCZOU6uWoQn/XlBfG6L6Ut73QqfPkSzpxRKMZq9c5dNC03EQysfXGAmQsX7vQIaMlXI wrYrPEcgEz4/6R89vEXhItTLbmEid9U911aGVkkoSTQdm4KxH3ssyAravljY6M6dDyLy P40RfGznmXP1ykBLl7M1nQBK+thu7rJX9Fwoe+MatBRuu3PDwmPEoG+B+msi8iGqptyL Fwng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682098824; x=1684690824; 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=abvwWBWOn0vLHIokwPNC/tHyu1Fa1R/g8ZqTWIaeK3o=; b=dZI6Z3mpn8bYfKhRD0wz4dHKO7CCv5BNjbFsXQPKS/5gu36A0SKV5MCT1w8rQAldJX 8pPH8NWWwaCxEH6E58W9wWcdeeYai8sUdEtBbCQCLd69wGU9mAQi0MKUAgGqReiZJ7zW 1ilQFXXjlKECQ6jl1DkHzQHTD31o2ggpMKx939IQyXJl4mX3FkPCgjBWtT+YaJMwCi9w Es8DbHYtBox4CVR5XWNhxJaeio+LNWDB6DZ+sFTHQPwhLsJQLg0T5T2Lz45iwfgDKggy NILOC+m95mWPIy04YGnZ8I1/hZcoRA/hKvgfzt35+NTDutvSBN1Q/atNGxrTv14azSYH B0Sg== X-Gm-Message-State: AAQBX9fEyMJZsEPHWpHbLq6Z0R72YyKuNxBcIw0S0sL6ZkCXpkbC3nx6 AZXcgqNajBOTG/Hl1IwQj/C8Hypdow1fljRj X-Google-Smtp-Source: AKy350YbjANQ50zXR9lpXjPZgwQ40mwqLJ7O/YqrPonNpx/xppRCva3J0ueIG/FDAbEMT7LPHpueSbGCVpFSyjJ8 X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a17:90a:290:b0:247:2677:77b with SMTP id w16-20020a17090a029000b002472677077bmr1455398pja.8.1682098824669; Fri, 21 Apr 2023 10:40:24 -0700 (PDT) Date: Fri, 21 Apr 2023 17:40:16 +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-2-yosryahmed@google.com> Subject: [PATCH v5 1/5] writeback: move wb_over_bg_thresh() call outside lock section 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CF605C0007 X-Rspam-User: X-Stat-Signature: 5ke59kbzyu1pqzn5gd8qon571my4s1fw X-HE-Tag: 1682098825-109107 X-HE-Meta: U2FsdGVkX1+dO8kOntENu0iq0ZOSVGoYa6N4qHoX/UQhl2UJN9n/fC2j0DrstCv/ixFIOPFk/dMvRHOrchMsuIDpQzFqCHmZ1DXg077+EgDrJGLUM+GE/IuID1JplLU0Cm+GD04VRORjbFlkLXUwTcKIOEfl4nLjt7CazmV++B8uYaJScwl9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izhUrqz7vJCCvR4pvmR1ejnsYWPtCrjdGkCc3iBR4iYbTjIf0W3rHncVxrDqSRj+cIhzQ4PFk7FCd9+YeBVHjq40VimBmXuWqa00AjY9yThFP+FZQjcBbXvovg/cr7Xm9BHGzbrYdS0Z/eTwIg1K5vtGj1wsRuNyjB0wV4oX98LTnB70zH2KFE+VPexNOKs41uUvYuw4lzQhIH2pZF4drkwx4lxyzOobH6zHMncCmXwXgyZnC1zzaIWLFrYhelzWhjHgSLn9LY+DjZjoqDNbzJOmhckSPyCEFfN4clZRdYxh/O9S71IDldrNlGJvwx3m+/Lt6U9cSc4cWrCYi6hSew91RnkYSXFSUgg+86ODHkUqENpJeKCP1Ps+vcqNZrQG1uql4HqjQ323fJ+L7Me3uafqb2idVrF1HAgMaxq4NOSxkrAeb290rqlJUCVUMSkXSw+h5hGayLDlEM9WsPkczj/nz/6GK600rVngHkE4tpg== 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: wb_over_bg_thresh() calls mem_cgroup_wb_stats() which invokes an rstat flush, which can be expensive on large systems. Currently, wb_writeback() calls wb_over_bg_thresh() within a lock section, so we have to do the rstat flush atomically. On systems with a lot of cpus and/or cgroups, this can cause us to disable irqs for a long time, potentially causing problems. Move the call to wb_over_bg_thresh() outside the lock section in preparation to make the rstat flush in mem_cgroup_wb_stats() non-atomic. The list_empty(&wb->work_list) check should be okay outside the lock section of wb->list_lock as it is protected by a separate lock (wb->work_lock), and wb_over_bg_thresh() doesn't seem like it is modifying any of wb->b_* lists the wb->list_lock is protecting. Also, the loop seems to be already releasing and reacquring the lock, so this refactoring looks safe. Signed-off-by: Yosry Ahmed Reviewed-by: Michal Koutný Reviewed-by: Jan Kara Acked-by: Shakeel Butt Acked-by: Tejun Heo --- fs/fs-writeback.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 1db3e3c24b43..11aa1652fb84 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2024,7 +2024,6 @@ static long wb_writeback(struct bdi_writeback *wb, struct blk_plug plug; blk_start_plug(&plug); - spin_lock(&wb->list_lock); for (;;) { /* * Stop writeback when nr_pages has been consumed @@ -2049,6 +2048,9 @@ static long wb_writeback(struct bdi_writeback *wb, if (work->for_background && !wb_over_bg_thresh(wb)) break; + + spin_lock(&wb->list_lock); + /* * Kupdate and background works are special and we want to * include all inodes that need writing. Livelock avoidance is @@ -2078,13 +2080,19 @@ static long wb_writeback(struct bdi_writeback *wb, * mean the overall work is done. So we keep looping as long * as made some progress on cleaning pages or inodes. */ - if (progress) + if (progress) { + spin_unlock(&wb->list_lock); continue; + } + /* * No more inodes for IO, bail */ - if (list_empty(&wb->b_more_io)) + if (list_empty(&wb->b_more_io)) { + spin_unlock(&wb->list_lock); break; + } + /* * Nothing written. Wait for some inode to * become available for writeback. Otherwise @@ -2096,9 +2104,7 @@ static long wb_writeback(struct bdi_writeback *wb, spin_unlock(&wb->list_lock); /* This function drops i_lock... */ inode_sleep_on_writeback(inode); - spin_lock(&wb->list_lock); } - spin_unlock(&wb->list_lock); blk_finish_plug(&plug); return nr_pages - work->nr_pages; 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/qRLnNc8531LF6dei6K2zK8b1DIjmPzV8DGmVbSNQgJ/HolIFxNaKLVi93NEGLucNB2Of80NAeTBE9gTXzQVMH0/3oXAPf7widmVH6Te6CEJl8mzM35eRtZAyqSihblIT4HU15i1efOh7nsspBQ0Hu6cJNnBLWLMvHwAisN69AoJRguD9hI4vBvlPGOJz2fxgRITw+re+8iG2NUZaOfTC9CygQGlAkHdA8CYBLKwY2pAZTH1uvZX5Mrm08IBssgjkYl6Mi24j/qYZ6W6rLFIW378t2iLR4P8oljNOwa/sK7zXDMPdUlfXgtfrVBj2AEK/RvDqvtNuvQ6SNp4GR1wy1aV8JLlkssj5JiyMVOF1YRq6o0XgflMDWnQldjOZ2m7uglkiX1lapub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EpwR9R4ywkaSvsDuYXR0+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); From patchwork Fri Apr 21 17:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13220542 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 63B00C77B76 for ; Fri, 21 Apr 2023 17:40:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59D286B0078; Fri, 21 Apr 2023 13:40:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5272A6B007B; Fri, 21 Apr 2023 13:40:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32AC36B007D; Fri, 21 Apr 2023 13:40:31 -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 1EA716B0078 for ; Fri, 21 Apr 2023 13:40:31 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AB07B1A0592 for ; Fri, 21 Apr 2023 17:40:30 +0000 (UTC) X-FDA: 80706112620.07.478146C Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf01.hostedemail.com (Postfix) with ESMTP id DD7F240010 for ; Fri, 21 Apr 2023 17:40:28 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Vz7q7Ozm; spf=pass (imf01.hostedemail.com: domain of 3jMpCZAoKCFULBFELx49103BB381.zB985AHK-997Ixz7.BE3@flex--yosryahmed.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3jMpCZAoKCFULBFELx49103BB381.zB985AHK-997Ixz7.BE3@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=1682098829; 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=ZwYNf0IQKL13Uvalja3XtUe1fz98Sj9XyCNuQ2xKGcs=; b=K2R7olR83mnEvlidqar2pmrYRelafpVnBrV7VSQ/tUQOVbV2KowaTefFd+Mknp1QCVXdi7 QBw2qv3edM6icpOVnwNNRLjrgJ8AZIeew9oZHyxqtz2Ch2gkQvxH9pb0PiY3D305Uw6QG3 bppyvr9oAf06BXfdVxqOgg+Pe8lcDRo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Vz7q7Ozm; spf=pass (imf01.hostedemail.com: domain of 3jMpCZAoKCFULBFELx49103BB381.zB985AHK-997Ixz7.BE3@flex--yosryahmed.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3jMpCZAoKCFULBFELx49103BB381.zB985AHK-997Ixz7.BE3@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682098829; a=rsa-sha256; cv=none; b=tvq93POghesvPHALJELPGWdY4K74JrPDK9qV95bBfT6xzeqX1QmHcLBqtfFO1zNHY+nral v1IGGgQjeEUvDlS07oLHcazw5cFfUAJ+HdYRInXGDylm4R8zV3xF2TUbJ7iudwu4tkBCwZ LrMJmpdsUv6I+YaddxplIxka4EYDcH0= Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1a66bd44f6dso16018335ad.0 for ; Fri, 21 Apr 2023 10:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682098828; x=1684690828; 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=ZwYNf0IQKL13Uvalja3XtUe1fz98Sj9XyCNuQ2xKGcs=; b=Vz7q7OzmTKVhjKuL1Z10tx4sjzaZzQc1RfkV5JIKDa4QF+qc7PE1nRpKj4JbTW26CL 6HWg0Bk/Qn7IeGOg2v+aAU068B55qLODSnp8tJGuESSICbp+6Gjpfa3HASvT4P/INIIX FNJAyhgiBW8P7szSQRrC+9yXtrHR4LwEf5c+uGkIF6nWGq5t81yHqYblmUSNV6/Pj4a5 x4hPCDxoK7EryyUSzUifkrvbv6JClx5/LSyTe0bPdsXuYCvvh5cuu7sfplfgaUZyWnve cPw/375qmd31nmxG3Xi1PRi7CTxei8qHjgER9ienP6JVZlSSk1rMC1yFsifBD6+eDFuk /A6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682098828; x=1684690828; 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=ZwYNf0IQKL13Uvalja3XtUe1fz98Sj9XyCNuQ2xKGcs=; b=PnQGMpwvje6SldBhzIiO9NvJ1svgwgLq65HNrOsbEM1C1inlQ2k1yvz+E601YeIxtn uyjdOVDfOBLvLCyPUAbrkeIe6AthjiQCrtdKF17NAOuiViACwrk+ZRF+p5A5ON8W+/0D 1zbIc48oW9lkuKT53ANtVgLD8AwBGYD1TY0GHrG6M8zIaGS42MVh0ISUYDuMPGU4qn+K yE2jiDVgVrD+mF2eGWM2XF3UlFs/DzpH5Tr8Nu54KcbK4AMZMXHWs0/CPrdxF4C9oJAd khfNEUNsi/wEgIAOLoL1/qmtSbSmlmqVAMYvSPH21xFYcu1NQsTrX2ankAv1fQPHH53I J9vA== X-Gm-Message-State: AAQBX9cTVxNqeXs7Xm47Oc894PK40NtZwoEZyPPOeDTyedmAOvNynprK /kmkVF/T41ofVnR2zUB0tVwluq2yQYvGqiSe X-Google-Smtp-Source: AKy350aINzx6WzxMD77WpFdXBe8LNCyI2424id24uJ5dWpjeDUwupScbzRciRo/Uc9LOO+muamaNQYT7/vZDgFTY X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a17:903:2447:b0:1a9:2c3e:b087 with SMTP id l7-20020a170903244700b001a92c3eb087mr1970101pls.0.1682098828387; Fri, 21 Apr 2023 10:40:28 -0700 (PDT) Date: Fri, 21 Apr 2023 17:40:18 +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-4-yosryahmed@google.com> Subject: [PATCH v5 3/5] memcg: calculate root usage from global state 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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DD7F240010 X-Stat-Signature: j1b74aaamiqm74wf8yrrrnxqi1jp4poe X-Rspam-User: X-HE-Tag: 1682098828-577801 X-HE-Meta: U2FsdGVkX19WfKJKaGLCd0IiCVyuanjHFMQ/yTYbz5pUUZWeijsRKObJZGJIEWDSWUz6sK28QC9aXx+EgZ1AldZ2gZgX7EHUkKUyusilBWFxV7ZFVJnW5oNMTkLh74ySVzYAMrntkCvoDyrxEmPjYfxJhTopVlFaMMozHhiKrQtl1hPapwPDQsSblpTc1rgxKfuuEj1/bLk5Vmw8A2ULDeldFVhxB4YUcmLgvH5DwtkvTIUFaG23hj59wbAZn2calD+VcN6fgJiDprILg12krSXt55AtQoKjcNM8KHAP91Pjvtpvc4iXNfaC5A9l/q3tKTDUwV3AdGJcdAslnL5igm4MFUmcO0Q/PVjOQQrQLEqJerJefemJg0RV77Tg7B3XwHSUUrs7IpDro/KB4vw6EOBimsTN+XjqYdURHVXFifCtkhKFnjajyMmeFUTZ9Ocsinkmzk/0JgdA3owMdxBztUCIynBbPEXRRcx+AaqUp/KGMocTrNa5z+oeiKi8XyLUYDAkWl55X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FpxMSUKM0FrDWqLbuzPFCv9e64NM0+2YHzsc+juCS2y2e3w0QmY+bQ9D5ZpF6fvzX2N5zeSPmENPH30I/A0Krs01VTUBrFFfN6NX3WUkvsjxdS 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: Currently, we approximate the root usage by adding the memcg stats for anon, file, and conditionally swap (for memsw). To read the memcg stats we need to invoke an rstat flush. rstat flushes can be expensive, they scale with the number of cpus and cgroups on the system. mem_cgroup_usage() is called by memcg_events()->mem_cgroup_threshold() with irqs disabled, so such an expensive operation with irqs disabled can cause problems. Instead, approximate the root usage from global state. This is not 100% accurate, but the root usage has always been ill-defined anyway. Signed-off-by: Yosry Ahmed Reviewed-by: Michal Koutný Acked-by: Shakeel Butt --- mm/memcontrol.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5e79fdf8442b..cb78bba5b4a4 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3699,27 +3699,13 @@ static unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap) if (mem_cgroup_is_root(memcg)) { /* - * We can reach here from irq context through: - * uncharge_batch() - * |--memcg_check_events() - * |--mem_cgroup_threshold() - * |--__mem_cgroup_threshold() - * |--mem_cgroup_usage - * - * rstat flushing is an expensive operation that should not be - * done from irq context; use stale stats in this case. - * Arguably, usage threshold events are not reliable on the root - * memcg anyway since its usage is ill-defined. - * - * Additionally, other call paths through memcg_check_events() - * disable irqs, so make sure we are flushing stats atomically. + * Approximate root's usage from global state. This isn't + * perfect, but the root usage was always an approximation. */ - if (in_task()) - mem_cgroup_flush_stats_atomic(); - val = memcg_page_state(memcg, NR_FILE_PAGES) + - memcg_page_state(memcg, NR_ANON_MAPPED); + val = global_node_page_state(NR_FILE_PAGES) + + global_node_page_state(NR_ANON_MAPPED); if (swap) - val += memcg_page_state(memcg, MEMCG_SWAP); + val += total_swap_pages - get_nr_swap_pages(); } else { if (!swap) val = page_counter_read(&memcg->memory); From patchwork Fri Apr 21 17:40:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13220543 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 2ECEEC7618E for ; Fri, 21 Apr 2023 17:40:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B42536B007B; Fri, 21 Apr 2023 13:40:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF2216B007D; Fri, 21 Apr 2023 13:40:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9944C6B007E; Fri, 21 Apr 2023 13:40:33 -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 71D896B007B for ; Fri, 21 Apr 2023 13:40:33 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 49421AC8F7 for ; Fri, 21 Apr 2023 17:40:33 +0000 (UTC) X-FDA: 80706112746.17.DB1658D Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf16.hostedemail.com (Postfix) with ESMTP id 7901D18000F for ; Fri, 21 Apr 2023 17:40:31 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=VsD7Uvvl; spf=pass (imf16.hostedemail.com: domain of 3jspCZAoKCFcNDHGNz6B325DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yosryahmed.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3jspCZAoKCFcNDHGNz6B325DD5A3.1DBA7CJM-BB9Kz19.DG5@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=1682098831; 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=2xVbU1EXT3F/5uSzRhbvwRdAhlPEIhLbnGkOO/O2kc0=; b=ikWeqgpVRxivbuF7/xcfMrodeJwet0mH5n/hxQZs9fIcOOQr/maS/zv4pLHjApKKoMVLQ7 LZ4FT2kfjUYEiRIfe7j7/KMudGDbwir6dkl6uaHeGRcU/HesdkgNcS2DL68+qYdkyeMQHs BvrKE1R3zn5qEcD1x+pmASeJttHMB2U= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=VsD7Uvvl; spf=pass (imf16.hostedemail.com: domain of 3jspCZAoKCFcNDHGNz6B325DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yosryahmed.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3jspCZAoKCFcNDHGNz6B325DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682098831; a=rsa-sha256; cv=none; b=vIxK/lPRnV5eboxb34onxnvBzv+/LBUcwCwfQYDOIcnqUDBeZ+C6ktAOv6re1Us2eoAzUR R2E6UHalvssvqtyU1qNwAUrCeo2xFFUYhEeUbFQepoE84OgFpK61kh/9Y7z4iFv1HKrdhh 1fpHV0ODOdkH9iugjzG3TvidkA4I4ws= Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-63b54d92622so1806610b3a.0 for ; Fri, 21 Apr 2023 10:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682098830; x=1684690830; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2xVbU1EXT3F/5uSzRhbvwRdAhlPEIhLbnGkOO/O2kc0=; b=VsD7UvvlQQthDrDrmrxfA+6j9bxs+fBOtiWfjPuVqKRncTMVYwHyMK7lQKw4z7d6OO 8f3IhH6XmGqVDVmFY8Cyv6LrhOYmMlAEwO97OjVKp4EfQ7GvmXRUQBA2elyZi2HdAWT8 tC3JhABpjBI1uwry+YoMsz8jQ+5FjhTBlcxyLfQuh9MawFFcJmVXlkCxxE83KRAGfIRN izUhapvRy65QRBOUgMasmNbiSkr8HJo7bR2eGmnfXoyNgGu2rdwIe+txD2JLoEKv7Tja ItjbWxT/dXoPWnPJUuXxJqFt3IyOH6lsotFnhAXC0TTQySKSNCNtSjYyYHqymn6WRMKQ FgWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682098830; x=1684690830; 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=2xVbU1EXT3F/5uSzRhbvwRdAhlPEIhLbnGkOO/O2kc0=; b=I3qjm1UVbR+mngqI0RnLv6l5dxBYMeGYx2Gb6flXeflXJAIM4Inzmnry9VoQ4h5r5z fiTkQgKT8PHK8ILMtbLSi1vDSzuCzPu64Q8qmhzA6AXEejRSs8Ujlf8SVNcws1luVgYv cs6jrOSoFs8hB96uouHnu8xby+Z7Ih/CkCeawfk4Hw96wegXgFaYE4WlaiEgYwO7R3Fy NB8emLmclye+iTGF6JQ0ONufK7ntm6J0+/f9FqPuvDHloUAX3KtOIcpZmGGhEoAwkv+v ttYZ2xpU6NLS2MOSvkoZG/0dzmqgx3gHqeVP29lgOsf2Jx5Elqn8YARbYuL4K363RzC0 3L0Q== X-Gm-Message-State: AAQBX9cEIzUsc53iioVDDcgaJhUC7M2WVv3IgGvMf4wZTXDp606J0EuF OvLw3xzuADfdcAz602O3CRSdBqpU1vU3lGvn X-Google-Smtp-Source: AKy350a5A112WsBcfM4E2oTlYZXb/Q86xb8XlqVuh7OqAqi/kCn371in9+BxtMemeJoGBiiS6Eu5MnjLStpGGXAY X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a05:6a00:2e97:b0:62d:9bea:2a0c with SMTP id fd23-20020a056a002e9700b0062d9bea2a0cmr2546450pfb.4.1682098830169; Fri, 21 Apr 2023 10:40:30 -0700 (PDT) Date: Fri, 21 Apr 2023 17:40:19 +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-5-yosryahmed@google.com> Subject: [PATCH v5 4/5] memcg: remove mem_cgroup_flush_stats_atomic() 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7901D18000F X-Rspam-User: X-Stat-Signature: zq7sunwkzwd9ot7sw8azeourbgmkeu3s X-HE-Tag: 1682098831-206951 X-HE-Meta: U2FsdGVkX19k5vg9R5VtamneIp0SFuofu8loErxtXcxcyTNtrLgkccGAhSq4ujLzouHzqEeZAIm3YhfSfCvlntwAm261oePkszEHgmYSxvaVwBS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l6Qu9Q4BP7pXxDDaKraVZAEVh6J3NTCUV4Q3OvCRfIvG97Sxnn6x5rt22oTtqqqxGtQfC/w3h9q1ezB64cWERdiLlN4CYHePCcoro8+DxWFIJURcFcVGqecj437JTVfymZLsGI4Iv5SICzxrihChu/HovyPFGBU3/nC+K7UXk5BJtxaMAx4PjO9kBXNIA1dpORyylJX0/v9S/pXS/S4jrVbYhmk9FIl9k8EDng4SDyuHPfjhpov9/kxjQ0GqHTPNDtosQCrHlm+wl6vFNjn/mW+hS6V8/nrCZGtpcFCPng8sbO+zaFIyskfwY7o5wkCV6x6/32sUphK6HvgeogORbQG7I0SKnB5Wjm2MMDeNcA5Nw5l+dzt+K8UxFpHAY5MQqlZRwqup58AvdLWFZTHzHUHy4rAu4rwZK7PqdjlRYhD3mcYkG2zHg8lBdjABxFKCUkEdLxAqfVkY4hwUAldp0OvL9Z/c9PTrtifvT0sBYWokuNpKTSnfw4A== 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: Previous patches removed all callers of mem_cgroup_flush_stats_atomic(). Remove the function and simplify the code. Signed-off-by: Yosry Ahmed Acked-by: Shakeel Butt --- include/linux/memcontrol.h | 5 ----- mm/memcontrol.c | 24 +++++------------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 222d7370134c..00a88cf947e1 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1038,7 +1038,6 @@ static inline unsigned long lruvec_page_state_local(struct lruvec *lruvec, } void mem_cgroup_flush_stats(void); -void mem_cgroup_flush_stats_atomic(void); void mem_cgroup_flush_stats_ratelimited(void); void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, @@ -1537,10 +1536,6 @@ static inline void mem_cgroup_flush_stats(void) { } -static inline void mem_cgroup_flush_stats_atomic(void) -{ -} - static inline void mem_cgroup_flush_stats_ratelimited(void) { } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index cb78bba5b4a4..eadfe371a8f2 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -639,7 +639,7 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val) } } -static void do_flush_stats(bool atomic) +static void do_flush_stats(void) { /* * We always flush the entire tree, so concurrent flushers can just @@ -652,30 +652,16 @@ static void do_flush_stats(bool atomic) WRITE_ONCE(flush_next_time, jiffies_64 + 2*FLUSH_TIME); - if (atomic) - cgroup_rstat_flush_atomic(root_mem_cgroup->css.cgroup); - else - cgroup_rstat_flush(root_mem_cgroup->css.cgroup); + cgroup_rstat_flush(root_mem_cgroup->css.cgroup); atomic_set(&stats_flush_threshold, 0); atomic_set(&stats_flush_ongoing, 0); } -static bool should_flush_stats(void) -{ - return atomic_read(&stats_flush_threshold) > num_online_cpus(); -} - void mem_cgroup_flush_stats(void) { - if (should_flush_stats()) - do_flush_stats(false); -} - -void mem_cgroup_flush_stats_atomic(void) -{ - if (should_flush_stats()) - do_flush_stats(true); + if (atomic_read(&stats_flush_threshold) > num_online_cpus()) + do_flush_stats(); } void mem_cgroup_flush_stats_ratelimited(void) @@ -690,7 +676,7 @@ static void flush_memcg_stats_dwork(struct work_struct *w) * Always flush here so that flushing in latency-sensitive paths is * as cheap as possible. */ - do_flush_stats(false); + do_flush_stats(); queue_delayed_work(system_unbound_wq, &stats_flush_dwork, FLUSH_TIME); } From patchwork Fri Apr 21 17:40:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13220544 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 5E185C77B78 for ; Fri, 21 Apr 2023 17:40:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC4B86B007D; Fri, 21 Apr 2023 13:40:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E755E6B007E; Fri, 21 Apr 2023 13:40:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3C806B0080; Fri, 21 Apr 2023 13:40:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C50D06B007D for ; Fri, 21 Apr 2023 13:40:35 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9CB23C083E for ; Fri, 21 Apr 2023 17:40:35 +0000 (UTC) X-FDA: 80706112830.30.0AED94B Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf30.hostedemail.com (Postfix) with ESMTP id D176480010 for ; Fri, 21 Apr 2023 17:40:32 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=2LLI0uS0; spf=pass (imf30.hostedemail.com: domain of 3j8pCZAoKCFgOEIHO07C436EE6B4.2ECB8DKN-CCAL02A.EH6@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3j8pCZAoKCFgOEIHO07C436EE6B4.2ECB8DKN-CCAL02A.EH6@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=1682098832; 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=xEOFJLcgICBTmNTLnyQD1ooBVf7w9cMBHK4zBwAxhps=; b=m4zJqlRCOaxwoFXrSVZTMwTtJP2L7UjMkuzuKI88o23rP/kvVf2tjDUzIbLvHo6q7KiwD+ eDleM5ifAaT5wtEZ8ujImfZPzuaZ/h/wcQPZkSe/J7LvTzFFufU0vjUaX8yDGaTuS4qskv G1j7o6Eg/OJZQJCu3GVEbWLAIQzLXxg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682098832; a=rsa-sha256; cv=none; b=dCGM3KqgVnLFAZoTC7s232bR4Uc4nYA8+nyQmtxJ895i9bW6I29lYoP41QTKB1+hLj6wtJ J3qLXjdr1MZOcHGt7CUuDRGkABxj5wlcWwff8NYmyG27aqVDGvDZjTxhvIpzR4Nl3ucZZH eJ/v5NQoQHHX022OXUsOxS4Rh8e1RlU= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=2LLI0uS0; spf=pass (imf30.hostedemail.com: domain of 3j8pCZAoKCFgOEIHO07C436EE6B4.2ECB8DKN-CCAL02A.EH6@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3j8pCZAoKCFgOEIHO07C436EE6B4.2ECB8DKN-CCAL02A.EH6@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-b8f53c7683fso3340255276.0 for ; Fri, 21 Apr 2023 10:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682098832; x=1684690832; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xEOFJLcgICBTmNTLnyQD1ooBVf7w9cMBHK4zBwAxhps=; b=2LLI0uS0HCGgUG+To5FG73zbxk+tuzk5tTcOBZNGKwnVbYk9yq2r0zkyTl0MD4wfQ3 kKiggVfa7NNclULg8NuxAqHV3zYnq7LZjfMrcVD62yChQCNHWbk54zVsBhxomTb0t0SN +XgJr7wul3fQD2JopF/MZfktxPtuUWKER8IL9ZU+RSEl7sW66jFXxgj6K5ErZztO7Nce l4ZWAyWNanyDDUgKfIgOcWOkpHNwJKJvYyr6/84gH8i9GqoBVPKeVaSusHPk+GdeSMBt A9hidHBqS6YCIVpadKtHiQ8uYxCY8mC3l7iI3bjfr9izY/KQoToKFIDt3lP79eIF321D fMOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682098832; x=1684690832; 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=xEOFJLcgICBTmNTLnyQD1ooBVf7w9cMBHK4zBwAxhps=; b=BkJTHhr7oyBJWEAWEV/okDj8qjwSCQbnIGkut/zmbu2/hMqqg1dCghew8MCPM5oesb Z3dXcUO7p58sdfOYWvmLkmJM0mlsfA/eTuug9CkAUiXWGOUbp/oFSf+vzQ7RWh8vC9JJ OxkPUTaSq2JSGhfv6UiHlUaJkGYFc6//DOnqFYlAApKbq0UAnw9Q8E1JrDydOo4p3f8G dH+x++JzKtF8OVbdL1N61K6/uw03WYnJ4p5Me0zXmfFCcAgzx1k7aFIsV3lo/9nFSW3F VEF3vKj3Ujr1Rrs1O+3VQRQS4w8Pc6Rmi9N144kewT8+i5vjVCIdinV8+13IjIbDug2h eoWQ== X-Gm-Message-State: AAQBX9fUFCbdJ+Hly0Mi07KQR6QQJEXyfXZHPC4RLfIMWBp5tnwpHSqp 4FjmxDP/8BqfLPc2dUhJJiv+xfOSUD2ulMQg X-Google-Smtp-Source: AKy350ZZ8ts19Uuwp1KvgVZn+d+WSE2zsbcOTm9kgrCL3PJuuy6na6YJxn3jgGZppB+bAg1Vc1I9v8GZpcBWJ5vX X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a25:bc4a:0:b0:b33:531b:3dd4 with SMTP id d10-20020a25bc4a000000b00b33531b3dd4mr1583021ybk.1.1682098831943; Fri, 21 Apr 2023 10:40:31 -0700 (PDT) Date: Fri, 21 Apr 2023 17:40:20 +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-6-yosryahmed@google.com> Subject: [PATCH v5 5/5] cgroup: remove cgroup_rstat_flush_atomic() 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-Rspam-User: X-Rspamd-Queue-Id: D176480010 X-Rspamd-Server: rspam09 X-Stat-Signature: 7uzri6aybd6mruj7n11zuuctuegr7kfi X-HE-Tag: 1682098832-625164 X-HE-Meta: U2FsdGVkX1+cv0Ru65rP0tgoCKjBvld8+HSCq5VyEGRm17t0t59+oQ0NSzKcZDkVKMs2mR/rN0RQ9feU7Vn2xXTzM2CFORmMqNrlThQZboG/ugqHu1HV8/4YyINQCD3qKWbHvPj/lDhN4Z6xowvRhYWrpsA+nrv7XGUWtlI4DMPIZGCtiaWTIj/ejcxmOzXPsD3rVkBf4SWUGm8hMTUTAv3W3/mJSmXAdKziQbUcNYEvjzGknqZ0qwuhY3N4De4/tb8NCAXoEje5Ud4Re6KlAaAmKcFpVYo008orzVm2NBopN9ctMPu0sTRw0kNzG71HZOxxqpXaecHozNvgBjhZhognVUDLZBTJqH8ZMFev4WbAmY2yCHO/mJ06k76Fza+6gOksnxsm+DoQVJcJIQHhzI1s5ScqhWZDOAn6iqgahTP7DMbRWuWvSKI6IS7eAIEc9HtNaVf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Jgcz7mu0kx5sUqzL3jyvhbnAZ12txBkrYvnr0HNETK70zPeUZH9oZLcDHJWe3U4aXFkB29zIaOo0hC3Q8OdeI+wZwVXZf6c3BQ0OZs7efVQfU8g8F7P79R0st3HwihFkQ3so47uQ== 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: Previous patches removed the only caller of cgroup_rstat_flush_atomic(). Remove the function and simplify the code. Signed-off-by: Yosry Ahmed Acked-by: Shakeel Butt Acked-by: Tejun Heo --- include/linux/cgroup.h | 1 - kernel/cgroup/rstat.c | 26 +++++--------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 885f5395fcd0..567c547cf371 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -692,7 +692,6 @@ static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) */ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu); void cgroup_rstat_flush(struct cgroup *cgrp); -void cgroup_rstat_flush_atomic(struct cgroup *cgrp); void cgroup_rstat_flush_hold(struct cgroup *cgrp); void cgroup_rstat_flush_release(void); diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index d3252b0416b6..f9ad33f117c8 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -171,7 +171,7 @@ __weak noinline void bpf_rstat_flush(struct cgroup *cgrp, __diag_pop(); /* see cgroup_rstat_flush() */ -static void cgroup_rstat_flush_locked(struct cgroup *cgrp, bool may_sleep) +static void cgroup_rstat_flush_locked(struct cgroup *cgrp) __releases(&cgroup_rstat_lock) __acquires(&cgroup_rstat_lock) { int cpu; @@ -207,9 +207,8 @@ static void cgroup_rstat_flush_locked(struct cgroup *cgrp, bool may_sleep) } raw_spin_unlock_irqrestore(cpu_lock, flags); - /* if @may_sleep, play nice and yield if necessary */ - if (may_sleep && (need_resched() || - spin_needbreak(&cgroup_rstat_lock))) { + /* play nice and yield if necessary */ + if (need_resched() || spin_needbreak(&cgroup_rstat_lock)) { spin_unlock_irq(&cgroup_rstat_lock); if (!cond_resched()) cpu_relax(); @@ -236,25 +235,10 @@ __bpf_kfunc void cgroup_rstat_flush(struct cgroup *cgrp) might_sleep(); spin_lock_irq(&cgroup_rstat_lock); - cgroup_rstat_flush_locked(cgrp, true); + cgroup_rstat_flush_locked(cgrp); spin_unlock_irq(&cgroup_rstat_lock); } -/** - * cgroup_rstat_flush_atomic- atomic version of cgroup_rstat_flush() - * @cgrp: target cgroup - * - * This function can be called from any context. - */ -void cgroup_rstat_flush_atomic(struct cgroup *cgrp) -{ - unsigned long flags; - - spin_lock_irqsave(&cgroup_rstat_lock, flags); - cgroup_rstat_flush_locked(cgrp, false); - spin_unlock_irqrestore(&cgroup_rstat_lock, flags); -} - /** * cgroup_rstat_flush_hold - flush stats in @cgrp's subtree and hold * @cgrp: target cgroup @@ -269,7 +253,7 @@ void cgroup_rstat_flush_hold(struct cgroup *cgrp) { might_sleep(); spin_lock_irq(&cgroup_rstat_lock); - cgroup_rstat_flush_locked(cgrp, true); + cgroup_rstat_flush_locked(cgrp); } /**