From patchwork Thu Aug 17 08:05:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13356112 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 158FCC2FC0E for ; Thu, 17 Aug 2023 08:09:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1BEC8280040; Thu, 17 Aug 2023 04:09:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1709528003E; Thu, 17 Aug 2023 04:09:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01214280040; Thu, 17 Aug 2023 04:09:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DFD7828003E for ; Thu, 17 Aug 2023 04:09:06 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C0628A1032 for ; Thu, 17 Aug 2023 08:09:06 +0000 (UTC) X-FDA: 81132871092.25.3E50776 Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by imf29.hostedemail.com (Postfix) with ESMTP id DA02F120010 for ; Thu, 17 Aug 2023 08:09:04 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf29.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692259745; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=mrAvDZq1CLVKxCFelD5gJ6PvbbLu6jexXpUij4Oengc=; b=BIdaOnkGSH+qmR9N+3NajOPA7wLT6qCWMB/LSahRFPrenbUKv+UpihlywH7fxBf68vabyo YqERxtxyfoaMHQB+CtzYux3Rj6IZs2es4gLUplrRQ4XXSNEXESj/yWt30cT37FigjhiEWJ Y45ieIr3eNQeZEfg0J/+Mkb+l34n//4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf29.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692259745; a=rsa-sha256; cv=none; b=aPD7kJG364DjUlJJgHbffWy+SFl2ElvMBfwMc2NtrQT2EdA8101SEwOgmqZlrNJ8+0dgaN ane3awQK5kbz4BR7hoFszxzzcrr9+wBDCKVN+NDxZSrhRPeUyU7mlz/lXC3dt+0bjF80nE RmWw7B/PQ9aPAGRilJB/BMEOwQzUnwA= X-AuditID: a67dfc5b-d85ff70000001748-d9-64ddd5987e6f From: Byungchul Park 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 Message-Id: <20230817080559.43200-7-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230817080559.43200-1-byungchul@sk.com> References: <20230817080559.43200-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsXC9ZZnoe6Mq3dTDA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9qI0ixuI2NVFHgi8xllajnCeWubnGm4Q2JqeBU7xXcfCN1hW5LxoKXMiXFflQzo+SqWaWoVl/Wsuq3vaUFllB2Vj/Ckj2h924pxSa0w74y3lC4TkgUd1pIBw6gD8i9JNKndyNnE/EMrICeLbiiv3x56mrVNxYrPJA6KbHjrlcv5VAnrYcf9hnBH7YSZ0IdWfhh/VmyDXDeAApeqAWl+yjKuR2WHlKuyC3HGE1QkyYUJ+UTF89n1NR7SzVyNHCqgvD716Z1ekOsEvJOBUrKKfENpFnmAyrJpfhiIY7ac9YJgoAZmchO5MNrU6qf1MzClMmnH0DUbPMyj1Xz0bpsTM6x34t4M0zMb8n1QNJMuZ9zVDWwtn2n2PwH8STtc7zKIVZYERLIuNMwORhPAxBm7uFkjIYBcO4gq8DDCgh5jprf04pVAOM9UPkqAz6CERK6qE4UfZy2CfKCDKSTKp4K5PfZWx1qjsEDj27tj3zS5doWhq/wj41iPHfouyanMtjm4KD+TQyCaZYneWnuMqd 7yQ== 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: (Not sure if this patch works meaningfully. Ignore if not.) Signed-off-by: Byungchul Park --- 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)