From patchwork Mon Apr 3 22:03:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13198872 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 1C50EC76196 for ; Mon, 3 Apr 2023 22:03:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70CAC6B0074; Mon, 3 Apr 2023 18:03:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BE20900002; Mon, 3 Apr 2023 18:03:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50F346B0078; Mon, 3 Apr 2023 18:03:44 -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 4240D6B0074 for ; Mon, 3 Apr 2023 18:03:44 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 208521206A4 for ; Mon, 3 Apr 2023 22:03:44 +0000 (UTC) X-FDA: 80641457568.05.9B2E335 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf09.hostedemail.com (Postfix) with ESMTP id 499BF14001F for ; Mon, 3 Apr 2023 22:03:42 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="W/ze/sAl"; spf=pass (imf09.hostedemail.com: domain of 3PU0rZAoKCKwkaedkMTYQPSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--yosryahmed.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3PU0rZAoKCKwkaedkMTYQPSaaSXQ.OaYXUZgj-YYWhMOW.adS@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=1680559422; 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=kId3QKjERA5KglVeO1VKvGvv5azlGeISt3c2gJrYgyo=; b=Nhv08jWbX/zdLd/u2k4h4vE+UcdnQsusG/aP6GWwYthXWBdfeIbkDHwuMZlXCW89ktPL2W C1HXPa5AwBpArCe3jbhLzjSx2kTaYMKH1pLEerNu/Mmor0HPdwnDpyTvif2OANI0jKcvaU pPszy10xmz9cPpvpah6qgrFAKlsdBJ0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="W/ze/sAl"; spf=pass (imf09.hostedemail.com: domain of 3PU0rZAoKCKwkaedkMTYQPSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--yosryahmed.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3PU0rZAoKCKwkaedkMTYQPSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680559422; a=rsa-sha256; cv=none; b=jLE3UrSnJpZfO+uMmGEmkL/Nz3RjMGtUnICpDLHdcDrfEzOSV5FlBg7LbWSG/s4HqEBh// uBci3zO0qf7HWsvE3cqY9SZk67YiPCCWGExez42LqkznwAufuZwLm6Twi+DBlOfyfXbpMm H9w8CKE7GDPfxWvA/1GlroaaSl0T3Lo= Received: by mail-pl1-f202.google.com with SMTP id l1-20020a170903244100b001a0468b4afcso18285116pls.12 for ; Mon, 03 Apr 2023 15:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680559421; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=kId3QKjERA5KglVeO1VKvGvv5azlGeISt3c2gJrYgyo=; b=W/ze/sAlU7O+7GhoVMA+gO+b3zK1GLSBb2wxG7cqOl+9vjmm6QdV40GnYhvFBAr6we 6QpU1r1iDXHFCTCDI3KvZCA5Fdx66xMvZLtqAf+RggvSzScbqU6Qb+D3U4BXwhb/OMA1 mj7EUoKa/2hKudyISX9IDUT5QtGjglqN6doUhxmfcL1+w5LR9gcm9RCdAs4iQ3yY+fKw 8EP2M2Ss5aeWYRlPCW8BW8qsios85nr5jm7RooCKJYkRU/xUY3Tcdg08l4PT4At3QjPp 8RJrh+/qwzB7v9VlZ60Az/txlakHCjAKDKadt2/B61f8k1qeYBs4X+ujruMC4SFwxMjN IvmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680559421; 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=kId3QKjERA5KglVeO1VKvGvv5azlGeISt3c2gJrYgyo=; b=fifin4Oj11t/em2xwE6/Fwjg9VzXwK7DA5Q89CCw86p52XSFL/OI3Y8/DHWYdtpN/c Fi9kjpuy1/rmIlFnVh+XeiNnA9llDgwVDEMzFG6nBvSudHTZyw/tYMq/uRKqeCDbAT1j KmiBJOEpPlp1TYNnCqHfnXTVBfu1uRm5EepJtlYc5reXFQfh8l52jxSD9pKE+j99OvNl UZXTkC9rqLXbjb+ORorXd9BX1G8lOZyOzml3mq99gqKj2tHq2HnmCT8gtgVfsvAayDCm hfx+SmUN/cf55C9ZB3xoX24OGRrCqFHKw0aQtO8zDtfTD9bxCUktwQXrlJUuszlWakNz u/Qg== X-Gm-Message-State: AAQBX9cNb7N14jt1ncPsWeb35RNqAuVN5NfUhxIhvRmyOM4mU5vdlIHx 3TwPOVtptoiizYWYAG1PedV2Mf4WHzpI1zO5 X-Google-Smtp-Source: AKy350bROYdy/7K8uGxBM0X/ZxH2AG6/5IpCycN9GV2HdX4MbVmRhF2WLCfVj205eUvkzCs7+3h4yAAbVuROFoGd X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a63:f307:0:b0:50c:bd0:eb8c with SMTP id l7-20020a63f307000000b0050c0bd0eb8cmr39435pgh.6.1680559421112; Mon, 03 Apr 2023 15:03:41 -0700 (PDT) Date: Mon, 3 Apr 2023 22:03:33 +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-2-yosryahmed@google.com> Subject: [PATCH mm-unstable RFC 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 Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed X-Rspamd-Queue-Id: 499BF14001F X-Stat-Signature: cxjmhjxbjrjsau86zhe6uzmjsi91sg4o X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1680559422-178362 X-HE-Meta: U2FsdGVkX1/S42yh7NrlZHPXAsiDAQb5mpBOsAFX8GVL8Zc5dxCFUg/M35g7Qq7Tw6CD2cQku7kfP4eY9nccxydIYhZPhsVql03KxW1MS910L26jIZhAvFpC96SrP7OhAVjZqAyaMcGfCZEYQRPDijbDlLSTpuDZbbIWJY0ZYbyZOBa5t9hdZ2BcGmw8nZ/aQ3D6eCJWPLXs/b4+nXpg0hhATApIihmrPzIThl3k+CUjhHb2fPgjwDJBPCB9qW/d5h1QsHui6Ug9PiwK5yby2vO+VDxdhE/569laVgb2Tiz3B7vekoVX2am7Xuaiw9CQv0G1fdUUR3W9rcZWbk5NnMCeQX8ceJv/Z81rGUlDj50M68RzeN/BIfBk2/PAYBqkS3sQyLt5olHQXUVaz4nEyyJPq30hOY+innZieuqZ7xr3OJOCQx8r0zzpiTe2nyah/MWcEdiHYeEtZbmgf94LMoQPVkjUPQ0O5UyJvjjmUA2mSJtC8Gmlr3GjevXZDK/72yuTQeTaEX14x2DAoQ0mGJ/DiwtEe9mwK93/fXH6gpyavxjSf7qqPvKLUjjjkN3eLsurhudbHjhdmgm2uUPdvLy6RHppqUvXnJ0hhMSzhv1dPBtSfh1lZLQDd3HXUXQ7qEokWrFMNxh7SHp4TiPWlJeUU5VfFNKL2u/F2gUITVYxvS8qies3C5ExPDDBVPC02r6Ztz8k3aj/izezbgWbVMrL6LZTmsfr/z0GvsOBI2QxZEHS4NocxvKkkHvJn/4X/KlKnyiTeGzCx8ZSTd8VMAfRvMac2pucb1f+DE1dVQa4Sge/VWJ4czOl/SxFW9dzD/5SPXBsWmSfoxg9agCR/G1KYNykS95MCteNbbCqOJlccRe9yyAr+ddPLypF/nEJsDLsb6Xt1GVk6TXuI/E2Meg917D3KcDCzUuLjyL1PFECema321sLSlPaWyx3JlNZczaJdQf0TqOuOcW8iEY HP9bslEx e35kwDPbTGVt2/lRjeDobsOoMdpnFDJC3v2rD8fAKfltDHufmp7ikTgJkBPdN61u0Wb2ThKPMqMf3TGLkqVqceGj7ug+e+0AoRHm+78esWn8MiiyvTHmP03tGB80F6YJCj1iRJ3OOWL1PvPbAan5DWU58V7mGRUC0kNriplAYt4vReDxQjBM3u6WAAseSDPs7JROi6oYt0Grtrzyq4aGPaV9qbYbwX3XEJuXFcELOFmRc85TZrerPwjjInjZnf58UwJpOAcS1ka1+KrnGoKYvyJ+Oum83pUj7xDRr4rBigZrQ+1lt31xhiGIAsCmTUkcOnnaOALQat1B7fKDe2PI7QnfEu5XU40dG+Htc152t9Ay8w/rGF5BauxejyK82dJ8ls5lxu3qpS32z+8Einl9qXOGPx4JZ4RsQr134+DTpV+3rp5A+sgSWdmI7iS0Va9o69w6nCn+gOUlPCF7b9/GZmTOMDFugtjDWXUEdwI2pbCpZ6iDjzPJ6TnmGblF1MqtlRTdfpmy53woNeafWk/e/up8zglYfVvhIAWth3KmJaHS4WzSYcrw7VFDpixwwi9HkhZkdfC3Qegp/WCVMJo8qTvsZ1OfOkRF5PYENgUCcJh9lfHqKgUSNy7hI4egUqpFBB+W6x26snfzbxTzJEtDFd2OUv8VqRQOxpaAXRin6F0+aN6hz8vszVD01fiuJWZneAm4QdFZAh7AGzQ4= 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 make the rstat flush atomically. On systems with a lot of cpus/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) 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 the 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 --- 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 195dc23e0d831..012357bc8daa3 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2021,7 +2021,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 @@ -2046,6 +2045,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 @@ -2075,13 +2077,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 @@ -2093,9 +2101,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 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+4wNi7anm8EQ2RxqjDdwiVnK5GhfoTJdgCUxgLIPQOO5sc6yhCh5cW62UGWmdfeiAk9S+TXSZKTlfUrw8zL8J19cQVva4AhabE4R8WczPJnGToMkcuwXyXlVknCzAFjLLh1a4qigNYU2/H6oEh7pMNxaE17OUqQZVz3wvlXZsMDl4al0WgH8EUW5KrcFjqrc7c8zgSVGXw/aj6kb6sxGLmPkAsh0+n7W0/rfAyhj4Z73FQwoQC3vuM8Xi93IIv4hW40FPNcJ6oTUrIUBgSV/C/73mANPdPWWNM9XlXThqP1RBLhKq5dYX27FkcE2ErGA/DiXX7QNXuUXk+rU4pM1YDUXuUXBgWy2rO6f0mzQmfzM97+xfP/qWe1wTFZcSA5avGdd2YNMIWY2o9WSJhUzHYCAicgZv2x1PZdNhR1MLRIvz7qKMaHvyZ/rYkY4UMcJTMGlDvamIG0Zt8ZB9FrQgg3U+r+k4hzATEwGs2Hyc3Jk+NYF3MI7dejcwKddCEofc5+myK7l7BYPZZ5dZL8ZoVs7pJ/4/rrB4qb9TMOTNpV276KNb1Z61NBgfe0BN8m5/nWdjRxuXhqyd7uVELXM0djSi/VUVQACWP97doj+vg4kb32AnsMGJ6u+6+KPpF6ipv22HdDr+supXhbJ+2S8vTnFqXmbTrgH79uxvn4nyLTHH+a2vFxhSXGSE/aDjWJVjmvZWwqCAnevd/RD4E8URIEXR/3sNTxdOgzuE+Td35PmbMPuhlR697XV0oGKa3E6UWRKv55FX CWXRESlh N7dfE2wHM+QGbIJLiQtOdv+R811l22C0C6OIAcA7pryRvtK1limNDNKN6Q/3wuFXuXdFkoIBcD1qETdau95MU6Zc/RfPCfWeP1TG//AEoc3zyLFTxjdXT/uwDufvcfCBjOa5cl7RYXHhm0aI0TeAWWxhT8W7sDb3i6ybmVuRZ9yrOm+yi5RfE5N/+d4R6rELfpr3bZouTzXu1iImwTJI0shING/Yd48h2+zSzXsU4w+yZc9zXrsgDtOvzvk6S+nnSKE8flGTyLMZbAUE28zm8hfgG6blJnbLB2Jre7JyPJgjfO/S2hzlbPL2NDGIEo0oCaSNt0i+02PRjHaM0JwadVtTmCD4Vw0KnK+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); From patchwork Mon Apr 3 22:03:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13198874 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 6C1D0C77B70 for ; Mon, 3 Apr 2023 22:03:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07D0A900004; Mon, 3 Apr 2023 18:03:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 005D1900002; Mon, 3 Apr 2023 18:03:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9AEF900004; Mon, 3 Apr 2023 18:03:47 -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 C8981900002 for ; Mon, 3 Apr 2023 18:03:47 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9BAD41A06F8 for ; Mon, 3 Apr 2023 22:03:47 +0000 (UTC) X-FDA: 80641457694.19.D5E5127 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf18.hostedemail.com (Postfix) with ESMTP id C959F1C001A for ; Mon, 3 Apr 2023 22:03:45 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=QZZrc3A9; spf=pass (imf18.hostedemail.com: domain of 3QE0rZAoKCK8ndhgnPWbTSVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--yosryahmed.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3QE0rZAoKCK8ndhgnPWbTSVddVaT.RdbaXcjm-bbZkPRZ.dgV@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=1680559425; 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=kF9j9xhVt+HAtgUv/sW6MmUPAVRA6NHiHn3mXAJRGAA=; b=GFnwHpeRhyGwOEEgnsz1VcaWfqY+JJc77hH0WVneuEyNpIBFylwbJQ3hWkmIfUSxki7M43 DD6A8e9WrSplsAAKiF8gIy64IjTSs8mia8ab2m3vJzWqA3SW11ILNcgnCYOFk3rlEFECnj 36uJBUbFRRljA6PpzBn+h2wRcCnY/Ng= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=QZZrc3A9; spf=pass (imf18.hostedemail.com: domain of 3QE0rZAoKCK8ndhgnPWbTSVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--yosryahmed.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3QE0rZAoKCK8ndhgnPWbTSVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680559425; a=rsa-sha256; cv=none; b=tXUbO2flnBWWWF5FMlnpaEtss/gnBLmIX7mFL1by2Ir0gPbIwuYMAuRv5725a5aDkgLcMu N/Sq+xoWYTgpjH1bl4Fr2uz2iB+ohmDtpRXoHJj36rUO0VNrDEL5BEFGSIZLSQVE46gM7z /3CI6k03+hTKeHe+ddcWpEUnxri3GnA= Received: by mail-pf1-f201.google.com with SMTP id y186-20020a62cec3000000b00627df3d6ec4so13957974pfg.12 for ; Mon, 03 Apr 2023 15:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680559424; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=kF9j9xhVt+HAtgUv/sW6MmUPAVRA6NHiHn3mXAJRGAA=; b=QZZrc3A9Ala3Y1fUrUeH9aHQEpEHIm56zSkCNE0A0d2CfnkVvyEn83miymwgAbVi5v 9d0zVCVjgbHefP1pXO+Nwo1Ul1PtmNl2tpG2LpPChio/My4WZElf1o1jchSNOgvJZUsW WbV5lrmHTcH3fAqoJ7gZenJSRA3/dWbn3kNYUTeryGOWXdDf83/N+i1IFVKcpHglHDCj nH4nWeMmhgItD/X0NlX5brqxxgrkgNj//KowEl9SOf+dOa58iks3E9glke7V87blHVFo T2x7kiC5rzRzeUUzMZ/tXlij1MqA5Wi+XXZnHplS+57XrL+yaVLwig14jPX/om3gIc+M IAag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680559424; 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=kF9j9xhVt+HAtgUv/sW6MmUPAVRA6NHiHn3mXAJRGAA=; b=fKYs7SFPHUnNi0iBPyOQ89yFR5odANzUvIQ4QhwjYhHtF4fW8VnDVhd4IzEFj7MBFz COfW7vRbZKPZMFlb6L858VmY6w3t17rU4RFGTeZmvtmkBkLKNVlbwnE2RWae5Grp3IGv MCdTroLGSeotdrgXlHdcTkm3MOGGoW4uwLvBlGUn/8NBHewHW7wgB542ElBteYeUb8tf 4FkV2LYQeKAsK3Zgin91QNruxKblyWLaqhXC7mqdS1BJ5lNkZ7znh8YDBnpQJor4pLVi UxVAdYtmXuGU44uiYsjfP02PTiy6W9kTHYZrZaZBq/5DV1MOG5j8hsl670mkJSweE0lo ArpA== X-Gm-Message-State: AAQBX9eUrHrVWked9itI4gnNRsGMJPhirTcUPHKzhQWYpap6Jy9L5LhM VEs1J1EEf55SyJYuKtd7ZMIwXghNnPt1KZzi X-Google-Smtp-Source: AKy350Y61C08ugQDQ0T+NdoZquMxt4ZL2sOiJByhoRsOjzxwb2aWtKxGtikw0lJtgE93Bg+tt+KjbLE8KoMgZHnh X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a63:2301:0:b0:503:91ff:8dd8 with SMTP id j1-20020a632301000000b0050391ff8dd8mr27700pgj.4.1680559424700; Mon, 03 Apr 2023 15:03:44 -0700 (PDT) Date: Mon, 3 Apr 2023 22:03:35 +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-4-yosryahmed@google.com> Subject: [PATCH mm-unstable RFC 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 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: rspam03 X-Stat-Signature: 7s5f1t6erwd11ji5shybkui8gay9hjud X-Rspamd-Queue-Id: C959F1C001A X-HE-Tag: 1680559425-117063 X-HE-Meta: U2FsdGVkX19M2qf3U+Gb7nYEU/HMat9u2LL1LXzrzJogIXHhvi8yMtXN3pPSv7ovIcdG77lw4QWkjhCWJwWSLPEp+haVmMRYZdBEVe9CVcDLJ6zgzSgjdtciTns8zAvnl9FawN2GDu1pNjhgthykd0YBz6KyzbYssSJX0F/VN5vlhyEZ+bxVhlL+2OV5tfHlWGWqGzpy9uk5N7T7waE0SgIpotp2qXpsLh5BYv8FVlAWgvHtuiZwAdGWpCuvMZiuoQoei0gEMagvKJwwStYGJuhdjIaZ0vNVOmkHsu7WRL8Zyw182H116ZTZdFGrjeynqOcMIA+7s9dvMl5DIY124HcMX9e2qkLSIPu3rOMcGdUTiTQsJ3FwULz+huo+Zzysv9LATtVDngsHf1l65IVIDTHcmdxXiCKWyi03juyrwcYpuj8jsrvV6S4EfWMA06E701NW4Imr2PYfT5ry/FbkyJrIC+VVmJelqh7hfc4+4AzqjFew5PjiHajfZ3Dp9UJ2Tix1tBbub5Kc1JNIQ7mmiW822Jc96KmDg4jjD6/IDk1XjYlvUj0Aq4IMW+sixTuWneUXobemI1foAIq1LDxLYD3OBEiF4R23nYHS8ztkw8jpKGHsRV1DDAHDvQN9mhZmGg8+ZafLzIb6G7LXl0rNLP67ESS2yOzBViKXKZsuX/3s0DmaFluDpEcQZalcDbX75+v66gLXnr7mznOqWOGPc6qKTcBdz0wHwM30SQeYOecKUmU2tsc1ICfwr0sgYsDGuccpDqWcMLCkhDo42pb+/e0i86XszBbwXcTQR3Jyg+K2Bndp9ev3ZI4hRzg8s5kQ8v23oa3n0jD84xCwbzs0cmqMQ6cBbNSodO5moEeA0HC4LMvshhPgTAbLMqIqsyWDRaRJnvCDYanwL242C8VHEjDAp9Dv4wsy3q2Eq2cG4oibtuDPx2D0PZH0sGCm0Km/MPvM6kLlwvNgEVe6Q3C bLFRwH9s nWfbBH44ova8rF61tpL5vHiFFAjS6g2H+XJuiib2uPt4VUpGxRH610vcP4BCDMJ/4uRPQNJsKosSRq3vtRmD0hdfR5W0sxwfC36l3ENPpropve7TSUWlOPU7iQeT1S9NGVn/TxvbYP+DFkZ9ASIhK8Iapz1Co8q0ygE45J9P//TpMy9dJx4EFRUW2ryZ2Qzlx0E5J2L4qT6FJmQd0hyykt6KDWRpLceYvhEXVRQ+9aFzM7scKqGPTiPAr3oaeqhm+ULGfFhtUqXponbP26gJ/OrW+COdWZp5QbIczyCtqoYCVOgvhCkJoMImQxJjqonLsPmesHBcmQwsZkicKmkqU9+kC94/ajYLAUXXp+xiHLcjhZFquLdhKk5UzTwvoBGy3xL9IZZesoExRhND0JR/ZJlMrreReAZpzF2u2UiBiW53BVU9HH1YjC241omLhS9EI+7y1vLC3HV85bSrejiYwj3t40fEDediincFxHK5Y1ZZQXY8766GXlllUWoNQfgAlJjzdAuylZ+XW6fHoWr1K5zpWlLU4itw9XHw51sv0TiW3oP08mN8A99X3d4rsJ8Y+14uiH4WvVzGnDZ61r6/dTJS9zAi0h2Q5EtK/Z3ofjzu/rXXa7+bDjrNvrfHJD6kyUkLIcR+PFYFy16WqFy2wsE5G4A== 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 bdd52fe9e7e4b..e7fe18c0c0ef2 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3698,27 +3698,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 Mon Apr 3 22:03:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13198875 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 3C472C76196 for ; Mon, 3 Apr 2023 22:03:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEEA1900005; Mon, 3 Apr 2023 18:03:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA0EE900002; Mon, 3 Apr 2023 18:03:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 97C61900005; Mon, 3 Apr 2023 18:03:49 -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 85149900002 for ; Mon, 3 Apr 2023 18:03:49 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 52A941A05F7 for ; Mon, 3 Apr 2023 22:03:49 +0000 (UTC) X-FDA: 80641457778.04.FE5921B Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf26.hostedemail.com (Postfix) with ESMTP id 89CE4140011 for ; Mon, 3 Apr 2023 22:03:47 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=PLSbfUpO; spf=pass (imf26.hostedemail.com: domain of 3Qk0rZAoKCLEpfjipRYdVUXffXcV.TfdcZelo-ddbmRTb.fiX@flex--yosryahmed.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3Qk0rZAoKCLEpfjipRYdVUXffXcV.TfdcZelo-ddbmRTb.fiX@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=1680559427; 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=hNJBwGVVZOmg9VOOVOlV/1s5wuc6P4CJY0BTT3hY1AM=; b=to9dChtp7oo8+f/nu86QCx08Av/+0kywlJmcyppleAdqZS3dBBIdqKUCE4/UvKmwiKYqZl A2SK8WlS4uHOPB/yibmbmSDcLbcB7yCcLZesQza0ihnNfDLzlJdOdPnGPqLpYCPTtHJONG j9/Ho+ibKWi5jTawgfbJzeqFp39f9gk= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=PLSbfUpO; spf=pass (imf26.hostedemail.com: domain of 3Qk0rZAoKCLEpfjipRYdVUXffXcV.TfdcZelo-ddbmRTb.fiX@flex--yosryahmed.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3Qk0rZAoKCLEpfjipRYdVUXffXcV.TfdcZelo-ddbmRTb.fiX@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680559427; a=rsa-sha256; cv=none; b=llZQGVaohcqKDePetL2hZ0bFHNrx8iZPgEwSSsyvkOR78VWFxEHf9TAMTSJwdYZxWmfdX5 rVtZqYftplQzioevIrWOUkqQPHg6bg4SkJY8zbtIudoPkzAK49v+FO+kYBLbvZvAhUU2Cn a165davbjdNeQYfOdISzI0/GFp3v9Ic= Received: by mail-pj1-f73.google.com with SMTP id qa18-20020a17090b4fd200b002400d8a8d1dso14796851pjb.7 for ; Mon, 03 Apr 2023 15:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680559426; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=hNJBwGVVZOmg9VOOVOlV/1s5wuc6P4CJY0BTT3hY1AM=; b=PLSbfUpOYbUqIYWD0lVUspaLdyltho/9MJ34jFGgaIu6ps/MvfYgJtvBICL0/UsCg8 Eo1bG+CpaO1W/JWBORyxWnVMwYforRdWFpLcNNnnTr6WckgWqX8cpRotu3SoW3jnNsSm PizUX3QJilPLsW/5Gft8jVYazARk9Ut3n4G+JQv0SopU/bBBAHVR6m+9um87Q19Q1oES JkmqUr13ZWZzVKrKo78OL0QtsqIHc61QjUXFxRzUrqMEuTOHPCZ7yp3LqOiDIHhK80Se /pN6/hsU4YI1MwbFb/U4Ozh2+s+tmlO9zkIjBJHts6ziq2HpcgAoxfLImivvQtFY+h9I 09eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680559426; 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=hNJBwGVVZOmg9VOOVOlV/1s5wuc6P4CJY0BTT3hY1AM=; b=B3VglrYVsG4RqHjB+++2vwIjJ0VmGJ4oDSC79qmCGFTPJHOGhvSKgBAoZWN2yj7I30 NklVHMtGj/6XGevnujY8TuyqtdEKkIVhFzlychI05uyTdRpubIGWXjlo6mBimb2FvO0y ODUyPlfMZT6p8b1947rOJHkrOXAiQdY09TXN6buNGLRRkjtXLW3+kLFukHtsqfP5fV1t Egm8K92terGzztVombyR6EyQi3NFv4OVblSs/1sAwUnHaHHZcK/svEjksIveoh0IkZyp eiqjlsZU12K/QhSsnc0/vtet1RdqrdMVjLyNVTbg9m2mHWUBUO2oXiuOUKsnwdmVhxoV m0Vw== X-Gm-Message-State: AAQBX9dBYbgs2qqcSluxn2NtyGsJoMKFem4X87vJpKfP0y9Y7CzyNeqb +XfZOH/eDwOXZkQ5ezUEvsmhTnrphkTa4vWe X-Google-Smtp-Source: AKy350YqjuJx0cPEvkhGlL8e3G8Xhx/mHcAIKY7AoMYKpy6RY5t/7e2yXmvxs0CQV10HpQGcD3F9B9OJJYiZoWXv X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a17:90b:4cce:b0:23b:5155:309f with SMTP id nd14-20020a17090b4cce00b0023b5155309fmr7558849pjb.0.1680559426408; Mon, 03 Apr 2023 15:03:46 -0700 (PDT) Date: Mon, 3 Apr 2023 22:03:36 +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-5-yosryahmed@google.com> Subject: [PATCH mm-unstable RFC 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 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: 89CE4140011 X-Stat-Signature: 98sh4z5zxkuk3awzuro61hiao4jaup3a X-HE-Tag: 1680559427-879674 X-HE-Meta: U2FsdGVkX18Vk1+2b1N6YMrHX2tlFlO/4YMBl02ht4MRtBtnxy/moc1rbLnjDAyz92IcofYNjSg+eU0wwhG9ltkxMG4JKsuLR7/U73U9whCH3VKD5BMOdOqIVwV6kLY4KqQiPS5r5491h3Q2lBIPZhYaKZ54QgSpcz59zBuWHmYedD4TLr6ThyaIhYYS1dqaUM107CYQ+r70YpX9fD+xywsIohu6LjS5lkSh4MLDKfbedvHWYokAkd0HTy5xoLllvkYnOjqDZsHeEkDhw8GX2P2dtPbvVkPLrZupkNxxhr+JdlEpOtvgI+SEg4BfZEVVD1Tgpe3fjmPCE3eSrKSQA1VEyUWTHKi6pXtIp1PqUQgXeaszZxFQHXQhz2GpuEE9wpUk2ryCS6zZJXA6Q85oSksxidQPX8GoVV1PkumS+0QXR9OWpYvvZotnS4m8G6qLXftp7WRzGQZ8vd9oxf1/rsudYp+r1RYwPgqrRcLvtK0e8eg19PqaGWjpbO9aU8dFEe0+HjLbMuD4ha9sxTM7PEqqdh6cp8iq8nkHgHdvwL7NWlt3B5dZDqtFM/u8w51DsP4p3zAoGena5Bo+gzU4WH2mv8WtqX8cZmpbQIhcsIjlgg8hFoqp3kHQb0id/BJvcypfu/fU/AYxTK9PuUEVyJLv5izWWMwNLQFuTeQpT0NVdGVA9zFJ57gVwQUHPuwQJwFUsMNrbOTZ4dIO8vZVuLXcsEALkDXoekCp46cbBr/jVQ/4v4OLSwgX7D903NiYkOC+/QqLVyGJ5Yy7DeS/exQ6cTZYUd8JU95aebI+n5X+94X6osv3kMam1cLR8xnAZHFr2g8Xm1MAoOzX5m5l4ZionA9vY9wmLO67poayPZuH94lVlsxp5U8+5YRUkbYunH0r5wosxoliiGO3uK8MuMMXqtgqXQQTzhpsrkGhzAmb6kwEIIqBn6Xem8Ql7VzbhvQ90jLNPf+wy1xY2Uo Tza6+MyE IHeEaH1fSnhg8M6D7OcjbUrZiUeN8gk+DZVg0qtOcbUbHcXks/jbtMpSzVJr1PwvtnClyndYqJ9qKQKnkkDXW6A+giokRjDGNylSsBTPFI4/O6XuvFgiKaia3Ph7k7dve5M1vtu2bAbyPutynkiEDWBNOxQaTQDF1qpxOu/pQPOiE5vqHZRjZPG2TE9DvGqwBlymYCSJqB0YT0iXC6g6MklbVfmgQQIchaomeg5WKkq2yw35T1V4g4y3NDBR7drmwrBYl9oThzLt5SVa5q4RO2OfJ9ambzH7w/fp++zLmp+9qCcTW4gUd3VV6wUfWsCaZq7GBj7ODl6ufsAgWUVFgeovTZOOWU80eXe14d5f8k0kHQSOouIJCiu9yjh/V5zOEvkMs3NgDOscz10Wl8t5gacsYKLsT5Z5OXuKjk5nWM72MTT04Iyhx8lztjfJvS4HgPX2aeZ9lHDTPt1pZQfUi59DsS5J/XF1bkZftn19acucfW8hnH2U3OUJ8G4FZYONLucq8uy0JgZ6vOuNxyDfdugev+aGqt1ZS7vt0CbQGWm6Yqno4JCo4M/yOpmV03uQZoEXPHov7iDlcumC4Do+OosxmWMDoier47cEgbRnkY80Vl5+x0fBufmPgZOya3GlwfSSG00BjeEqm1Xt9Ii4XbMmwp6vKfEtA64FdXcCingiaid/9ytPSJkOKD4t/biq8ycGo4/4mXAsddJQ= 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 222d7370134c7..00a88cf947e14 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 e7fe18c0c0ef2..33339106f1d9b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -638,7 +638,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 @@ -651,30 +651,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) @@ -689,7 +675,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 Mon Apr 3 22:03:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13198876 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 AAC40C77B62 for ; Mon, 3 Apr 2023 22:03:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB5EC900002; Mon, 3 Apr 2023 18:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C15AD280002; Mon, 3 Apr 2023 18:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A655F900006; Mon, 3 Apr 2023 18:03:51 -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 96128900002 for ; Mon, 3 Apr 2023 18:03:51 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6CBE5140BA9 for ; Mon, 3 Apr 2023 22:03:51 +0000 (UTC) X-FDA: 80641457862.01.14DFFB1 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf08.hostedemail.com (Postfix) with ESMTP id AFA47160008 for ; Mon, 3 Apr 2023 22:03:49 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kWaOfIm3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of 3RE0rZAoKCLMrhlkrTafXWZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--yosryahmed.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3RE0rZAoKCLMrhlkrTafXWZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680559429; 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=QacupsFZGNVPJSGTJC6YypXeluEyL82tnZkM1VlhIdc=; b=JB6D07oCaARr/5FBPL1xGb0KAg5TmwXQwJIn2d0haN49U6hFPjQj0VgxetN/jWc2cs1eZb t5UzAx+YLbkYwEl7YPDhJ4Hx2hForda3Dtv7dZZrUX6GYNtelE34qlctO9VZxGAom0w+7k Ea4mKeyGGngp/sBqahuTSvRyksJJSo0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kWaOfIm3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of 3RE0rZAoKCLMrhlkrTafXWZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--yosryahmed.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3RE0rZAoKCLMrhlkrTafXWZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680559429; a=rsa-sha256; cv=none; b=7zUKHmI0vwQqDcr0r4frJVaUP4VcHJmvIYkymlX0gMsxzNfOhEzpJw0bi/iMBKGgG/kHMR gnaXGiaDsEVon/DYdNeWAAOD1EDaVRr6xKzRjjR/8JknGLsipOLrnDGhZ/GE+P+Cr4E+g0 kip1BnaGye/VZWfi9CjD0+Ij4C/wtDk= Received: by mail-pl1-f202.google.com with SMTP id z16-20020a170902d55000b001a06f9b5e31so18544429plf.21 for ; Mon, 03 Apr 2023 15:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680559428; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QacupsFZGNVPJSGTJC6YypXeluEyL82tnZkM1VlhIdc=; b=kWaOfIm3ix3CjQ6P0LRgdpWoqBgJu3ykmdsz32NiUF8x9A1dmCU0K7B4JSzYOReEDZ FYgPQlT3SuWLrHKrP3wDopLbn9eVfq4lg7l4naylQ8tTZgKaGOhXPPjrkCrnIEo3mSYz lk/IOCkztnHJOg8hCDeaYralpjItb0pP1L9kf7xz8p5kouBsn/T4mHo837Hsw6EVM4fX wXifin0wFGMZCFLJ9fRpD2UTXhFCMfIx9NWguUNma600XyrmJZUcuoS1IkX3lwn5WJbF /q9yx8rYhgQBtZhs0hPFucZM0Rd23Z/nGcnjDiwXILvEaD94FJtXEZgMXINCRE/Es3tO KyGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680559428; 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=QacupsFZGNVPJSGTJC6YypXeluEyL82tnZkM1VlhIdc=; b=HoZ7/M/HR6ZsVaFIGAodT5TUW8A17rSjA9TaGlychbey3PpC/qBapt6oVVq9ZCyAkS GMdFKrh/2zmNJGirSjpngGUcMLU7HAwuruep1eyc1HQexA9hQjCeHQT9fJvQL1GJlF2t gSexCjwkS56QABN0tRZJN6TIneFlHazQhMgo+qOoVxlsHYLtWKFX4uWNin5Hf5B7/Z9a tydVkS3u2nCiTAHPmyGflX63OXc9EIo6ZgQBmsdXmsF3FogfPhIGgCcfOIFAfpFKnZX8 Bz7HqQLz0yy8i/TjXS250Agp4gntB3CpeX6Bp4dJbxQyO+7fEMmd4mKcBH/tFJYIxJQh mgeQ== X-Gm-Message-State: AAQBX9dXbe0AQ9LRvnOd97po5QAT64eZmYcCfkjyIfHDpi5pYAdLJWRp exGiRTHGIZAavJgc9nvWNogd5l4t6EyPjPua X-Google-Smtp-Source: AKy350bOmcX4bhvMcYbhTSAl8lBQ2O0deW3xZkttmpHKSB+VEjNEWJFCZZnxKvEdtC6SV8VkwoJDDIrEQNByEpas X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a63:485d:0:b0:4f2:8281:8afb with SMTP id x29-20020a63485d000000b004f282818afbmr35913pgk.4.1680559428241; Mon, 03 Apr 2023 15:03:48 -0700 (PDT) Date: Mon, 3 Apr 2023 22:03:37 +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-6-yosryahmed@google.com> Subject: [PATCH mm-unstable RFC 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 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: rspam02 X-Rspamd-Queue-Id: AFA47160008 X-Stat-Signature: bducpd4cg3jc9bbj9uqjx3539of55ojy X-HE-Tag: 1680559429-611009 X-HE-Meta: U2FsdGVkX1/Y6p2HjCCrx+k2pHyp6zI86Bej+rAHX6qGFP8nMRcp0wtoT9YLtyEG6NmRPqdEKZgB1+30kJNkTJ0eolufiKrXAOLdo1OPvqUj//+3TJfqcsaAeJ2sfm1ncVl7niF+77dp67pUkg5gVrbIC2WyRXrb0IJYAQCvk1He1uS/3E6uIV1zpInkV5QYMk1PZeXHRrK33ZsBYzzv4Vrn/YM+BJOo1rqILwryMqmUetHFfPCyF+DDPA8Tbkk3sGSWQZebEqYGQ2TrmPwpGZ+x0ikp22oAd1Eo7RYc2kam2awLrpTcDD77zZgIG/XMTDv/+pCzouAMYAAu6himTlqjyIBVYcVHJ3ktmoLgJiinbS7lED9V74FXDfd8VzgRtZkwZBkqvAbcgSoqwG3HFocoYp3Nid2FQNU0GtFBuO216BOqozifz01sN8x1OvdO/nrqTOfufqGZcXMgPwTAVbFpAeZegutJ0HpssTJ85UXbDnjLxV2JcgOWNCT6ZUkCD0BWp8MmlTzrCK9F5irpO7gwFMA46EqKWvHdXaKrqlKwSxcB+q+PqLSaNTALnd/pQFonrQ8+uMGbZZsv/9S6Fg4SQzxZULY1VxtQ5ZDy7QTr7tMrUTy7sScuqUseJlqwsIdUlAAlm6sSdHthZ5wi+/1DlMuXLKOPu2bdrx050F8stqpuuvgUO5AK9EivkNtiJErfYOk5rNCa5yDInj+u3pnYNcWtKGvK4s12qp6oMoMdTv280q3gr/yX5r2j3FPVTmiCjH+/2PUlwFKeAyD5P6ohubD6aT73rIgxi002/w7TLMo1lkoMuBxsxXYg+5y50yTqDvYk14DG0m+/+BATyknMncbvZTXVAlRQnV1Jt782jAaOiIs/qBkgiQgEBv8oC58Fx2vW8DtOnwDzIFMyPkwYpBWJiJZ6cinSQmtbEtQMR7whcJpP4uyIx2LFNdpwPABHUc0vfl52Dq0ZiQN rjPNYqTN FC2CpioLESTHrBvLQlvL6oqPNemgzMq3ZuXwDDQ3SHHs774rub6anus/Ra9bO1dA6dtznVzUFS6vjWyPOO8NHqXpwM+o5Bq+r1ZmbylAantkY1Aoend08CMSn4G7qUU90Qhz+Lja/h6D/txeH/RZoLZIm/U0o1v+JBtvCpZodJmN2eNxrYH7BSdoeLPC4Yt9bStbbkGDwvDLmAFM09YS30K3vg6wY1YVRWMEqWsrrHQTmVm7rXrzS+jih789pXA8t9P78G/TRAGbvL3Vo/kTfqfuZfn6GCfZ+2WP3o1WgZSa69x22T/HFjQuhE/2OQaIjf2lGIscAmTnYl3WcOI3exq1cc6vMtsfWFfE8HS/dlzx0e6af2OtGujeDj6tJCQh5YWU8NA/Rb8HJNu2kFrbSsb1CcOjECIYO3vLfspU6xObDp/PJCTy3ff3WgtsSlKP9EvqFiJ7kTfQE4ggn8PMmgQ+OeAQGujekDp10SeyPlkLOWgV1fIQPqiPtnxK29zd4d7r1IwewRiBXJZ9itHG6t6SrYQ2G4bjI0O7R5EVDl8YmqDGV5AIuxxs5uWCb2l5BPhQ+3Qx65nAMSqgHjeRw5w2AAH7BgnkQTQEjxhq7aZKhSffbXwsE5+eNAR0m1Cr96GYvHH5VN43G/hCCBpw24oM0KlwrLHLXtAuT4jGUmeDYLVoOKqyCzXe5bol5/2cxi6yZ2/FjIu5Icos= 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 --- 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 885f5395fcd04..567c547cf371f 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 d3252b0416b69..f9ad33f117c82 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); } /**