From patchwork Mon Oct 24 20:49:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13018125 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 953ABC67871 for ; Mon, 24 Oct 2022 20:49:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8397E94000C; Mon, 24 Oct 2022 16:49:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C4C194000B; Mon, 24 Oct 2022 16:49:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37C9F94000C; Mon, 24 Oct 2022 16:49:29 -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 1331494000B for ; Mon, 24 Oct 2022 16:49:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D859C120658 for ; Mon, 24 Oct 2022 20:49:28 +0000 (UTC) X-FDA: 80057033616.22.02A8BCE Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf15.hostedemail.com (Postfix) with ESMTP id 5E350A0014 for ; Mon, 24 Oct 2022 20:49:28 +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 43924B81217; Mon, 24 Oct 2022 20:49:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 832D5C433D6; Mon, 24 Oct 2022 20:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644565; bh=eaYYbVIt8/+YtwkZbXmhWn+ifMSd+sXZYeDANgnL568=; h=From:To:Cc:Subject:Date:From; b=WIZ16QyG5Q6vwOmUWHJ7DZ3C93eYq1e4vlvqj2xhXEgil6Dse1Q01vZs3+J0urUO0 knps5WXaFzvq5VfPiPkJh4e0peL20MAOXXa3m2AEl1KXKAiAcg/8qdI9mVIVW05DFb QgvfEpi7XmS/LClWDIGu1sLJtqCNlimdF/GzwpGibfjnf0Qbkjs9DA35HYpW1PB/GE ZxLXshRS4GUmu3j8ESWINLnfBZFicdUxQg7HkxjYJ/cFLzmqMvmoLrZVcTKnN5wptr Q7DjDGskKYHXg9aWmnsD/7LLYvJpxdvwzNk5SPhnaZ2+MaIjBL5n3uBv+jixPvZlmr 1g2OnHsgaNSqw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 00/11] mm/damon: cleanup and refactoring code Date: Mon, 24 Oct 2022 20:49:08 +0000 Message-Id: <20221024204919.18524-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666644568; a=rsa-sha256; cv=none; b=cl0G2Mz8TNhTGxAppN5e4aGp6dfemz4mqPOM1fR+c9AP71nKF9cVvBHCclHse3Ifja90Ip et4/aFIiIkhVUj/fpHS5RUFRaJmtA53Ue06Wb++zmHfYySZeWGK+Oadld8s7L28Ee9YpMy 0hX542z959oZq5xm4jVY2r3gz4peimU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WIZ16QyG; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666644568; 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:dkim-signature; bh=VyaX3wCE5rGoYljuNDd5yl9k02NTvPyw9gYQ9qKULj4=; b=tQ5AaKVL0fvcCYKTk8KvQXb/52eN2p+bCYMKG832DDueOtNpKsEyzPN53//tWDLpKP2pBF sjf60nCjFX8Ycu9L4daq3dpzgyTJ6InlwX6935jXLalsmzNs/GxWlozzwYz8iIBG7A4OQ8 /xbgEzUPIwjcoHrIFO+1fpUmLY7iZyg= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5E350A0014 X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WIZ16QyG; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Stat-Signature: itheiaybexzntxt67xe849a8grqfye5e X-HE-Tag: 1666644568-663223 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: This patchset cleans up and refactors a range of DAMON code including the core, DAMON sysfs interface, and DAMON modules, for better readability and convenient future feature implementations. In detail, this patchset splits unnecessarily long and complex functions in core into smaller functions (patches 1-4). Then, it cleans up the DAMON sysfs interface by using more type-safe code (patch 5) and removing unnecessary function parameters (patch 6). Further, it refactor the code by distributing the code into multiple files (patches 7-9). Last two patches (patches 10 and 11) deduplicates and remove unnecessary header inclusion in DAMON modules (reclaim and lru_sort). Note that this initially posted as a part of a feature implementation RFC patchset[1], but separated into this patchset as the amount of the change is not small compared to the feature implementation change itself. [1] https://lore.kernel.org/damon/20221019001317.104270-1-sj@kernel.org/ SeongJae Park (11): mm/damon/core: split out DAMOS-charged region skip logic into a new function mm/damon/core: split damos application logic into a new function mm/damon/core: split out scheme stat update logic into a new function mm/damon/core: split out scheme quota adjustment logic into a new function mm/damon/sysfs: use damon_addr_range for regions' start and end values mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc() mm/damon/sysfs: move sysfs_lock to common module mm/damon/sysfs: move unsigned long range directory to common module mm/damon/sysfs: split out kdamond-independent schemes stats update logic into a new function mm/damon/modules: deduplicate init steps for DAMON context setup mm/damon/{reclaim,lru_sort}: remove unnecessarily included headers mm/damon/Makefile | 6 +- mm/damon/core.c | 262 +++++++++++++++++++++++--------------- mm/damon/lru_sort.c | 19 +-- mm/damon/modules-common.c | 42 ++++++ mm/damon/modules-common.h | 3 + mm/damon/reclaim.c | 19 +-- mm/damon/sysfs-common.c | 107 ++++++++++++++++ mm/damon/sysfs-common.h | 24 ++++ mm/damon/sysfs.c | 172 +++++-------------------- 9 files changed, 374 insertions(+), 280 deletions(-) create mode 100644 mm/damon/modules-common.c create mode 100644 mm/damon/sysfs-common.c create mode 100644 mm/damon/sysfs-common.h