Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1111746ybz; Wed, 22 Apr 2020 13:48:45 -0700 (PDT) X-Google-Smtp-Source: APiQypLkNK7HrIr6OPfLUZ8pgjWXYM7OuNCwWhofw+gW0AcnZV2QOeQTpJoKnmge7siHmihedf4T X-Received: by 2002:aa7:d1cc:: with SMTP id g12mr410463edp.84.1587588524762; Wed, 22 Apr 2020 13:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587588524; cv=none; d=google.com; s=arc-20160816; b=g7keuyDKk5cu/yNwxFejrxtNDv/HqrnV0bnj/OXiJ5LgeVVtR6775G7SlozvAWn3BP QstzEAV/dqkXgNIYf8tsneiV+7D7nttJSUmmyehQjg0SbZDaM6O6JH3XDKM+oVLNynpM XgQ3DV96h7QHNnbyzPgEl6fnAbGVueNSqFAvFQmYlWYWiMj69pf/MeImU/3vRTRJoCpe GvMGmPjnS3mZnYZikOH3tKbeEFXhTA9HXzzEcy9zuz2OGy4gIINep9MCtCaeWBDnX3rP t7pDqVICQsbVCl6Op0MPcjemu1HdCU6o0WKEy48A41ezceGgRo2MBvdnbgzQLjFqXjdV x15Q== 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=xFQhRG4otpxk4sVPdK5uAy8DxGseW6gRDe8NvSrL9+s=; b=HbmoL1t9MfXk51Sak7gLEws2FEKDQV9RWWS3pdBcFYu0qBrMzEXV9/n1WJ4G/qOvDx LYJASMq00ENmaeScDErKgdS9G2v8WRmNLHYvVX3ZXnb8DbGWAeqtX9cugohErA7N2mvA 0UFMihj3rY6i7PvpAi+UaZol9lFS9heaYwO5dGu8MqDLmKv/083Sg9bG+xjd6p9nc78X kgTf22katMkuXE9FQv7cEOWRo63bgZqRj80nAhZyL/gsl0GaJRkJzmFWoildVIlo8iZf EAYwyp5r9cty94P1gRE5XcJmxZ+FZ6GLBTRkmtA2PuAcE1SDpciN/RAgxc7GPaUFRoCW P+pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=dIjQmjN4; 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 i17si148748edu.511.2020.04.22.13.48.22; Wed, 22 Apr 2020 13:48:44 -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=dIjQmjN4; 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 S1726475AbgDVUrZ (ORCPT + 99 others); Wed, 22 Apr 2020 16:47:25 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:36578 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725779AbgDVUrW (ORCPT ); Wed, 22 Apr 2020 16:47:22 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.42/8.16.0.42) with SMTP id 03MKinBc002576 for ; Wed, 22 Apr 2020 13:47:22 -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=xFQhRG4otpxk4sVPdK5uAy8DxGseW6gRDe8NvSrL9+s=; b=dIjQmjN4MKE0fQm3HsNDkgsfO3nPRmoNwFwjl4gzOrdiowoRqcZvn/2lIlTMlUdewW4J TD3ZsU7GDyjDauCleu44SruD0eBK74FDsc5dHWzl3wQ1NscxKZxt/3FFym9hc+n3/qUm bBFtIrryOrRBk4GVVmI9vpk/MO4ZCPU2o20= Received: from mail.thefacebook.com ([163.114.132.120]) by m0089730.ppops.net with ESMTP id 30g36d8bhb-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 22 Apr 2020 13:47:22 -0700 Received: from intmgw003.06.prn3.facebook.com (2620:10d:c085:108::8) 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.1847.3; Wed, 22 Apr 2020 13:47:21 -0700 Received: by devvm4439.prn2.facebook.com (Postfix, from userid 111017) id BECE1229357F9; Wed, 22 Apr 2020 13:47:16 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm4439.prn2.facebook.com To: Andrew Morton CC: Johannes Weiner , Michal Hocko , , , , Roman Gushchin Smtp-Origin-Cluster: prn2c23 Subject: [PATCH v3 01/19] mm: memcg: factor out memcg- and lruvec-level changes out of __mod_lruvec_state() Date: Wed, 22 Apr 2020 13:46:50 -0700 Message-ID: <20200422204708.2176080-2-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200422204708.2176080-1-guro@fb.com> References: <20200422204708.2176080-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.138,18.0.676 definitions=2020-04-22_07:2020-04-22,2020-04-22 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 suspectscore=0 impostorscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 spamscore=0 malwarescore=0 clxscore=1015 mlxlogscore=816 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004220158 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 --- include/linux/memcontrol.h | 17 ++++++++++++++++ mm/memcontrol.c | 41 +++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index d630af1a4e17..c2eb73d89f5d 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -692,11 +692,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) { @@ -1092,6 +1104,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 44579831221a..f6ff20095105 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -713,30 +713,14 @@ 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 @@ -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.3