From patchwork Tue Sep 13 11:47:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12974702 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 3EA61C6FA89 for ; Tue, 13 Sep 2022 11:47:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A8BD8D0001; Tue, 13 Sep 2022 07:47:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8594D6B0073; Tue, 13 Sep 2022 07:47:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 747448D0001; Tue, 13 Sep 2022 07:47:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 657566B0072 for ; Tue, 13 Sep 2022 07:47:51 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3A1D680D71 for ; Tue, 13 Sep 2022 11:47:51 +0000 (UTC) X-FDA: 79906887942.25.83951A9 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf12.hostedemail.com (Postfix) with ESMTP id 5A463400B6 for ; Tue, 13 Sep 2022 11:47:48 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VPgF9Ig_1663069663; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VPgF9Ig_1663069663) by smtp.aliyun-inc.com; Tue, 13 Sep 2022 19:47:45 +0800 From: Xin Hao To: sj@kernel.org Cc: akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xhao@linux.alibaba.com Subject: [PATCH] mm/damon: add MADV_COLLAPSE support in damos_action Date: Tue, 13 Sep 2022 19:47:35 +0800 Message-Id: <20220913114735.22841-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663069671; a=rsa-sha256; cv=none; b=NMZGlmyWJe9EpptM2JD84njsJj+eL7EJ59+RVvoqFa+T6/5fJKe1kqWx3QLRcSn+KM2Vrp lI0j4UH4yEyjvXWsU8xokbeEusEEze4jkIUx+DW55gjfxy88U2p872R7NCQCsjlQGgvpsI 90ATr28XtnFFMeYedRg4WgKCHgS3UYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663069670; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=evhBVI6J9t/VObuQ2jzwozzFLWuGXgmcc7f+JlhYQ1s=; b=Aus81aPXuBagM5wX8hFk4VgtJ8uOF7a2rU8xGNQ9qX+bjstlJy9LripQqPwL07AqFFigIi ZHGxfpNgQLwD89E9/uQ5bJRX7ont8KqvUI/jcruudr2yU60mxhsgjW7ig3gKJdj464YYYw 9BLWuETlaZEdc3MgHMW2rn+JRwvErPQ= Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Rspamd-Queue-Id: 5A463400B6 X-Rspamd-Server: rspam04 X-Stat-Signature: yrg5ao6h8yssxm63194b64i9p5zgzhw5 X-HE-Tag: 1663069668-714385 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: MADV_COLLAPSE has large different with MDVA_HUGE in dealing with huge pages, it doesn't need to rely on 'khugepage' thread to create THP. So combining with it will give damon users more options. Signed-off-by: Xin Hao --- include/linux/damon.h | 1 + mm/damon/vaddr.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 016b6c9c03d6..c44f9410d997 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -97,6 +97,7 @@ enum damos_action { DAMOS_PAGEOUT, DAMOS_HUGEPAGE, DAMOS_NOHUGEPAGE, + DAMOS_COLLAPSE, DAMOS_LRU_PRIO, DAMOS_LRU_DEPRIO, DAMOS_STAT, /* Do nothing but only record the stat */ diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index c2c08c1b316b..58c0d068563d 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -655,6 +655,9 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx, case DAMOS_NOHUGEPAGE: madv_action = MADV_NOHUGEPAGE; break; + case DAMOS_COLLAPSE: + madv_action = MADV_COLLAPSE; + break; case DAMOS_STAT: return 0; default: