Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp182235imj; Fri, 15 Feb 2019 21:09:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IYe2zdoSbu0UlkfJIqr2tUYt/W4z+9qIC08RJFUJOMXqPv6NmVA64c72GxhTRal+9HvRQHj X-Received: by 2002:a62:aa08:: with SMTP id e8mr578601pff.139.1550293784645; Fri, 15 Feb 2019 21:09:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550293784; cv=none; d=google.com; s=arc-20160816; b=okaWknVGJ6w0sQLt3uvbZ5JdolDZ+GLZGRG41QOkh3Bd9PB1ttraxgIf8Djej/RWPM 8NiZMQw9nNQnd06qYy/p6Kx6LqaEhmFbwpgqsSYJCa+KkP22sEEmkYc7KYTpGiAMTxp+ 2aRZJUkKBLAxrLi1Ah5Mz2ICxl9VOCM1jUEmQ627h1DsW5kQYQ75ZNaQ3djetwvhpc/d bSIf3XCz77uAc2gHY/20ClLmiMxYQfE0uXxS32L6eU0FZG9p7FQjXEu4NfcC130sFMDn vfCvJiw/ro6xx+7xGfEt+tm+SflHrci785WdeiXjLaxTP8YEM+mmvV1fZm8G3zSO/eDs sqcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m8WChnDGiJjl3dG7Qy7BcuERcz0zJgVAywmHmi4mw/w=; b=PoHGOU8aaWtLFScDm3BD+u6cSSyK74ncBxaPFUjZCOxgB9eNebfs01oLQ+DSOAQa99 8zXbVLjhmLGF/vkwPPwFEj+sn9RJiCA7md0ty3keu5DoOs618Ck8zMj20o5gNdcI5EF3 BM0OQ6LT9rf3P6bpWOFq5VfYTfXBRBXm/vBwWGT+OZLYre3KTA2mh/GSlNDqUFQYD7HB GJmMvZxXApgIjJWJ4zuCAzZO25Yf8KLu68Ow62pQzH4qlWT1snNrgkQwh3v0Ovc+KoGi 9Bwra21bkkOOdfPgHUPPc/6X0rnWeJZI1eht8CdFGW/grqWZPhHpDoGDU9TK+n1k7Tgh hrJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=UdfnkLw0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l94si7614800plb.209.2019.02.15.21.09.28; Fri, 15 Feb 2019 21:09:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=UdfnkLw0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388547AbfBOSOm (ORCPT + 99 others); Fri, 15 Feb 2019 13:14:42 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:36388 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731904AbfBOSOg (ORCPT ); Fri, 15 Feb 2019 13:14:36 -0500 Received: by mail-yb1-f195.google.com with SMTP id o129so2381416yba.3 for ; Fri, 15 Feb 2019 10:14:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m8WChnDGiJjl3dG7Qy7BcuERcz0zJgVAywmHmi4mw/w=; b=UdfnkLw0LmmTMvDdh9ElM17TqIoS3oWEjsSyoG4o6RGsaPK+fs4daWXmy0W/V7D+78 Ob2Pc5U21jjOaaMkxoMxu9tYDRhLSY2CL/sI5SGMTfBDcQdRvqtWJ1c9dngW43CxCbTv 9p4H2xQVSXhBxNYvad1mhG4sR3iDigfmHjGeDfRaTU+7XjGsyeFxL22FLqvWeI/UsRbR PTdCQwKwdVXH+yJAh1ngZAjeqZ2nUBqtDoA+jtJ5gStQMocaU9AuCbQLZYLint5d9dxj S9J7e7kCePwD2WfXXOsu+GBqZ9GNU0PIVhs0jDdsSLfjoGX15iGR18dpmrWWhqj3O5UO DL0Q== 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=m8WChnDGiJjl3dG7Qy7BcuERcz0zJgVAywmHmi4mw/w=; b=uiAv1D4Qj6kAgIUowTSuQqSgALDnF8V7RadEBzLEyaaEPBtyouWqsjhiV5LPqPPvjf Kp+xcvkYNB+DYv+YNN7/QfDm4ZTLGEDRpaobdD7twplxlR1pH1t/azoQoaA7Ym7VVTyG NMJ4bhC6XsFJHuM8TjAq89DqGqv5qIw4djh+qVcdDsUrBJoornfNQ8v0beoOKTqF6qTP yNkc1xPhCBvQ6QlBUG7b8yAyUcrA8fTOhSb72IPC8m+jDPGFueA8mhTTD1pVE56MHHF6 JWnNVoYPfg2IIBYbZisfxlSw27Bg7jaIOxQvOG4oo6cxA8N1xG1pu8ax6DUapEgKJQ6i MesA== X-Gm-Message-State: AHQUAub3Lo8Lvw/JoRRd7Wbnfq7Tyl2z/KdwlDpOJPQ42Rj25FwO9HTV 3/ZV3yFUeCeOeK30Ki9UCbzb3Q== X-Received: by 2002:a25:b287:: with SMTP id k7mr2048404ybj.9.1550254474721; Fri, 15 Feb 2019 10:14:34 -0800 (PST) Received: from localhost ([2620:10d:c091:200::4:33c1]) by smtp.gmail.com with ESMTPSA id m127sm2369379ywf.68.2019.02.15.10.14.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Feb 2019 10:14:34 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: Tejun Heo , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 3/6] mm: memcontrol: replace node summing with memcg_page_state() Date: Fri, 15 Feb 2019 13:14:22 -0500 Message-Id: <20190215181425.32624-4-hannes@cmpxchg.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190215181425.32624-1-hannes@cmpxchg.org> References: <20190215181425.32624-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of adding up the node counters, use memcg_page_state() to get the memcg state directly. This is a bit cheaper and more stream-lined. Signed-off-by: Johannes Weiner --- mm/memcontrol.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a04177f25758..4d573f4e1759 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -739,10 +739,13 @@ static unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg, unsigned int lru_mask) { unsigned long nr = 0; - int nid; + enum lru_list lru; - for_each_node_state(nid, N_MEMORY) - nr += mem_cgroup_node_nr_lru_pages(memcg, nid, lru_mask); + for_each_lru(lru) { + if (!(BIT(lru) & lru_mask)) + continue; + nr += memcg_page_state(memcg, NR_LRU_BASE + lru); + } return nr; } -- 2.20.1