From patchwork Mon Oct 5 10:55:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11816451 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 90F7B139A for ; Mon, 5 Oct 2020 10:58:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E9E2207F7 for ; Mon, 5 Oct 2020 10:58:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="bLkaqWJC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E9E2207F7 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 940626B0068; Mon, 5 Oct 2020 06:58:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C8766B0071; Mon, 5 Oct 2020 06:58:33 -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 76A436B0072; Mon, 5 Oct 2020 06:58:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id 45A686B0068 for ; Mon, 5 Oct 2020 06:58:33 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C982A362B for ; Mon, 5 Oct 2020 10:58:32 +0000 (UTC) X-FDA: 77337573264.01.shame85_2d094d2271bd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id A592D10047837 for ; Mon, 5 Oct 2020 10:58:32 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,prvs=5409d9be5=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;04y814x43ucjnqhqgrs5487n8gs8goc9o3e1jizsn5o69bkps4hf9onztotcpiq.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:22,LUA_SUMMARY:none X-HE-Tag: shame85_2d094d2271bd X-Filterd-Recvd-Size: 5809 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Mon, 5 Oct 2020 10:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1601895513; x=1633431513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=sovS4fsavcCCXLTzHaW2dVDQJFnArtjht8C/IMsjG80=; b=bLkaqWJCwylsOy3r3yIv+8zYQ1Zp6Y3STzbzxeWftxQBvHo90K6y7LII Ol8wtIFqH+xolGDKXPpqHqng6IYmwvhIJ8SLxjLEOEqzT1QD8CyIgMSR0 8WxGcAbDzf54Mew+O7Vry6Ysnsm3qamuEC4PCi68IRYYxoljvayLWrNPp 0=; X-IronPort-AV: E=Sophos;i="5.77,338,1596499200"; d="scan'208";a="80357873" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 05 Oct 2020 10:58:27 +0000 Received: from EX13D31EUA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com (Postfix) with ESMTPS id B07C9A1F92; Mon, 5 Oct 2020 10:58:14 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.146) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 5 Oct 2020 10:57:58 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v21 08/18] mm/damon/primitives: Make coexistable with Idle Page Tracking Date: Mon, 5 Oct 2020 12:55:12 +0200 Message-ID: <20201005105522.23841-9-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201005105522.23841-1-sjpark@amazon.com> References: <20201005105522.23841-1-sjpark@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.160.146] X-ClientProxiedBy: EX13d09UWC002.ant.amazon.com (10.43.162.102) To EX13D31EUA001.ant.amazon.com (10.43.165.15) 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 6c8cb66866ac..9f33677e4807 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