All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qiang Yu <qiang.yu@amd.com>
To: linux-mm@kvack.org, cgroups@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tejun Heo <tj@kernel.org>,
	Christian Koenig <christian.koenig@amd.com>,
	Huang Rui <ray.huang@amd.com>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>, Kenny Ho <kenny.ho@amd.com>,
	Qiang Yu <qiang.yu@amd.com>
Subject: [PATCH RFC 2/3] mm: memcontrol: record driver memory statistics
Date: Mon, 13 Jan 2020 23:35:42 +0800	[thread overview]
Message-ID: <20200113153543.24957-3-qiang.yu@amd.com> (raw)
In-Reply-To: <20200113153543.24957-1-qiang.yu@amd.com>

Signed-off-by: Qiang Yu <qiang.yu@amd.com>
---
 include/linux/memcontrol.h | 1 +
 mm/memcontrol.c            | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d76977943265..6518b4b5ee07 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -36,6 +36,7 @@ enum memcg_stat_item {
 	MEMCG_SOCK,
 	/* XXX: why are these zone and not node counters? */
 	MEMCG_KERNEL_STACK_KB,
+	MEMCG_DRV,
 	MEMCG_NR_STAT,
 };
 
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 28595c276e6b..cdd3f3401598 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1413,6 +1413,9 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
 	seq_buf_printf(&s, "sock %llu\n",
 		       (u64)memcg_page_state(memcg, MEMCG_SOCK) *
 		       PAGE_SIZE);
+	seq_buf_printf(&s, "driver %llu\n",
+		       (u64)memcg_page_state(memcg, MEMCG_DRV) *
+		       PAGE_SIZE);
 
 	seq_buf_printf(&s, "shmem %llu\n",
 		       (u64)memcg_page_state(memcg, NR_SHMEM) *
@@ -6947,6 +6950,9 @@ EXPORT_SYMBOL(mem_cgroup_driver_get_from_current);
 int mem_cgroup_charge_drvmem(struct mem_cgroup *memcg, gfp_t gfp,
 			     unsigned long nr_pages)
 {
+	if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+		mod_memcg_state(memcg, MEMCG_DRV, nr_pages);
+
 	return try_charge(memcg, gfp, nr_pages);
 }
 EXPORT_SYMBOL(mem_cgroup_charge_drvmem);
@@ -6958,6 +6964,9 @@ EXPORT_SYMBOL(mem_cgroup_charge_drvmem);
  */
 void mem_cgroup_uncharge_drvmem(struct mem_cgroup *memcg, unsigned long nr_pages)
 {
+	if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+		mod_memcg_state(memcg, MEMCG_DRV, -nr_pages);
+
 	refill_stock(memcg, nr_pages);
 }
 EXPORT_SYMBOL(mem_cgroup_uncharge_drvmem);
-- 
2.17.1



WARNING: multiple messages have this Message-ID (diff)
From: Qiang Yu <qiang.yu@amd.com>
To: linux-mm@kvack.org, cgroups@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Cc: David Airlie <airlied@linux.ie>, Kenny Ho <kenny.ho@amd.com>,
	Michal Hocko <mhocko@kernel.org>, Qiang Yu <qiang.yu@amd.com>,
	Huang Rui <ray.huang@amd.com>,
	Johannes Weiner <hannes@cmpxchg.org>, Tejun Heo <tj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christian Koenig <christian.koenig@amd.com>
Subject: [PATCH RFC 2/3] mm: memcontrol: record driver memory statistics
Date: Mon, 13 Jan 2020 23:35:42 +0800	[thread overview]
Message-ID: <20200113153543.24957-3-qiang.yu@amd.com> (raw)
In-Reply-To: <20200113153543.24957-1-qiang.yu@amd.com>

Signed-off-by: Qiang Yu <qiang.yu@amd.com>
---
 include/linux/memcontrol.h | 1 +
 mm/memcontrol.c            | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d76977943265..6518b4b5ee07 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -36,6 +36,7 @@ enum memcg_stat_item {
 	MEMCG_SOCK,
 	/* XXX: why are these zone and not node counters? */
 	MEMCG_KERNEL_STACK_KB,
+	MEMCG_DRV,
 	MEMCG_NR_STAT,
 };
 
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 28595c276e6b..cdd3f3401598 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1413,6 +1413,9 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
 	seq_buf_printf(&s, "sock %llu\n",
 		       (u64)memcg_page_state(memcg, MEMCG_SOCK) *
 		       PAGE_SIZE);
+	seq_buf_printf(&s, "driver %llu\n",
+		       (u64)memcg_page_state(memcg, MEMCG_DRV) *
+		       PAGE_SIZE);
 
 	seq_buf_printf(&s, "shmem %llu\n",
 		       (u64)memcg_page_state(memcg, NR_SHMEM) *
@@ -6947,6 +6950,9 @@ EXPORT_SYMBOL(mem_cgroup_driver_get_from_current);
 int mem_cgroup_charge_drvmem(struct mem_cgroup *memcg, gfp_t gfp,
 			     unsigned long nr_pages)
 {
+	if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+		mod_memcg_state(memcg, MEMCG_DRV, nr_pages);
+
 	return try_charge(memcg, gfp, nr_pages);
 }
 EXPORT_SYMBOL(mem_cgroup_charge_drvmem);
@@ -6958,6 +6964,9 @@ EXPORT_SYMBOL(mem_cgroup_charge_drvmem);
  */
 void mem_cgroup_uncharge_drvmem(struct mem_cgroup *memcg, unsigned long nr_pages)
 {
+	if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+		mod_memcg_state(memcg, MEMCG_DRV, -nr_pages);
+
 	refill_stock(memcg, nr_pages);
 }
 EXPORT_SYMBOL(mem_cgroup_uncharge_drvmem);
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-01-13 15:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13 15:35 [PATCH RFC 0/3] mm/memcontrol drm/ttm: charge ttm buffer backed by system memory Qiang Yu
2020-01-13 15:35 ` Qiang Yu
2020-01-13 15:35 ` Qiang Yu
2020-01-13 15:35 ` [PATCH RFC 1/3] mm: memcontrol: add mem_cgroup_(un)charge_drvmem Qiang Yu
2020-01-13 15:35   ` Qiang Yu
2020-01-13 15:35   ` Qiang Yu
2020-01-13 15:35 ` Qiang Yu [this message]
2020-01-13 15:35   ` [PATCH RFC 2/3] mm: memcontrol: record driver memory statistics Qiang Yu
2020-01-13 15:35 ` [PATCH RFC 3/3] drm/ttm: support memcg for ttm_tt Qiang Yu
2020-01-13 15:35   ` Qiang Yu
2020-01-13 15:55   ` Christian König
2020-01-13 15:55     ` Christian König
2020-01-13 15:55     ` Christian König
2020-01-19  2:47     ` Qiang Yu
2020-01-19  2:47       ` Qiang Yu
2020-01-19  2:47       ` Qiang Yu
2020-01-19 13:03       ` Christian König
2020-01-19 13:03         ` Christian König
2020-01-19 13:03         ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200113153543.24957-3-qiang.yu@amd.com \
    --to=qiang.yu@amd.com \
    --cc=airlied@linux.ie \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hannes@cmpxchg.org \
    --cc=kenny.ho@amd.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.