From patchwork Thu Mar 23 04:00: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: 13184910 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 D6968C7619A for ; Thu, 23 Mar 2023 04:00:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5A946B008A; Thu, 23 Mar 2023 00:00:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0AE56B008C; Thu, 23 Mar 2023 00:00:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD2316B0092; Thu, 23 Mar 2023 00:00:56 -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 BEFAA6B008A for ; Thu, 23 Mar 2023 00:00:56 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 90105C01D6 for ; Thu, 23 Mar 2023 04:00:56 +0000 (UTC) X-FDA: 80598812112.26.ADE2A55 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf13.hostedemail.com (Postfix) with ESMTP id BE3BD20005 for ; Thu, 23 Mar 2023 04:00:54 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Hsck6MLI; spf=pass (imf13.hostedemail.com: domain of 39c4bZAoKCCoeUYXeGNSKJMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=39c4bZAoKCCoeUYXeGNSKJMUUMRK.IUSROTad-SSQbGIQ.UXM@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=1679544054; 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=GbeROioJTSRzpGZIx65CHc5YHmhlz1VRWOdmKxovUco=; b=VvkiUjU1YvOcq4woS3rUi5l7vNowkJPQu3DW+YPTb/flv5rkvcyuSynh/w8Vq8R5RrQ8D0 9ffc8r+Ve05vJjiQF8QeS+QpCXfqV5juDlp3h2OnFuLzDC0pAZhlU1awlohHptY5yLGI5p nlMQxy04YYcE/8mpqiC6IJD4PyvoUj4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Hsck6MLI; spf=pass (imf13.hostedemail.com: domain of 39c4bZAoKCCoeUYXeGNSKJMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=39c4bZAoKCCoeUYXeGNSKJMUUMRK.IUSROTad-SSQbGIQ.UXM@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679544054; a=rsa-sha256; cv=none; b=GRu3KSZ8+Y19UaVLBCrnmvaALo+YPSOaDB1Txl5dEvA5srmvhuOqH2EdsVQZE1/kpvchU7 iDW9xGP+MktJjZP2600IPfbIMnBfmx2E16q3lhmQ5Uda2TuqY42ogKt36EXevyY1SukD8m Hwv4f6wCFZW8n3mIbfFrC0Qrj4gJ+Y8= Received: by mail-yb1-f201.google.com with SMTP id i11-20020a256d0b000000b0086349255277so21517532ybc.8 for ; Wed, 22 Mar 2023 21:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679544054; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=GbeROioJTSRzpGZIx65CHc5YHmhlz1VRWOdmKxovUco=; b=Hsck6MLI0adIPASRaTY3d/eUkBNtZFq5fHTozHNB8yOtl2ZkHkJQQ4GNrxQh4iSoWz JkY9CbdFxu+ujh+Pyx1oKlS53Vj0EANz1HJ/mNRwoFFcZsbYiHuLCMd4Lx5axIZ0gB5l yaad/tHsVvn1tHU57blkHy/+dS8g9HHclDAV/QT3pdal8fCNCqCcJD9lMmCv5J074fQc TEWaFK69tR0mz3hWUAlm/mUgTwQep/HE638zK7huhLNEr0Yv6vPjLeQWwk4UQCFbwI31 KRefecpL1tiBaS/Y5Rnpmz8ntCNmT0BogLXtNGk9m7i1zmm8BH4noVNiIwwFJbgEqIWE ZH9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679544054; 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=GbeROioJTSRzpGZIx65CHc5YHmhlz1VRWOdmKxovUco=; b=hByDhs+Lz8ZMm0hY5O8NZro/FYqxaCfAWp2Qr2M2sBQbmrTxkiR1WECiKXVmgDDvLK M+Fie5qum4pMWSSMw1aAp+Ldr6jPeOpDpCPwPDc3EZUhCEcVsyN/0DGcUT9Yb11/pDjb EX8AXt2eVBC53Y8dH3/HSb2/820YSlO0YBjsUTBy/dbDNu0O1SoEhPZn3lNZa9A/iNYt 5BExArlU0NDr4iJ+pa7YjR9jS8ywKLdx92uqYsYx/iaI5NNYj2QUayRviHOsQQnlL8+x Dt3XPAjP8xLfSUTosL0I7tk/bN2je2vlxiRKRIwaMucZkTjQd/KBdQmmJnrNybvTdAd4 ytFA== X-Gm-Message-State: AAQBX9dvljcfonRIFRJxlBr48vDvHZiVGSdvfio64q2clFR46tlQnWdM YN8wuUxNaeCPtquieNQA7qAbK7qmSMZT7jLK X-Google-Smtp-Source: AKy350aHC0fJxZVNDyOM4vrsmksnjt2c5UEEiO2IoOQY1+2DycjUjKQKdK6RunG6Yd33ZztPbzyijCwEZgPQmgPG X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:1549:b0:b73:4a25:fd36 with SMTP id r9-20020a056902154900b00b734a25fd36mr1286158ybu.2.1679544053971; Wed, 22 Mar 2023 21:00:53 -0700 (PDT) Date: Thu, 23 Mar 2023 04:00:37 +0000 In-Reply-To: <20230323040037.2389095-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230323040037.2389095-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog Message-ID: <20230323040037.2389095-8-yosryahmed@google.com> Subject: [RFC PATCH 7/7] memcg: do not modify rstat tree for zero updates From: Yosry Ahmed To: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton Cc: Vasily Averin , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, Yosry Ahmed X-Stat-Signature: cza439n5tcr5cg6b8w66udmj9orhbj17 X-Rspam-User: X-Rspamd-Queue-Id: BE3BD20005 X-Rspamd-Server: rspam06 X-HE-Tag: 1679544054-380071 X-HE-Meta: U2FsdGVkX19S4pTU/G8E+BNqfDB3T5xyW4t5JdrREz4rqOySNrkufGOyjRL69VGKafmuKREaGHhOjC5KmfDDQHLB8dxbynPvofXCUcSSOEsLmYl2GGSRbZyFcB4D/QR9ky9TGlIEnMICJx43nHn6XcSWXftkchsKaMU89IHNT7y303EawPdmTNdv2bF7vC8tc8a63UjAiMlDurUpCBiBbZTixxZCPOl19rNiuPvFd4zsEZNjNzlGPLwPW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AxFH1IO+NmADDOur6l69frDGprYcPaJtDy+oMfwBPFI8+rGEJS3wP8i8Rgc1X34WEmJuOydPcknfBkPLtiBpnJRiqUizL8MwfsiC6wXFMccRucA7t6NTLABQ9C9pPnoVpvHItG/3qu45ReuzxKefX0TvtYzD1/yNAMz4xS9/QgsWvosL+1YUvLDQ+eK/uUM/2SVAJjo1bLWxu8Wgs53ulqEFP4yrBBy308ZHWSD4+mnSMXKLCPLW/akQB+zzR07SJCWvlOp37WR10TuBrvj7zrv1UG+GqKFtoGXE0/SZq27uw80Xf3P/51N+rYmVziW4X/ckzMiv2+w== 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: In some situations, we may end up calling memcg_rstat_updated() with a value of 0, which means the stat was not actually updated. An example is if we fail to reclaim any pages in shrink_folio_list(). Do not add the cgroup to the rstat updated tree in this case, to avoid unnecessarily flushing it. Signed-off-by: Yosry Ahmed --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 39a9c7a978ae..7afd29399409 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -618,6 +618,9 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val) { unsigned int x; + if (!val) + return; + cgroup_rstat_updated(memcg->css.cgroup, smp_processor_id()); x = __this_cpu_add_return(stats_updates, abs(val));