From patchwork Tue Oct 20 08:59:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11846089 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5CC31580 for ; Tue, 20 Oct 2020 09:04:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8485D222C8 for ; Tue, 20 Oct 2020 09:04:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="A5YSAzyu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8485D222C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 43CB86B0062; Tue, 20 Oct 2020 05:04:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 413B46B0070; Tue, 20 Oct 2020 05:04:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E4A16B0062; Tue, 20 Oct 2020 05:04:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id E04146B0062 for ; Tue, 20 Oct 2020 05:04:08 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 675BCA8DD for ; Tue, 20 Oct 2020 09:04:08 +0000 (UTC) X-FDA: 77391716976.12.goat52_1c106a22723e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 302381801BD7B for ; Tue, 20 Oct 2020 09:04:08 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,prvs=55584ce82=sjpark@amazon.com,,RULES_HIT:30003:30051:30054:30064,0,RBL:207.171.190.10:@amazon.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100;04yfxz5tahb456891ck83kz9gbtikoc9o3e1jizsn5o69bkps4hf9onztotcpiq.857q4g567z3k881qoahn5op4szjaf4o7yshqtxnk8uqhjjssy3491s6935akmwh.k-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: goat52_1c106a22723e X-Filterd-Recvd-Size: 5812 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 09:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1603184648; x=1634720648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ex0dyR52pQlWbtLTi7+DCeRnQUrgwEcr4wvrGWXwkYQ=; b=A5YSAzyum2Tux7zJ66NfEzlWz29JnVbxJA5u9ZKzwp7veNdeD84nr6vI N18RuFwCI3QLMA6POSh/f/exPphBOCuyG39+MXuW16tqcR8+eMPQ9UBTg GWXxPgzgHBN6XfoOD0vV02AJ//TcN72ktkNOzT70x+iuJRnuJ5rRdEBGD c=; X-IronPort-AV: E=Sophos;i="5.77,396,1596499200"; d="scan'208";a="85042254" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2c-456ef9c9.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 20 Oct 2020 09:04:07 +0000 Received: from EX13D31EUB001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2c-456ef9c9.us-west-2.amazon.com (Postfix) with ESMTPS id B46DAA88A7; Tue, 20 Oct 2020 09:04:02 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.161.237) by EX13D31EUB001.ant.amazon.com (10.43.166.210) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 20 Oct 2020 09:03:44 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v22 08/18] mm/damon/primitives: Make coexistable with Idle Page Tracking Date: Tue, 20 Oct 2020 10:59:30 +0200 Message-ID: <20201020085940.13875-9-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201020085940.13875-1-sjpark@amazon.com> References: <20201020085940.13875-1-sjpark@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.161.237] X-ClientProxiedBy: EX13D41UWC001.ant.amazon.com (10.43.162.107) To EX13D31EUB001.ant.amazon.com (10.43.166.210) 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: From: SeongJae Park DAMON's reference 'primitives' internally use 'PG_Idle' flag. Because the flag is also used by Idle Page Tracking but there was no way to synchronize with it, the 'primitives' were configured to be exclusive with Idle Page Tracking before. However, as we can now synchronize with Idle Page Tracking using 'idle_page_lock', this commit makes the primitives to do the synchronization and coexistable with Idle Page Tracking. Note that the 'primitives' only require the users to do the synchronization by themselves. Signed-off-by: SeongJae Park --- include/linux/page_idle.h | 2 ++ mm/damon/Kconfig | 2 +- mm/damon/primitives.c | 7 +++++++ mm/page_idle.c | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h index d8a6aecf99cb..bcbb965b566c 100644 --- a/include/linux/page_idle.h +++ b/include/linux/page_idle.h @@ -8,6 +8,8 @@ #ifdef CONFIG_PAGE_IDLE_FLAG +extern struct mutex page_idle_lock; + #ifdef CONFIG_64BIT static inline bool page_is_young(struct page *page) { diff --git a/mm/damon/Kconfig b/mm/damon/Kconfig index 0d2a18ddb9d8..63b9c905b548 100644 --- a/mm/damon/Kconfig +++ b/mm/damon/Kconfig @@ -14,7 +14,7 @@ config DAMON config DAMON_PRIMITIVES bool "Monitoring primitives for virtual address spaces monitoring" - depends on DAMON && MMU && !IDLE_PAGE_TRACKING + depends on DAMON && MMU select PAGE_EXTENSION if !64BIT select PAGE_IDLE_FLAG help diff --git a/mm/damon/primitives.c b/mm/damon/primitives.c index 9b603ac0077c..59f4de703413 100644 --- a/mm/damon/primitives.c +++ b/mm/damon/primitives.c @@ -15,6 +15,10 @@ #include #include +#ifndef CONFIG_IDLE_PAGE_TRACKING +DEFINE_MUTEX(page_idle_lock); +#endif + /* Minimal region size. Every damon_region is aligned by this. */ #define MIN_REGION PAGE_SIZE @@ -552,6 +556,9 @@ bool damon_va_target_valid(struct damon_target *t) { struct task_struct *task; + if (!mutex_is_locked(&page_idle_lock)) + return false; + task = damon_get_task_struct(t); if (task) { put_task_struct(task); diff --git a/mm/page_idle.c b/mm/page_idle.c index 0aa45f848570..958dcc18f6cd 100644 --- a/mm/page_idle.c +++ b/mm/page_idle.c @@ -16,7 +16,7 @@ #define BITMAP_CHUNK_SIZE sizeof(u64) #define BITMAP_CHUNK_BITS (BITMAP_CHUNK_SIZE * BITS_PER_BYTE) -static DEFINE_MUTEX(page_idle_lock); +DEFINE_MUTEX(page_idle_lock); /* * Idle page tracking only considers user memory pages, for other types of