From patchwork Wed Oct 26 22:59:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13021333 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 3CAFAC433FE for ; Wed, 26 Oct 2022 22:59:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9BD98E0003; Wed, 26 Oct 2022 18:59:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEAC38E0007; Wed, 26 Oct 2022 18:59:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A1BE8E0005; Wed, 26 Oct 2022 18:59:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6B4128E0006 for ; Wed, 26 Oct 2022 18:59:53 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D3217AB253 for ; Wed, 26 Oct 2022 22:59:52 +0000 (UTC) X-FDA: 80064619824.10.202526A Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf09.hostedemail.com (Postfix) with ESMTP id 586E9140040 for ; Wed, 26 Oct 2022 22:59:52 +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 95D9CB82470; Wed, 26 Oct 2022 22:59:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF248C433D7; Wed, 26 Oct 2022 22:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666825189; bh=A1xog9/JoTImuQjfC8/0jRefs+jLn853oqIp5j+8x/c=; h=From:To:Cc:Subject:Date:From; b=QuZyRMU3886vYVE9gsZJ/b9p/OupKMJkvflDE3O8Tpf3rT5z/+aX0QHbWjjP63vHI LZZkgA1vu7Blc2LCxWr051ayX6l1dQzGNlUL11HVCOqYob35Z4MQdCHEbmTsLu/OyB oEFhko1EMhCPAhvgco50a17N4c2GLd3zLbQX5aUF3Tw9tdHQIThpqd1lEOfqWs6BrF fFmwJYzqRWJSM/T/Sygfc8AFO+/lFSWw6Yd5HXvNxx3XnO1gghW1eOgrY2tyxGsHP2 vHdKZ9Xa2YTSV6GkqtaUY+96KMC++26CXgZM1YYvQddsPVWBm4PNdV/jcfkCzbT+oC STlJEMnhT2gNA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 00/12] mm/damon: cleanup and refactoring code Date: Wed, 26 Oct 2022 22:59:31 +0000 Message-Id: <20221026225943.100429-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=1666825192; a=rsa-sha256; cv=none; b=QwPTflCDuR+esWF/aDYOU7tQAj+5alixK9x++2jGLLsW6WxPKBPYwD5+Ysck+j04uCdDjs j0jO6KS2ydYF9z+rUpiDgSMJevaagNxpdiF8/PTr0KazRjpAgx2KNANcGjEVlz9B+Bvq7V vYcpvsJDYJUMQdQ6ipKEtfJdgCtvlfI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QuZyRMU3; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.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=1666825192; 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=kboEvSiM5b5lZy4Ai7WQjYzWPxLprwOSxCDhDapZDHI=; b=tADS0GxDFQ6tROqHO5iBnn/SyahPVTaf/C2C6EDgqVEFhFrQ8H0ZhXrn0cOpqjJy6LgULm Qdl1+4hj1c76fhTyJauKQu/x+a3xuDSMW9HRLMzVGWG8JAnz9zRHoc7juVYjFySVr5AtaG se+gDUp7iREvMn8pkBYJ4JZX5YuTTNI= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 586E9140040 X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QuZyRMU3; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Stat-Signature: furamgpuiqdc8jiu9zfsoqb95ynpyd3i X-HE-Tag: 1666825192-331419 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: Changes from v1 (https://lore.kernel.org/damon/20221024204919.18524-1-sj@kernel.org/): - Add 10th patch, which splits schemes sysfs directory implementation 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-10). Last two patches (patches 11 and 12) 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 (12): 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/sysfs: split out schemes directory implementation to separate file 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 | 46 ++ mm/damon/sysfs-schemes.c | 1022 ++++++++++++++++++++++++++++++++ mm/damon/sysfs.c | 1152 +------------------------------------ 10 files changed, 1399 insertions(+), 1279 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 create mode 100644 mm/damon/sysfs-schemes.c