Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2052688pxb; Sun, 18 Apr 2021 17:02:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwijtoPnM5/RVHM4RG9Ok7tI0WHfoM2rKweOJS1CliRJgxeUviPp5GfknKJP/Ony9v/kbqz X-Received: by 2002:aa7:cd6e:: with SMTP id ca14mr6049048edb.111.1618790559954; Sun, 18 Apr 2021 17:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618790559; cv=none; d=google.com; s=arc-20160816; b=LJ+FKBHLLsJ7N0LzW3QiTMZpo8l1KIJaLC5DLY5xcokMR1i96QHbzXs9PH6nMLrL2R S0iCYoOFW3xZbuAH5O3Zlo2s8EkEgcf6/pC9PbRm2EDnSmObF5Z3wz6NvCEl3geUBIfQ 3j6Xnawiub9xh5IdCtZFqmMdrqKFqK17vvjdQ7Okfv0wRjNvxrtlE4iAYMFp2EOdoxpM 6ADWfIZn2dkGRr4KukKK90WINafvoA8J5HBnbNW0WYpS6K6+YrvLhjtsQisNxP/ZsFw7 22i/o4ztOz1JGwVK38MeUl0A35sXZ+FkRuwNoOFYpKlBztbWlaUV4A/VXx7+51kfIBq1 FfVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=pIzly3xuH0PWUBWjBoEugIWAN5rcOKgjj+f+nKIsmUw=; b=Ns7OZ3U04hxrqfhkMzmtHLV+EJKol3bhern8Z+YI1V2nB5KMSPHinOXPoVY0684PXA tND6A62fQfPVc1iIRJOyglA2O9l+Maiav41JPydND5a9Q73Zl6hzBHCeXiy+Wvh1VvOr 6cypfeYNK0k09EKXCWDTazScG8V3/app4GZD0pVEDDB4E+eA4Fh1z2kJIV5X6rQdVloD VcrzrV5HuDkE2+fxbRLQFnIcZzbJA4/Tm6Wi8iSqFMP40gJhbZNRVYak22eEW6PzbuZ4 iHodvfarf/+BcC/9Cg7/7qfg0gp8gttjkQAPkoubUhknUujOA9diOjniVh4Oa86yMU9y Krpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MTpbOsdV; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kq15si10781981ejb.556.2021.04.18.17.02.16; Sun, 18 Apr 2021 17:02:39 -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=@redhat.com header.s=mimecast20190719 header.b=MTpbOsdV; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235680AbhDSAB1 (ORCPT + 99 others); Sun, 18 Apr 2021 20:01:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43369 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232588AbhDSAB0 (ORCPT ); Sun, 18 Apr 2021 20:01:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618790456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=pIzly3xuH0PWUBWjBoEugIWAN5rcOKgjj+f+nKIsmUw=; b=MTpbOsdVe0XIrD3eBT23Re1tP9VWKtaFYvilO/gNCVBRyJh1Ghs5VrRWLNZO1MpCsk4I/+ VUBX8sBRYQpG//HjHR6O4fnBbBUbU8PkQjZjbV3Nxlyao8ZrjTypKRpvgdM2ycbo4wqd9y zKsvDtS4Y/6DWxLcVRmhpz/o+MxyXWE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-dpTpdBMuMd-VridQre62gg-1; Sun, 18 Apr 2021 20:00:53 -0400 X-MC-Unique: dpTpdBMuMd-VridQre62gg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 779BF501F9; Mon, 19 Apr 2021 00:00:50 +0000 (UTC) Received: from llong.com (ovpn-112-235.rdu2.redhat.com [10.10.112.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id 874B25D741; Mon, 19 Apr 2021 00:00:47 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Tejun Heo , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Muchun Song , Alex Shi , Chris Down , Yafang Shao , Wei Yang , Masayoshi Mizuma , Xing Zhengjun , Matthew Wilcox , Waiman Long Subject: [PATCH v4 1/5] mm/memcg: Move mod_objcg_state() to memcontrol.c Date: Sun, 18 Apr 2021 20:00:28 -0400 Message-Id: <20210419000032.5432-2-longman@redhat.com> In-Reply-To: <20210419000032.5432-1-longman@redhat.com> References: <20210419000032.5432-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mod_objcg_state() function is moved from mm/slab.h to mm/memcontrol.c so that further optimization can be done to it in later patches without exposing unnecessary details to other mm components. Signed-off-by: Waiman Long --- mm/memcontrol.c | 13 +++++++++++++ mm/slab.h | 16 ++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e064ac0d850a..dc9032f28f2e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3150,6 +3150,19 @@ void __memcg_kmem_uncharge_page(struct page *page, int order) css_put(&memcg->css); } +void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat, + enum node_stat_item idx, int nr) +{ + struct mem_cgroup *memcg; + struct lruvec *lruvec = NULL; + + rcu_read_lock(); + memcg = obj_cgroup_memcg(objcg); + lruvec = mem_cgroup_lruvec(memcg, pgdat); + mod_memcg_lruvec_state(lruvec, idx, nr); + rcu_read_unlock(); +} + static bool consume_obj_stock(struct obj_cgroup *objcg, unsigned int nr_bytes) { struct memcg_stock_pcp *stock; diff --git a/mm/slab.h b/mm/slab.h index 076582f58f68..ae8b85875426 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -239,6 +239,8 @@ static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t fla #ifdef CONFIG_MEMCG_KMEM int memcg_alloc_page_obj_cgroups(struct page *page, struct kmem_cache *s, gfp_t gfp, bool new_page); +void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat, + enum node_stat_item idx, int nr); static inline void memcg_free_page_obj_cgroups(struct page *page) { @@ -283,20 +285,6 @@ static inline bool memcg_slab_pre_alloc_hook(struct kmem_cache *s, return true; } -static inline void mod_objcg_state(struct obj_cgroup *objcg, - struct pglist_data *pgdat, - enum node_stat_item idx, int nr) -{ - struct mem_cgroup *memcg; - struct lruvec *lruvec; - - rcu_read_lock(); - memcg = obj_cgroup_memcg(objcg); - lruvec = mem_cgroup_lruvec(memcg, pgdat); - mod_memcg_lruvec_state(lruvec, idx, nr); - rcu_read_unlock(); -} - static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s, struct obj_cgroup *objcg, gfp_t flags, size_t size, -- 2.18.1