Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp398203ybm; Tue, 26 May 2020 20:56:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZLItUXvzXUC5N/nk5JOlN+DQB11UFSE6G9UeYbBLBj4i9eEsGOSuBZ9a0KVPrDd4UCujh X-Received: by 2002:a17:906:703:: with SMTP id y3mr4102506ejb.61.1590551764642; Tue, 26 May 2020 20:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590551764; cv=none; d=google.com; s=arc-20160816; b=0Y5ofXY2fHIxVKZKgdadBjOy5EFN6oa88NTwKTy4BCQqQZQGbq0vCYGwHzFj5/mbLP 77pBai5sVXzFrPsJeGZM9gfnxeaAn93TBhVQfs9xEV58Pe6OrP674FWudRMD52VVewDW JxSbnDuUKN0CPhRqxKBegBN0tIVPd+ild/2ZzAi9NGtrqWMSLgFqq3ZjUcyEYHBvPAEX /TVHsNqnB/p7Zh15CfXvM0WXS041oPyZKt2Si1K0aktqJ8LLdcRuts0Zrv/tftYS3lJz 97EVhI5QT/zGahFoKMSyA7zCLCdbwXJ3hlzQqSpEgeCgUw8GfIo6vLXrO0PZXGzcmNns 4AOQ== 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:smtp-origin-cluster :cc:to:smtp-origin-hostname:from:smtp-origin-hostprefix :dkim-signature; bh=r6yFOrQH+l4NZPSwQMQNM0GAX4CW7fFhGG+KDvTrUkU=; b=V+Up/+EuIQa0+J9IastAXwl739oCXxdD2xmbivX4FdKwD06+ZRqkYeVxEopnZ0y/Ka kroKyAo1TU0KAyhJO6aRq/nlrCufa2NPZAhsPZtUjSdp8tyibyA2LiNei/zI3vGI6swm Ox6MqRs9H5OteuFcucwLxKOcoyUCO8GrJe1OKDsefWsDTGwZUEO8yci4ee3X4gUkhlwe rB9C/UAw67WtcU6fpmR0cvEm3t2DL7MmwG+m5/nXTDJUmH7SWivbsv6Y7ucHWqxZQLYm +HwckA2QmRoukn/frlPh+VuR+NPxkvd/SbiNgBgXsAP7RO+TO7oml4F074Kub5KWbubI qCIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=QPI2DdL1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc10si1116567ejb.156.2020.05.26.20.55.41; Tue, 26 May 2020 20:56:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=QPI2DdL1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391126AbgEZVm4 (ORCPT + 99 others); Tue, 26 May 2020 17:42:56 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:26242 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390816AbgEZVmr (ORCPT ); Tue, 26 May 2020 17:42:47 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04QLeigE000842 for ; Tue, 26 May 2020 14:42:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=r6yFOrQH+l4NZPSwQMQNM0GAX4CW7fFhGG+KDvTrUkU=; b=QPI2DdL1YW5KXUoCVIowRRTYrBP3ZdGtiKA2JoZ36nW9ZGawrA9XmwFuRJTX4jG8OFdq DMcKK9CYR8h1cODvqJ0JfFsXuQXo7EQA5T+lSJcHSew7ftX/457subGmLeLX85fuChMS mj1dlOst01FX/TyRkNlJ0JFk7sjnlsU2cM4= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 3171bpcyfh-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 26 May 2020 14:42:46 -0700 Received: from intmgw004.06.prn3.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:11d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 26 May 2020 14:42:43 -0700 Received: by devvm1291.vll0.facebook.com (Postfix, from userid 111017) id 3AB5B15EA7C8; Tue, 26 May 2020 14:42:33 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm1291.vll0.facebook.com To: Andrew Morton , Christoph Lameter CC: Johannes Weiner , Michal Hocko , Shakeel Butt , , Vlastimil Babka , , , Roman Gushchin Smtp-Origin-Cluster: vll0c01 Subject: [PATCH v4 01/19] mm: memcg: factor out memcg- and lruvec-level changes out of __mod_lruvec_state() Date: Tue, 26 May 2020 14:42:09 -0700 Message-ID: <20200526214227.989341-2-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200526214227.989341-1-guro@fb.com> References: <20200526214227.989341-1-guro@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-05-26_02:2020-05-26,2020-05-26 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 cotscore=-2147483648 mlxlogscore=944 bulkscore=0 phishscore=0 adultscore=0 clxscore=1015 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005260166 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To convert memcg and lruvec slab counters to bytes there must be a way to change these counters without touching node counters. Factor out __mod_memcg_lruvec_state() out of __mod_lruvec_state(). Signed-off-by: Roman Gushchin Acked-by: Johannes Weiner Reviewed-by: Vlastimil Babka --- include/linux/memcontrol.h | 17 +++++++++++++++ mm/memcontrol.c | 43 +++++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 3632d062dc11..8e5a5445db54 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -681,11 +681,23 @@ static inline unsigned long lruvec_page_state_local= (struct lruvec *lruvec, return x; } =20 +void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item= idx, + int val); void __mod_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, int val); void __mod_lruvec_slab_state(void *p, enum node_stat_item idx, int val); void mod_memcg_obj_state(void *p, int idx, int val); =20 +static inline void mod_memcg_lruvec_state(struct lruvec *lruvec, + enum node_stat_item idx, int val) +{ + unsigned long flags; + + local_irq_save(flags); + __mod_memcg_lruvec_state(lruvec, idx, val); + local_irq_restore(flags); +} + static inline void mod_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, int val) { @@ -1059,6 +1071,11 @@ static inline unsigned long lruvec_page_state_loca= l(struct lruvec *lruvec, return node_page_state(lruvec_pgdat(lruvec), idx); } =20 +static inline void __mod_memcg_lruvec_state(struct lruvec *lruvec, + enum node_stat_item idx, int val) +{ +} + static inline void __mod_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, int val) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a2b3840bd432..8faed813921f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -713,30 +713,13 @@ parent_nodeinfo(struct mem_cgroup_per_node *pn, int= nid) return mem_cgroup_nodeinfo(parent, nid); } =20 -/** - * __mod_lruvec_state - update lruvec memory statistics - * @lruvec: the lruvec - * @idx: the stat item - * @val: delta to add to the counter, can be negative - * - * The lruvec is the intersection of the NUMA node and a cgroup. This - * function updates the all three counters that are affected by a - * change of state at this level: per-node, per-cgroup, per-lruvec. - */ -void __mod_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, - int val) +void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item= idx, + int val) { - pg_data_t *pgdat =3D lruvec_pgdat(lruvec); struct mem_cgroup_per_node *pn; struct mem_cgroup *memcg; long x; =20 - /* Update node */ - __mod_node_page_state(pgdat, idx, val); - - if (mem_cgroup_disabled()) - return; - pn =3D container_of(lruvec, struct mem_cgroup_per_node, lruvec); memcg =3D pn->memcg; =20 @@ -748,6 +731,7 @@ void __mod_lruvec_state(struct lruvec *lruvec, enum n= ode_stat_item idx, =20 x =3D val + __this_cpu_read(pn->lruvec_stat_cpu->count[idx]); if (unlikely(abs(x) > MEMCG_CHARGE_BATCH)) { + pg_data_t *pgdat =3D lruvec_pgdat(lruvec); struct mem_cgroup_per_node *pi; =20 for (pi =3D pn; pi; pi =3D parent_nodeinfo(pi, pgdat->node_id)) @@ -757,6 +741,27 @@ void __mod_lruvec_state(struct lruvec *lruvec, enum = node_stat_item idx, __this_cpu_write(pn->lruvec_stat_cpu->count[idx], x); } =20 +/** + * __mod_lruvec_state - update lruvec memory statistics + * @lruvec: the lruvec + * @idx: the stat item + * @val: delta to add to the counter, can be negative + * + * The lruvec is the intersection of the NUMA node and a cgroup. This + * function updates the all three counters that are affected by a + * change of state at this level: per-node, per-cgroup, per-lruvec. + */ +void __mod_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, + int val) +{ + /* Update node */ + __mod_node_page_state(lruvec_pgdat(lruvec), idx, val); + + /* Update memcg and lruvec */ + if (!mem_cgroup_disabled()) + __mod_memcg_lruvec_state(lruvec, idx, val); +} + void __mod_lruvec_slab_state(void *p, enum node_stat_item idx, int val) { pg_data_t *pgdat =3D page_pgdat(virt_to_page(p)); --=20 2.25.4