From patchwork Thu Mar 18 11:06:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12147919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1B1FC433E0 for ; Thu, 18 Mar 2021 11:08:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 26A9D6186A for ; Thu, 18 Mar 2021 11:08:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26A9D6186A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B84B36B0073; Thu, 18 Mar 2021 07:08:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5BEA6B0074; Thu, 18 Mar 2021 07:08:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A246F6B0075; Thu, 18 Mar 2021 07:08:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 886AD6B0073 for ; Thu, 18 Mar 2021 07:08:41 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4B9418249980 for ; Thu, 18 Mar 2021 11:08:41 +0000 (UTC) X-FDA: 77932722042.37.FA31CB5 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf24.hostedemail.com (Postfix) with ESMTP id D4D70A0009E0 for ; Thu, 18 Mar 2021 11:08:40 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id v8so1121032plz.10 for ; Thu, 18 Mar 2021 04:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=15LgLWnrDF9xrY/f9Qycq0PzYRn8kF+pr7olZciihDc=; b=KtCvKs+mdXNV7hiXR9LnggjmgOU3pD83nEi3aMALjUmJrnwc0VCJWtA33DzRM3ejR+ 8YCeNCjveM54mbqMhLrw7JP3SDAA/+rS/tHgOg0YaCpi3cyMXag0Dd61VsNKgMB2tvID 2b3pQVxuK/+w61Y4cHv1gZ2IyWU6+YiEJEGoFb3ThIPpM7fhElDTPdmC8c0tPj13uqN7 Cnc09uKri9MNkeloxXsBQiYNrzdIxFI+iQgNuZlIcQ/cYabVryhTdoTfUO6LWLt+9hxe LqHeBrO8JdxSUeNpZP/k85gDtzMZNOpwKW35Zg+IlzLlJg2zS4J2SFgP68SJqs4Lp1+l lemA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=15LgLWnrDF9xrY/f9Qycq0PzYRn8kF+pr7olZciihDc=; b=pQF9Ihx4bg2VpQizeup9WolnavCkU4nvoqw0QD1Ge3G3W6bT/NRC0diaRdAGN2KRno gP6Lz8q0w+OZm283ubeGxc/r8wA1p2EJ1Dhj4mMPaOqtJp63QP68tGHAkNE9ipnV7WWs go1crhlAK4tuq19c1Ni5FO71828bVlK76HRGnaVt+31s/EVTLRQjgFkfPiD4tqghtQr3 73vrNdZdApIsd+s0VxP2dEVh87nD4P1/a8HMTr2x1l7HATbH8yg4+AekCbm1rgsTb0/4 4gzBGrQmNKEj8Mx2LIQb5BOUmHEtwVgDcgUA/+yvVrCyfZqvhNyuNRBpfj/H+wVtt7Ai Ad6Q== X-Gm-Message-State: AOAM532NN2Fs5fVK/vEjmV+YinMk7ah1kvcvUHIweBnbsmV/WQAjLW9u xZd5H+4bcvxBGcNGXq6oo7WVPA== X-Google-Smtp-Source: ABdhPJwNlbzYvF2snPZSAkGAO2vl/mGld5g0amM9i3l7jk7w+k2UvRsVeWdXBYNJeKHXR8MS6D85HA== X-Received: by 2002:a17:90a:6e44:: with SMTP id s4mr3579552pjm.112.1616065720004; Thu, 18 Mar 2021 04:08:40 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.231]) by smtp.gmail.com with ESMTPSA id e21sm1779509pgv.74.2021.03.18.04.08.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Mar 2021 04:08:39 -0700 (PDT) From: Muchun Song To: guro@fb.com, hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, shakeelb@google.com, vdavydov.dev@gmail.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH v4 3/5] mm: memcontrol: change ug->dummy_page only if memcg changed Date: Thu, 18 Mar 2021 19:06:56 +0800 Message-Id: <20210318110658.60892-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210318110658.60892-1-songmuchun@bytedance.com> References: <20210318110658.60892-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Stat-Signature: t81x5go5z4n5tuhppkqyz3wd87shdesq X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D4D70A0009E0 Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail-pl1-f181.google.com; client-ip=209.85.214.181 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616065720-299741 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: Just like assignment to ug->memcg, we only need to update ug->dummy_page if memcg changed. So move it to there. This is a very small optimization. Signed-off-by: Muchun Song Acked-by: Johannes Weiner Reviewed-by: Shakeel Butt --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index fc22da9805fb..104bddf21314 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6845,6 +6845,7 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug) uncharge_gather_clear(ug); } ug->memcg = page_memcg(page); + ug->dummy_page = page; /* pairs with css_put in uncharge_batch */ css_get(&ug->memcg->css); @@ -6858,7 +6859,6 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug) else ug->pgpgout++; - ug->dummy_page = page; page->memcg_data = 0; css_put(&ug->memcg->css); }