From: Byungchul Park <byungchul@sk.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: kernel_team@skhynix.com, akpm@linux-foundation.org,
ying.huang@intel.com, namit@vmware.com, xhao@linux.alibaba.com,
mgorman@techsingularity.net, hughd@google.com,
willy@infradead.org, david@redhat.com, peterz@infradead.org,
luto@kernel.org, dave.hansen@linux.intel.com
Subject: [RFC v2 6/6] mm, migrc: Implement internal allocator to minimize impact onto vm
Date: Thu, 17 Aug 2023 17:05:59 +0900 [thread overview]
Message-ID: <20230817080559.43200-7-byungchul@sk.com> (raw)
In-Reply-To: <20230817080559.43200-1-byungchul@sk.com>
(Not sure if this patch works meaningfully. Ignore if not.)
Signed-off-by: Byungchul Park <byungchul@sk.com>
---
mm/migrate.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index c57536a0b2a6..6b5113d5a1e2 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -122,14 +122,33 @@ enum {
MIGRC_DST_PENDING,
};
+#define MAX_MIGRC_REQ_NR 4096
+static struct migrc_req migrc_req_pool_static[MAX_MIGRC_REQ_NR];
+static atomic_t migrc_req_pool_idx = ATOMIC_INIT(-1);
+static LLIST_HEAD(migrc_req_pool_llist);
+static DEFINE_SPINLOCK(migrc_req_pool_lock);
+
static struct migrc_req *alloc_migrc_req(void)
{
- return kmalloc(sizeof(struct migrc_req), GFP_KERNEL);
+ int idx = atomic_read(&migrc_req_pool_idx);
+ struct llist_node *n;
+
+ if (idx < MAX_MIGRC_REQ_NR - 1) {
+ idx = atomic_inc_return(&migrc_req_pool_idx);
+ if (idx < MAX_MIGRC_REQ_NR)
+ return migrc_req_pool_static + idx;
+ }
+
+ spin_lock(&migrc_req_pool_lock);
+ n = llist_del_first(&migrc_req_pool_llist);
+ spin_unlock(&migrc_req_pool_lock);
+
+ return n ? llist_entry(n, struct migrc_req, llnode) : NULL;
}
void free_migrc_req(struct migrc_req *req)
{
- kfree(req);
+ llist_add(&req->llnode, &migrc_req_pool_llist);
}
static bool migrc_is_full(int nid)
--
2.17.1
prev parent reply other threads:[~2023-08-17 8:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-17 8:05 [RFC v2 0/6] Reduce TLB flushes under some specific conditions Byungchul Park
2023-08-17 8:05 ` [RFC v2 1/6] mm/rmap: Recognize non-writable TLB entries during TLB batch flush Byungchul Park
2023-08-17 8:05 ` [RFC v2 2/6] mm: Defer TLB flush by keeping both src and dst folios at migration Byungchul Park
2023-08-17 8:05 ` [RFC v2 3/6] mm, migrc: Skip TLB flushes at the CPUs that already have been done Byungchul Park
2023-08-17 8:05 ` [RFC v2 4/6] mm, migrc: Ajust __zone_watermark_ok() with the amount of pending folios Byungchul Park
2023-08-17 8:05 ` [RFC v2 5/6] mm, migrc: Add a sysctl knob to enable/disable MIGRC mechanism Byungchul Park
2023-08-17 8:05 ` Byungchul Park [this message]
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=20230817080559.43200-7-byungchul@sk.com \
--to=byungchul@sk.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=kernel_team@skhynix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mgorman@techsingularity.net \
--cc=namit@vmware.com \
--cc=peterz@infradead.org \
--cc=willy@infradead.org \
--cc=xhao@linux.alibaba.com \
--cc=ying.huang@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox