From patchwork Fri Sep 9 20:28:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12972160 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 3A18BECAAD5 for ; Fri, 9 Sep 2022 20:29:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 31D778D0005; Fri, 9 Sep 2022 16:29:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CDF58D0006; Fri, 9 Sep 2022 16:29:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1978C8D0005; Fri, 9 Sep 2022 16:29:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EE5DF8D0006 for ; Fri, 9 Sep 2022 16:29:08 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B6AA8AAF99 for ; Fri, 9 Sep 2022 20:29:08 +0000 (UTC) X-FDA: 79893686376.05.43CE901 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf04.hostedemail.com (Postfix) with ESMTP id 481B54007B for ; Fri, 9 Sep 2022 20:29:08 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F2468B82658; Fri, 9 Sep 2022 20:29:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 369FEC43470; Fri, 9 Sep 2022 20:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662755345; bh=OVGs4WGaZlHSNw1bV9aTKJG9y36ZzMQPGlZGZcjins0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ip+V2dwR7+a6tDS2JAnQCwO5rJFAyowrX5+FfGIBNIsTYot/Veb/nwDlEqmeNtUQs nEMBGWe6pqrJyEb8Hs+MdAFA+I5oFdJNB36NlBpZC0nkTMOd21lG8iO2Ra4ypuPpjQ 4W5dX/F5GI0AkFryiAkYJKkQO8JIV3lB45w4lT7jL47LAAaPIRzynMz6uwU45Bh+XZ E5o5BI4Lyarzt66Xj/yFuiQb9R8RZ3h4J+c8G2gc9WN4gZbF7NICi52SH5OVqMv0in TH9MrIoz+J6fNJe93GTJ17U6HxX04QkESr522tdExGQL28caqt3vzzSA3ojYrHEmu/ K2etw9lz6iwkg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yun Levi Subject: [PATCH 2/7] mm/damon/core: avoid holes in newly set monitoring target ranges Date: Fri, 9 Sep 2022 20:28:56 +0000 Message-Id: <20220909202901.57977-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220909202901.57977-1-sj@kernel.org> References: <20220909202901.57977-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662755348; 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:in-reply-to:references:references:dkim-signature; bh=PHG3tseMODOqgX44qZm0G5El+SJLZ2NP77K3XscEj4I=; b=r+YU79Sy9DD+hW6ObXE0Zq5/lYrBvv3oVos9NPuENDHJoAzsyGbBK5sdBOcN83eWAZgZLO BaIVwzH6HYv+W1Cs8F/8HvcQUWhiVyUvCaLxXKB6S76+LAQ0c8QoCkVhBQzd+O3q/fLgwP hjNCXKW8SKaDeoRdTSWLBIP1pyLNU9U= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ip+V2dwR; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662755348; a=rsa-sha256; cv=none; b=6Sd16KG2XiF9QZelF3DWkSquM+wSTnDtZtiFG6r/tQLfVB9GFU6JZ6Enm5oh5hVCH8d67I hPgu4XN6HDLs2mqlx5YUzah5uz+aw+7yVs4pQZ2gVIS00aU25lg5KJsI1QT8zl9NCKL4Pr 3Q2abXpe3OACEivb0sPeZDD7QuhnvUo= X-Rspam-User: X-Stat-Signature: 9gupx8skj5c8tgpp3qe6gzx44agy779e X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 481B54007B Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ip+V2dwR; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1662755348-241480 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: When there are two or more non-contiguous regions intersecting with given new ranges, 'damon_set_regions()' does not fill the holes. This commit makes the function to fill the holes with newly created regions. Fixes: 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces") Reported-by: Yun Levi Signed-off-by: SeongJae Park --- mm/damon/core.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index bae41990f422..6f6c9c9aca9d 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -168,6 +168,27 @@ static bool damon_intersect(struct damon_region *r, return !(r->ar.end <= re->start || re->end <= r->ar.start); } +/* + * Fill holes in regions with new regions. + */ +static void damon_fill_regions_holes(struct damon_region *first, + struct damon_region *last, struct damon_target *t) +{ + struct damon_region *r = first; + + damon_for_each_region_from(r, t) { + struct damon_region *next, *newr; + + if (r == last) + break; + next = damon_next_region(r); + if (r->ar.end != next->ar.start) { + newr = damon_new_region(r->ar.end, next->ar.start); + damon_insert_region(newr, r, next, t); + } + } +} + /* * damon_set_regions() - Set regions of a target for given address ranges. * @t: the given target. @@ -226,6 +247,9 @@ int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, first->ar.start = ALIGN_DOWN(range->start, DAMON_MIN_REGION); last->ar.end = ALIGN(range->end, DAMON_MIN_REGION); + + /* fill possible holes in the range */ + damon_fill_regions_holes(first, last, t); } } return 0;