Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp252025rwi; Tue, 18 Oct 2022 17:17:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73lK4CnWuebwJR3Io29QkWuiID7fmgzc/rqggo0oqJzvNFXNelVr55ekxpZwHK9Nh3t7WN X-Received: by 2002:a17:907:3181:b0:787:d81c:a6ad with SMTP id xe1-20020a170907318100b00787d81ca6admr4488146ejb.769.1666138621698; Tue, 18 Oct 2022 17:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666138621; cv=none; d=google.com; s=arc-20160816; b=oTmHZuhuT/tHk/X+Zco88WQ93QAcI3fXG64i1zqNLrD4f5MdGXfVm5IbuDcV0i5g9Q GldfCktgO5TD4bdWc7rN44j5m+XFQ89aq8kSWal/pe29bRRCzUOTx+Q4rnWoSDFwkJKw SWSvdkTouJHERTSF4JV48IhFMJDOgf9qBT4wEQacWH7L49g9YPIM2y0VkOVW6VcXRM0g hpqVwHR22zZiJ28mTQB2NyeIlJV4Lg9VHkGr1rjzs14Jl2jUXlMQFQF8OvM3Hh41BYPg 6Sprrdc3DOpdaNG8xFEQCu/hLva8aILK9P07p8ssQTTk8SxvbPD8KhoNJ9+D2BXMahzI RXOg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q60uXh1pTpQ/fOpuvqR7hV0JaV42pVNGpZx81icpqzo=; b=JNsSAg3IidZ2/DXsiFdQNsuKDXoWOIztSFxBhzNVx9Lf0zyZpuUWhkhHFoda+zuhDF YBxHNLtN4yPojgfia8pZONGCR8UQ36iEznLIKbUZreRBk6Kki9Etd3SH/BfgXB/wfmMD 0gNi+ezZnHXZmOEf7MQzBy8BZAE/bxtyRXbVbq1+jQLEvTK1OMjjldMT3M5K9Ln/fwur qRl56E/EZu9LAHKnM3bpt7msq8ZJJG2vyv5FQUioumRzcj12DsyGfMnHp2gqk62bAb5L jwnG/jg7G2jmUqq9cFTQFNyLE0Z/KqrL3TW/4DfV19zKsvX7/JklmYpNGPUqdqIQbDBP jNLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o8CVgNK3; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gr1-20020a170906e2c100b00782069599b8si11780345ejb.379.2022.10.18.17.16.34; Tue, 18 Oct 2022 17:17:01 -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=o8CVgNK3; 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 S229893AbiJSANz (ORCPT + 99 others); Tue, 18 Oct 2022 20:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbiJSANb (ORCPT ); Tue, 18 Oct 2022 20:13:31 -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 AB0C4DAC64 for ; Tue, 18 Oct 2022 17:13:29 -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 46F29B821AD for ; Wed, 19 Oct 2022 00:13:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E7D2C4347C; Wed, 19 Oct 2022 00:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666138407; bh=tOOj3luO+EygOYDe7o6HDFHzEbK5aAH6Idm+S6DN7zQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o8CVgNK3brAMUD+ttc9PFIAJCJF15RsAnjfYfdqncoOCdrXuKGUv569s/TN+VHtHH WF1GwmWMLD2cixTMKMlqaTaUexsscFQeOmFv3YCA8YTioCVdZIwKl+PrfEDs3+lykd ZeyR0i+dpsKsYndu2BGECAuD+TI7FXiEwzXAkXZJJIXzwrB+ykqJ9PjgxZHl2vYedo qtmRxw+Q80/EO3o6erYGxv8mBq0Z9ehl84G4o3wYKiy1qsxuMs7i7xGoHdG9x9UQyZ +KSSFc8+1G6IqqsJTePgxUOv+pUz+PezWbyJaV5BRMEeZ0EhezXd1xtJYG3a9R15q3 sQ9+2x+JMorig== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: linux-kernel@vger.kernel.org, damon@lists.linux.dev, linux-mm@kvack.org Subject: [RFC PATCH 09/18] mm/damon/sysfs: move sysfs_lock to common module Date: Wed, 19 Oct 2022 00:13:08 +0000 Message-Id: <20221019001317.104270-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019001317.104270-1-sj@kernel.org> References: <20221019001317.104270-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 DAMON sysfs interface is implemented in a single file, sysfs.c, which has about 2,800 lines of code. As the interface is hierarchical and some of the code can be reused by different hierarchies, it would make more sense to split the implementation into common parts and different parts in multiple files. As the beginning of the work, create files for common code and move the global mutex for directories modifications protection into the files. Signed-off-by: SeongJae Park --- mm/damon/Makefile | 2 +- mm/damon/sysfs-common.c | 11 +++++++++++ mm/damon/sysfs-common.h | 11 +++++++++++ mm/damon/sysfs.c | 4 +--- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 mm/damon/sysfs-common.c create mode 100644 mm/damon/sysfs-common.h diff --git a/mm/damon/Makefile b/mm/damon/Makefile index a076ccd55d44..50d6b2ab3956 100644 --- a/mm/damon/Makefile +++ b/mm/damon/Makefile @@ -3,7 +3,7 @@ obj-y := core.o obj-$(CONFIG_DAMON_VADDR) += ops-common.o vaddr.o obj-$(CONFIG_DAMON_PADDR) += ops-common.o paddr.o -obj-$(CONFIG_DAMON_SYSFS) += sysfs.o +obj-$(CONFIG_DAMON_SYSFS) += sysfs-common.o sysfs.o obj-$(CONFIG_DAMON_DBGFS) += dbgfs.o obj-$(CONFIG_DAMON_RECLAIM) += modules-common.o reclaim.o obj-$(CONFIG_DAMON_LRU_SORT) += modules-common.o lru_sort.o diff --git a/mm/damon/sysfs-common.c b/mm/damon/sysfs-common.c new file mode 100644 index 000000000000..9dc743868d5b --- /dev/null +++ b/mm/damon/sysfs-common.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Common Primitives for DAMON Sysfs Interface + * + * Author: SeongJae Park + */ + +#include "sysfs-common.h" + +DEFINE_MUTEX(damon_sysfs_lock); + diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h new file mode 100644 index 000000000000..745a918b94f5 --- /dev/null +++ b/mm/damon/sysfs-common.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Common Primitives for DAMON Sysfs Interface + * + * Author: SeongJae Park + */ + +#include +#include + +extern struct mutex damon_sysfs_lock; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index e8bd7367d15b..0f3f06d8dae7 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -5,13 +5,11 @@ * Copyright (c) 2022 SeongJae Park */ -#include -#include #include #include #include -static DEFINE_MUTEX(damon_sysfs_lock); +#include "sysfs-common.h" /* * unsigned long range directory -- 2.25.1