From patchwork Wed Oct 26 22:59:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11474 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp525038wru; Wed, 26 Oct 2022 16:02:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7nsxMiesPyfDSsM35G+OX1Tb7XwsjJu/OG3bAqwFco3CX+H0cGLV5X9fp3JJ/vdCO+KjXu X-Received: by 2002:a63:4a53:0:b0:439:3c80:e053 with SMTP id j19-20020a634a53000000b004393c80e053mr39443069pgl.3.1666825349125; Wed, 26 Oct 2022 16:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666825349; cv=none; d=google.com; s=arc-20160816; b=ssZL5a5qzukqT6j2UMYnGC6zU8I4YDP/1Y2ZKhulu0quhwQyUvAwUuNRSdgEJOlzbj OgeMu/Sa1PnfKb1LQwsRSOioLap258r4YKMBGBrO5umlmgiZ494ob9Nu+phzezT3RWDE FoUWO3nbeI2dVOf/hY9UumqGyz9ZnlpHSJf7JZtAfdpekgGixIsxolzYTIyYIRvjPgNS POrQfoI8cxI2UkKPzfzX+cw6hmRvQdEcyrX0Vgm2UIviNDxSJm+olDbVgFziM9d8LxDH 8aZz/dnz5SkFSiuZgaGApM4sdW+5ZSwK2P3V3M1YEGzqIH2nKv9Y6TMzdKcEWFuA72qM 8Jrg== 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=ZTtZYN5Tjj+kqV/qO73E+myXwvSzWSW2PRPjRDUDwaY=; b=IsO7VasqB1hb2y0DlM32URyzxW2Z/Is07WzyUoKzY/QXzgU4SC9Sz3hKegSa64+hs9 TvAdaqW0RhW6akQjmVJLqtSEHxFQNEATwIJBzrfZc9zudZ+7zIAWaGTazuKnAntK8C/0 ZUT+I/+/Ki/XQkEGhZLJDSFL6W8q+5OZDjVi267qIgAaVXapsdAaLnjIyDDqiFYx2SQq JRLcfByZD4oHFo0avYC+uzaxteXvNGZQZUwSIPxzi9/mOsaayB5EV8CK3eim4kzrkJvA 95W/t0447IK9eP591UJAoQTNx1JiHI8paOEzfc4+UA0KQcPLZWziddXYYMY71/UvlueE HLZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mdx99LlU; 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 z12-20020a170902708c00b0017b977d1b7bsi7335317plk.32.2022.10.26.16.02.15; Wed, 26 Oct 2022 16:02:29 -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=mdx99LlU; 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 S234071AbiJZXAj (ORCPT + 99 others); Wed, 26 Oct 2022 19:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234008AbiJZXAA (ORCPT ); Wed, 26 Oct 2022 19:00:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C17227CD6 for ; Wed, 26 Oct 2022 15:59:54 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 092AD620C8 for ; Wed, 26 Oct 2022 22:59:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 154F0C4347C; Wed, 26 Oct 2022 22:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666825193; bh=LA5eSTlkkTuiqSOiZ/+/4cpBqjOUioigu0cyIQgAlG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mdx99LlUzYMWJi74isWfMCDiXyKcMKzijAHikjv0jWN8tI7zmyTSk1qW93l74h7Lb hsze/eZTlUpzQ62rz+WlvSlBzeG41W0gpPTx1sZznMrvnYEctzRT4zEukhbOkox3C0 pQXbJ+Lcjlkfoo4DgHEmsNEg0RIWmJqmyqJehfjkcZKOySeSyjy6zYBU9p7OR/tAut Co/Mk7lwUXr8bg8A5h3Eca1kBzGeOlkpjSHBazNz9OzYx95ewoCNEBMbxEhnTGfjYz YEY8vXwy8jF9sDchZoVxNkA8Z2lgzPn/OxCyvhVJPWDyEbtXe0Maj+O9ZPWlEwBBRv P+DCd2ogTB6IA== From: SeongJae Park To: Andrew Morton Cc: linux-kernel@vger.kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, SeongJae Park Subject: [PATCH v2 07/12] mm/damon/sysfs: move sysfs_lock to common module Date: Wed, 26 Oct 2022 22:59:38 +0000 Message-Id: <20221026225943.100429-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221026225943.100429-1-sj@kernel.org> References: <20221026225943.100429-1-sj@kernel.org> 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?1747793057100484225?= X-GMAIL-MSGID: =?utf-8?q?1747793057100484225?= 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 out 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 new file. Signed-off-by: SeongJae Park Signed-off-by: Andrew Morton --- 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 3e6b8ad73858..f8d535a6253b 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) += reclaim.o obj-$(CONFIG_DAMON_LRU_SORT) += 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