From patchwork Tue Aug 13 16:56:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanchu Xie X-Patchwork-Id: 13762347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84F87C52D7C for ; Tue, 13 Aug 2024 16:59:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86D696B009F; Tue, 13 Aug 2024 12:59:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F3E76B00A0; Tue, 13 Aug 2024 12:59:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 586516B00A1; Tue, 13 Aug 2024 12:59:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2FD9C6B009F for ; Tue, 13 Aug 2024 12:59:47 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CC32B160909 for ; Tue, 13 Aug 2024 16:59:46 +0000 (UTC) X-FDA: 82447833972.05.219145F Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf12.hostedemail.com (Postfix) with ESMTP id F0ABE40014 for ; Tue, 13 Aug 2024 16:59:44 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=CJmeDm6q; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of 3_5C7ZgcKCEwC8o1qv8u22uzs.q20zw18B-00y9oqy.25u@flex--yuanchu.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3_5C7ZgcKCEwC8o1qv8u22uzs.q20zw18B-00y9oqy.25u@flex--yuanchu.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723568327; a=rsa-sha256; cv=none; b=zcsJrCiTkqD9DzJOLmgE5fIedsX9EWqLn42o/ScSHMpzPhG5nc5EpsRdzuCcMz1NqrqOlY UFGQMhtc44B6YqIK7AZbTnFMeWRZXQ4v8Vd5hZGFIfsPSPizK4TlPYI/luHI9ckYALCu+f MibT7lnHH45DLQH8iLg6fW/T/CeBaHA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=CJmeDm6q; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of 3_5C7ZgcKCEwC8o1qv8u22uzs.q20zw18B-00y9oqy.25u@flex--yuanchu.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3_5C7ZgcKCEwC8o1qv8u22uzs.q20zw18B-00y9oqy.25u@flex--yuanchu.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723568327; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nX5Or29rWGSYnqI8Mal7bT79wmdNbU4VM0EJZ849BDE=; b=8qNoi+X3QM4kGIXE8WBDrc8VFTVOxJ6j0eKmRfbfvPKsKwQEoZQk81soZVnHQQKPiDbsow b+GbYIPg1f71tJstyZFjESJy5p8dgrbuFbPT5YJQU41ldAuQRgZ4ZGhrlkfuqZjXLSdKLG k/V+655cvy3dtAlupUChgVyqVUJTM90= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-672bea19bedso135340877b3.3 for ; Tue, 13 Aug 2024 09:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723568384; x=1724173184; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=nX5Or29rWGSYnqI8Mal7bT79wmdNbU4VM0EJZ849BDE=; b=CJmeDm6qrr+ILt8/AD9jK/iE3zN5z9NcMmGhsV44IA8v4256p0TQEULKM3TF0uj6hz QF2toYHJCyjYpxdRsxaJldqF1ePLUGr1VpsA9oilzbbPrvrcsLrGoCyU30Q0nZUoGMF5 y7I8vCgk33JcBEfzTwHR8F0hMC9rVyXBqkJfyDXZ7nQyC+8VCmhLSNPhkMGnHCqp2CMV O3hnxcLcP924yjMPRblkN6nliPeylmHELweJfWZXM8bjhaw3X9C0MQoa9Ja+yLBQ64TW oqGveRlxq0j4l7KrN5iWqf5stXwqSDt/BlRsGr73bqNaRvyxhMANnXSA8KlDf46zVz8t B3Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723568384; x=1724173184; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nX5Or29rWGSYnqI8Mal7bT79wmdNbU4VM0EJZ849BDE=; b=OEeaQf1KHwALVZuBScd6TAVyLWd7ZpCfWeoJbYsjHp2nvfvtgpqgFVBgLDY+xpgk2e zkNQdi5ZmrRP2ibV9+JSKN0om/Kl9viVUh3oJ9AFzrr0cD1+9fuvdgdJEK846FcTrV6c TazUgJJt1Q9Oei1UXxLB3Wel08DCW4ajfjQvYxBGoXOD80MIo7mrvR8nKEQgRolXBWPX fn3qS27d7ys1un87Y8zx9gnDk72qKQUqSgvRi9v2QVs4W/xxen7Zrf8jDO7rmb5DF7hg iDxuaAxHrVT4bEruzVKRBDDT0UmRdN1qN2CnJygkkiUq98JOKXRkN4ANwmQc6iP95duW BSdw== X-Forwarded-Encrypted: i=1; AJvYcCV9v9RNjFe1yzyut9/VhwlUFjSBHfxj2oanxMYIvTwetRqMq4hXOKS5JAmW5fwLcp1/JLqCRyWfFA==@kvack.org X-Gm-Message-State: AOJu0Yw7q+7ucprfcKx305lAe9EQYT1mAhdcU0HH6ZivsbKFqxCNR0tA urFEND8Aknkree9q8h8R3JbLeq7b5kRATUToYHIqWhyIMqBifUd8D0VHbahkhoDeNwkU03uJpTI b6+D5UA== X-Google-Smtp-Source: AGHT+IEDV077DvpPZgcSOtEG+50DqdAd9HxWks1Jm8Rh/HY1wmqFnkHTld2tYhmnQaOc9LEXewCUzyWTHQqf X-Received: from yuanchu-desktop.svl.corp.google.com ([2620:15c:2a3:200:b50c:66e8:6532:a371]) (user=yuanchu job=sendgmr) by 2002:a25:a444:0:b0:e05:6e45:84b6 with SMTP id 3f1490d57ef6-e1155b79891mr171276.8.1723568383787; Tue, 13 Aug 2024 09:59:43 -0700 (PDT) Date: Tue, 13 Aug 2024 09:56:15 -0700 In-Reply-To: <20240813165619.748102-1-yuanchu@google.com> Mime-Version: 1.0 References: <20240813165619.748102-1-yuanchu@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Message-ID: <20240813165619.748102-5-yuanchu@google.com> Subject: [PATCH v3 4/7] mm: extend working set reporting to memcgs From: Yuanchu Xie To: David Hildenbrand , "Aneesh Kumar K.V" , Khalid Aziz , Henry Huang , Yu Zhao , Dan Williams , Gregory Price , Huang Ying , Andrew Morton , Lance Yang , Randy Dunlap , Muhammad Usama Anjum Cc: Kalesh Singh , Wei Xu , David Rientjes , Greg Kroah-Hartman , "Rafael J. Wysocki" , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Shuah Khan , Yosry Ahmed , Matthew Wilcox , Sudarshan Rajagopalan , Kairui Song , "Michael S. Tsirkin" , Vasily Averin , Nhat Pham , Miaohe Lin , Qi Zheng , Abel Wu , "Vishal Moola (Oracle)" , Kefeng Wang , Yuanchu Xie , linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: F0ABE40014 X-Stat-Signature: qgi6yxins5m78j66jwaor5qe3xgxbnh3 X-Rspam-User: X-HE-Tag: 1723568384-688403 X-HE-Meta: U2FsdGVkX18MyOL23rr2jRDmj/UT9XDmkPtw6kgMZGHvzASrhS5B8vj+U2dshE4HPHLQIQAhQtg0hxdkbceXVk4ZLcabWR8XUoBun/1TjlL8UyzjXa6g6X57ZVjQtPML8jy0kGE5Svh5hhAsfYruEcz4v89X9l+MoJejWlp2oanYK8TpEswdh2212uN6ZrK9p4pfSlUlxG5yoFwgAXFTplbYtQEznKidR2oTyHNqUO+avfu7i4Xjsdy2fRqw9vZAWSSmBP+IHvElJH0hM6EWsAngYyxL+OlU+xn4iXRVEzk5oo+G8NIhYPAY+fldBfzrT0c4+jBw2gnbt6Uj3xjnJffP6iUidXFe2XI6hRabmmi41y8nF3W6AeP4B0n2ie227aRZZsPOmwqvR6djj9Yc3WZ2ESDj/mSL+ddrTZtyYyNMVVg7mAI4nrI3TKsu3Q5qO3z2wUsSZouMPid2layAdSVTuq45VK4YQOJLi402gZGr10GH7xli/ADMnLKg07cApxGWwU2WOdsMehwR3hgT4s/mWDhJ9yiInKzsPGe+uJma0HWZSa47RFO0856GgyLTkCdEZgznrne0kI6YgEkrcQ7HB4xL0+jtlHB+vKm6Qe+/lnVstYW6cvQCYhsAzvH7yPVum8+heOAY5g55SljqJ2G6/AHw2pO8KBXoPWqngObtuEEF0U5Swp/ugelafbAG5czJeuNotPvwU7npKR7ZbWWuz73T7zxNHAo5YKm2pFqaCJltu10auO80nJE5DLZ+kyVblsTRhl9dUUE9nm8U8bWh2XVxDVn3Zs9VTvgPP/pKg8wY8cLxx+UJ/+u2o2tIWj2tYpDT6IMOooGMN/X2ZXro/96E+PAhPpboyVUZ+zSYKC0S4zq+H8W74mTr3uqjts/0sGJeAgBcqZ4HdoPWaO+gVLg5N7FZ56mhw2+Rx5+70N4vR/cdm1tCQplldt1vnmqDd1dwNt+dyKvoAn1 RirT31Dj xpaWjTI4JzVERudeidAlmfA0/HP6r0HPr5Xl4pCZk8KP+qBodawqMxnwWh3B9zaY8jZGh05vtja7pTx3JebF9D5vT1gT/V7oaBwiCNI7Wq07KuzYVuWjROPYaqGqSQ9ylxilrkC9m9Ktbg28vgWik43ZDgmoCgSC1MWer6ck3aUJCXHqgfmUqXhWSqNfHRHIUEAGaHu2sXZEATheviDol5bI2kx9aktpwphBRj5Zb0rxFrY/vCbZ/JRWZqplUZWZBn7sAhVn+4C7ibSt3J5AYQ/AeQJWn2P843UBqMzBVUG6frm4gyM3M8ez25cIyp5TrVjErVHTWxHDGG/5LwotLwTuUL700Xuhd10fEaWqMQJfzHUgDaKDjR5gvpHx9p2TBIRAmlRI4Q2QIkIZAJ5PDiqdwDG29++IaEACtNxI12lORvjyVrKVwFbziNU/yayNe3+3dkHa9iah/TlnchnXxnRoAn5y0dOla+LVIeOVijqGsJHa23k/CS7Zt2JFCciUVV06d7vGs72bSKS8JNtCoctRS5lE6vZpsR3mKNZtUTZsIWiHH8ApZIcGpza1AXletYhop40wKmS7WNbgmCamORd9+ng== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Break down the system-wide working set reporting into per-memcg reports, which aggregages its children hierarchically. The per-node working set reporting histograms and refresh/report threshold files are presented as memcg files, showing a report containing all the nodes. The per-node page age interval is configurable in sysfs and not available per-memcg, while the refresh interval and report threshold are configured per-memcg. Memcg interface: /sys/fs/cgroup/.../memory.workingset.page_age The memcg equivalent of the sysfs workingset page age histogram breaks down the workingset of this memcg and its children into page age intervals. Each node is prefixed with a node header and a newline. Non-proactive direct reclaim on this memcg can also wake up userspace agents that are waiting on this file. e.g. N0 1000 anon=0 file=0 2000 anon=0 file=0 3000 anon=0 file=0 4000 anon=0 file=0 5000 anon=0 file=0 18446744073709551615 anon=0 file=0 /sys/fs/cgroup/.../memory.workingset.refresh_interval The memcg equivalent of the sysfs refresh interval. A per-node number of how much time a page age histogram is valid for, in milliseconds. e.g. echo N0=2000 > memory.workingset.refresh_interval /sys/fs/cgroup/.../memory.workingset.report_threshold The memcg equivalent of the sysfs report threshold. A per-node number of how often userspace agent waiting on the page age histogram can be woken up, in milliseconds. e.g. echo N0=1000 > memory.workingset.report_threshold Signed-off-by: Yuanchu Xie Change-Id: I6c8a39cddd248c031c85f144787c9044912f3c21 --- include/linux/memcontrol.h | 21 ++++ include/linux/workingset_report.h | 6 +- mm/internal.h | 2 + mm/memcontrol.c | 178 +++++++++++++++++++++++++++++- mm/workingset_report.c | 12 +- 5 files changed, 214 insertions(+), 5 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 0e5bf25d324f..6d67f1072943 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -315,6 +315,11 @@ struct mem_cgroup { spinlock_t event_list_lock; #endif /* CONFIG_MEMCG_V1 */ +#ifdef CONFIG_WORKINGSET_REPORT + /* memory.workingset.page_age file */ + struct cgroup_file workingset_page_age_file; +#endif + struct mem_cgroup_per_node *nodeinfo[]; }; @@ -1063,6 +1068,16 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm, void split_page_memcg(struct page *head, int old_order, int new_order); +static inline struct cgroup_file * +mem_cgroup_page_age_file(struct mem_cgroup *memcg) +{ +#ifdef CONFIG_WORKINGSET_REPORT + return &memcg->workingset_page_age_file; +#else + return NULL; +#endif +} + #else /* CONFIG_MEMCG */ #define MEM_CGROUP_ID_SHIFT 0 @@ -1470,6 +1485,12 @@ void count_memcg_event_mm(struct mm_struct *mm, enum vm_event_item idx) static inline void split_page_memcg(struct page *head, int old_order, int new_order) { } + +static inline struct cgroup_file * +mem_cgroup_page_age_file(struct mem_cgroup *memcg) +{ + return NULL; +} #endif /* CONFIG_MEMCG */ /* diff --git a/include/linux/workingset_report.h b/include/linux/workingset_report.h index 2ec8b927b200..ae412d408037 100644 --- a/include/linux/workingset_report.h +++ b/include/linux/workingset_report.h @@ -9,6 +9,7 @@ struct mem_cgroup; struct pglist_data; struct node; struct lruvec; +struct cgroup_file; #ifdef CONFIG_WORKINGSET_REPORT @@ -40,7 +41,10 @@ struct wsr_state { unsigned long report_threshold; unsigned long refresh_interval; - struct kernfs_node *page_age_sys_file; + union { + struct kernfs_node *page_age_sys_file; + struct cgroup_file *page_age_cgroup_file; + }; /* breakdown of workingset by page age */ struct mutex page_age_lock; diff --git a/mm/internal.h b/mm/internal.h index 19af882c506e..cc54358ed582 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -421,6 +421,8 @@ void set_task_reclaim_state(struct task_struct *task, struct reclaim_state *rs); * in mm/wsr.c */ void notify_workingset(struct mem_cgroup *memcg, struct pglist_data *pgdat); +int workingset_report_intervals_parse(char *src, + struct wsr_report_bins *bins); #else static inline void notify_workingset(struct mem_cgroup *memcg, struct pglist_data *pgdat) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5d16fd9d2c3f..56848dc94d48 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4318,6 +4318,162 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf, return nbytes; } +#ifdef CONFIG_WORKINGSET_REPORT +static int memory_ws_refresh_interval_show(struct seq_file *m, void *v) +{ + int nid; + struct mem_cgroup *memcg = mem_cgroup_from_seq(m); + + for_each_node_state(nid, N_MEMORY) { + struct wsr_state *wsr = + &mem_cgroup_lruvec(memcg, NODE_DATA(nid))->wsr; + + seq_printf(m, "N%d=%u ", nid, + jiffies_to_msecs(READ_ONCE(wsr->refresh_interval))); + } + seq_putc(m, '\n'); + + return 0; +} + +static ssize_t memory_wsr_threshold_parse(char *buf, size_t nbytes, + unsigned int *nid_out, + unsigned int *msecs) +{ + char *node, *threshold; + unsigned int nid; + int err; + + buf = strstrip(buf); + threshold = buf; + node = strsep(&threshold, "="); + + if (*node != 'N') + return -EINVAL; + + err = kstrtouint(node + 1, 0, &nid); + if (err) + return err; + + if (nid >= nr_node_ids || !node_state(nid, N_MEMORY)) + return -EINVAL; + + err = kstrtouint(threshold, 0, msecs); + if (err) + return err; + + *nid_out = nid; + + return nbytes; +} + +static ssize_t memory_ws_refresh_interval_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, + loff_t off) +{ + unsigned int nid, msecs; + struct wsr_state *wsr; + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); + ssize_t ret = memory_wsr_threshold_parse(buf, nbytes, &nid, &msecs); + + if (ret < 0) + return ret; + + wsr = &mem_cgroup_lruvec(memcg, NODE_DATA(nid))->wsr; + + mutex_lock(&wsr->page_age_lock); + if (msecs && !wsr->page_age) { + struct wsr_page_age_histo *page_age = + kzalloc(sizeof(struct wsr_page_age_histo), GFP_KERNEL); + + if (!page_age) { + ret = -ENOMEM; + goto unlock; + } + wsr->page_age = page_age; + } + if (!msecs && wsr->page_age) { + kfree(wsr->page_age); + wsr->page_age = NULL; + } + + WRITE_ONCE(wsr->refresh_interval, msecs_to_jiffies(msecs)); +unlock: + mutex_unlock(&wsr->page_age_lock); + return ret; +} + +static int memory_ws_report_threshold_show(struct seq_file *m, void *v) +{ + int nid; + struct mem_cgroup *memcg = mem_cgroup_from_seq(m); + + for_each_node_state(nid, N_MEMORY) { + struct wsr_state *wsr = + &mem_cgroup_lruvec(memcg, NODE_DATA(nid))->wsr; + + seq_printf(m, "N%d=%u ", nid, + jiffies_to_msecs(READ_ONCE(wsr->report_threshold))); + } + seq_putc(m, '\n'); + + return 0; +} + +static ssize_t memory_ws_report_threshold_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, + loff_t off) +{ + unsigned int nid, msecs; + struct wsr_state *wsr; + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); + ssize_t ret = memory_wsr_threshold_parse(buf, nbytes, &nid, &msecs); + + if (ret < 0) + return ret; + + wsr = &mem_cgroup_lruvec(memcg, NODE_DATA(nid))->wsr; + WRITE_ONCE(wsr->report_threshold, msecs_to_jiffies(msecs)); + return ret; +} + +static int memory_ws_page_age_show(struct seq_file *m, void *v) +{ + int nid; + struct mem_cgroup *memcg = mem_cgroup_from_seq(m); + + for_each_node_state(nid, N_MEMORY) { + struct wsr_state *wsr = + &mem_cgroup_lruvec(memcg, NODE_DATA(nid))->wsr; + struct wsr_report_bin *bin; + + if (!READ_ONCE(wsr->page_age)) + continue; + + wsr_refresh_report(wsr, memcg, NODE_DATA(nid)); + mutex_lock(&wsr->page_age_lock); + if (!wsr->page_age) + goto unlock; + seq_printf(m, "N%d\n", nid); + for (bin = wsr->page_age->bins; + bin->idle_age != WORKINGSET_INTERVAL_MAX; bin++) + seq_printf(m, "%u anon=%lu file=%lu\n", + jiffies_to_msecs(bin->idle_age), + bin->nr_pages[0] * PAGE_SIZE, + bin->nr_pages[1] * PAGE_SIZE); + + seq_printf(m, "%lu anon=%lu file=%lu\n", WORKINGSET_INTERVAL_MAX, + bin->nr_pages[0] * PAGE_SIZE, + bin->nr_pages[1] * PAGE_SIZE); + +unlock: + mutex_unlock(&wsr->page_age_lock); + } + + return 0; +} +#endif + static struct cftype memory_files[] = { { .name = "current", @@ -4386,7 +4542,27 @@ static struct cftype memory_files[] = { .flags = CFTYPE_NS_DELEGATABLE, .write = memory_reclaim, }, - { } /* terminate */ +#ifdef CONFIG_WORKINGSET_REPORT + { + .name = "workingset.refresh_interval", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_NS_DELEGATABLE, + .seq_show = memory_ws_refresh_interval_show, + .write = memory_ws_refresh_interval_write, + }, + { + .name = "workingset.report_threshold", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_NS_DELEGATABLE, + .seq_show = memory_ws_report_threshold_show, + .write = memory_ws_report_threshold_write, + }, + { + .name = "workingset.page_age", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_NS_DELEGATABLE, + .file_offset = offsetof(struct mem_cgroup, workingset_page_age_file), + .seq_show = memory_ws_page_age_show, + }, +#endif + {} /* terminate */ }; struct cgroup_subsys memory_cgrp_subsys = { diff --git a/mm/workingset_report.c b/mm/workingset_report.c index 801ac8e5c1da..333e51e3ee12 100644 --- a/mm/workingset_report.c +++ b/mm/workingset_report.c @@ -37,9 +37,12 @@ void wsr_destroy_pgdat(struct pglist_data *pgdat) void wsr_init_lruvec(struct lruvec *lruvec) { struct wsr_state *wsr = &lruvec->wsr; + struct mem_cgroup *memcg = lruvec_memcg(lruvec); memset(wsr, 0, sizeof(*wsr)); mutex_init(&wsr->page_age_lock); + if (memcg && !mem_cgroup_is_root(memcg)) + wsr->page_age_cgroup_file = mem_cgroup_page_age_file(memcg); } void wsr_destroy_lruvec(struct lruvec *lruvec) @@ -51,8 +54,8 @@ void wsr_destroy_lruvec(struct lruvec *lruvec) memset(wsr, 0, sizeof(*wsr)); } -static int workingset_report_intervals_parse(char *src, - struct wsr_report_bins *bins) +int workingset_report_intervals_parse(char *src, + struct wsr_report_bins *bins) { int err = 0, i = 0; char *cur, *next = strim(src); @@ -542,5 +545,8 @@ void notify_workingset(struct mem_cgroup *memcg, struct pglist_data *pgdat) { struct wsr_state *wsr = &mem_cgroup_lruvec(memcg, pgdat)->wsr; - kernfs_notify(wsr->page_age_sys_file); + if (mem_cgroup_is_root(memcg)) + kernfs_notify(wsr->page_age_sys_file); + else + cgroup_file_notify(wsr->page_age_cgroup_file); }