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: 614 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp683939wru; Mon, 24 Oct 2022 15:36:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6AD9x5ItJaFGFUiNCg9KqWJDNFnOQc6OwAK1Q5JFIDmit/EVdEcBH1lvZJYLLGnkQu/rFI X-Received: by 2002:a05:6402:40ce:b0:461:b253:c22f with SMTP id z14-20020a05640240ce00b00461b253c22fmr8321272edb.199.1666650970840; Mon, 24 Oct 2022 15:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650970; cv=none; d=google.com; s=arc-20160816; b=L//CB5to0JYjcJ8c6fgO5BUiKmulNC69bPH2nCrH9qfRvIYuORxaRHAJXb4qSIEJci 9q6d3TMOJUUaDFVm/XeQAiDLLYVWmvj/0UBwgALxy0tZ9/K6duwTumbxvW/thGqjNZ+h ylAjcTjC9PHcaPov4qOgmKp7PeaXSbMul6GpY1gOdXDPQ6OgiQJhVq4EDzyGxM32dhAA iA35tqauU5cRlHAlpJFIUwTA1HaZVfNFqxTPU1wJX2sz6YlddeL9lzvDUnoySy33Oscg e3Ohw48Lc9IE0aJHgwli9I/DpQiVG4atoRlpFZSYNfo/jyCJSi0RgYctkS8jC1Q5b83W xLXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=VyaX3wCE5rGoYljuNDd5yl9k02NTvPyw9gYQ9qKULj4=; b=FTTl/u8rf0if/l3kAwNzhFBAR9/xg1hsCN96xlPjfu8JUCde79TVsG2Iaierxo8vCL 3iwVqQqgWDBG0hSYRpAUaE4vnc8rMC38K7vOnFAwbAd4X3vH922NabwK8nrO3/wDbQS5 6xjx2cCKyY2RDLjuAJdFzlu79QUcTzYyDAeTbBirfIaCMfLg+5goWTIlzp1vcCclMsvF AGTa8wbHHb6PjlF4k92jW0AJoz8COWh9bL1V7CSYTvC5gr3qoJAcMj9kFd/0yAXtj1gT CxNWNo5+5SpIYyNx+cNamW2ZL0pBNVnEQAHVrTF6NwOKrWqspByI22UiYZX0xdJt4mvS x4KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WIZ16QyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m21-20020a170906721500b00782e9b7305dsi779567ejk.266.2022.10.24.15.35.47; Mon, 24 Oct 2022 15:36:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WIZ16QyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbiJXW3m (ORCPT + 99 others); Mon, 24 Oct 2022 18:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231365AbiJXW2n (ORCPT ); Mon, 24 Oct 2022 18:28:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FECF16727B for ; Mon, 24 Oct 2022 13:51:05 -0700 (PDT) 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 3EDBEB81212 for ; 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 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610208326172881?= X-GMAIL-MSGID: =?utf-8?q?1747610208326172881?= 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