From patchwork Wed Oct 26 22:59:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13021334 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 84B16FA373D for ; Wed, 26 Oct 2022 22:59:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B14F8E0007; Wed, 26 Oct 2022 18:59:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33B268E0005; Wed, 26 Oct 2022 18:59:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEE9B8E0008; Wed, 26 Oct 2022 18:59:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C17D88E0005 for ; Wed, 26 Oct 2022 18:59:53 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8AE99160FF4 for ; Wed, 26 Oct 2022 22:59:53 +0000 (UTC) X-FDA: 80064619866.29.D11EDE9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 22FF540022 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 dfw.source.kernel.org (Postfix) with ESMTPS id 76088620C8; Wed, 26 Oct 2022 22:59:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3802C433D7; Wed, 26 Oct 2022 22:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666825192; bh=nH2ArlwknM/y/vBnmfj0ga+qKqYuQNWCJAYIWsSWxEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sh/w0gDPKBDZTvj3PeoKX95hmST7DK0fwtYMFgGoV74D2d7W70BPXmc5pMvr5UQYX 75wYdCxnWco7u/YfNf1FDOAhTvd/pPYEyDStO6ND3y32bPM7xos/FuOjTVPu4Mq9jw VlgS34XwFctaQ3C1VZOMt4M9/K/iqHjhh49PhbCDOJBlf5Ky0Qvo6Shgse1SNLhQkE NPvv5qeOaWtv96IkHUVp6wO8/mxvZWRKhx0FGNnx/4TjLZEoOVxAKJkjKuFqgEpTRr T1meIpTeo4BixfYNRNbL/nciUQg5bNB8rUc2rjDrp1IcPFxpHNcsBzPCflEloIyx8s hxg/wLJ1Vo2DA== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH v2 05/12] mm/damon/sysfs: use damon_addr_range for regions' start and end values Date: Wed, 26 Oct 2022 22:59:36 +0000 Message-Id: <20221026225943.100429-6-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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666825193; a=rsa-sha256; cv=none; b=ak1LxmbMGPkZ043g/sYMfwRPe+Rtt+S0CH7vF3aqs2oZrbvyj2vB59nh4ujw5jtGqZ8r+n MYtz4mhoAyd9t9dqlnMRx7/Lwo/OAcwwsWhrmsULXBfRyHhKOUC1Ev4slWPNlWwcGzC0Ss 1pIGsQrZQa2e7CZC0fvjutLgMNqErqI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="sh/w0gDP"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1666825193; 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:in-reply-to:references:references:dkim-signature; bh=q5+A7BAbL60kyU7PSyW160QAGWB8rjXk/E6rfxLrtGI=; b=Gx/DUZcI3Xp2oc7hu3sgBsrqvglj7flMi198351SIwkDDPnRuYntgtVMdHmpV3bdxbp17E rPjccak5AdmK4URc6XT13x8rPe0QYe4kGY09zHDuGQS2yk4k36NyioQ7J3W1KSsNLwY4ST VzltOBmXpaLqvcULRSsU52ifzu0yqq0= X-Rspam-User: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="sh/w0gDP"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam11 X-Stat-Signature: j4di9cwgcan6eir3gqhoc68owbb1399i X-Rspamd-Queue-Id: 22FF540022 X-HE-Tag: 1666825192-779284 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: DAMON has a struct for each address range but DAMON sysfs interface is using the low type (unsigned long) for storing the start and end addresses of regions. Use the dedicated struct for better type safety. Signed-off-by: SeongJae Park Signed-off-by: Andrew Morton --- mm/damon/sysfs.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 9f1219a67e3f..b9183063bfea 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1062,13 +1062,11 @@ static struct kobj_type damon_sysfs_schemes_ktype = { struct damon_sysfs_region { struct kobject kobj; - unsigned long start; - unsigned long end; + struct damon_addr_range ar; }; static struct damon_sysfs_region *damon_sysfs_region_alloc( - unsigned long start, - unsigned long end) + struct damon_addr_range ar) { struct damon_sysfs_region *region = kmalloc(sizeof(*region), GFP_KERNEL); @@ -1076,8 +1074,7 @@ static struct damon_sysfs_region *damon_sysfs_region_alloc( if (!region) return NULL; region->kobj = (struct kobject){}; - region->start = start; - region->end = end; + region->ar = ar; return region; } @@ -1087,7 +1084,7 @@ static ssize_t start_show(struct kobject *kobj, struct kobj_attribute *attr, struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - return sysfs_emit(buf, "%lu\n", region->start); + return sysfs_emit(buf, "%lu\n", region->ar.start); } static ssize_t start_store(struct kobject *kobj, struct kobj_attribute *attr, @@ -1095,7 +1092,7 @@ static ssize_t start_store(struct kobject *kobj, struct kobj_attribute *attr, { struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - int err = kstrtoul(buf, 0, ®ion->start); + int err = kstrtoul(buf, 0, ®ion->ar.start); return err ? err : count; } @@ -1106,7 +1103,7 @@ static ssize_t end_show(struct kobject *kobj, struct kobj_attribute *attr, struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - return sysfs_emit(buf, "%lu\n", region->end); + return sysfs_emit(buf, "%lu\n", region->ar.end); } static ssize_t end_store(struct kobject *kobj, struct kobj_attribute *attr, @@ -1114,7 +1111,7 @@ static ssize_t end_store(struct kobject *kobj, struct kobj_attribute *attr, { struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - int err = kstrtoul(buf, 0, ®ion->end); + int err = kstrtoul(buf, 0, ®ion->ar.end); return err ? err : count; } @@ -1187,7 +1184,7 @@ static int damon_sysfs_regions_add_dirs(struct damon_sysfs_regions *regions, regions->regions_arr = regions_arr; for (i = 0; i < nr_regions; i++) { - region = damon_sysfs_region_alloc(0, 0); + region = damon_sysfs_region_alloc((struct damon_addr_range){}); if (!region) { damon_sysfs_regions_rm_dirs(regions); return -ENOMEM; @@ -2147,11 +2144,11 @@ static int damon_sysfs_set_regions(struct damon_target *t, struct damon_sysfs_region *sys_region = sysfs_regions->regions_arr[i]; - if (sys_region->start > sys_region->end) + if (sys_region->ar.start > sys_region->ar.end) goto out; - ranges[i].start = sys_region->start; - ranges[i].end = sys_region->end; + ranges[i].start = sys_region->ar.start; + ranges[i].end = sys_region->ar.end; if (i == 0) continue; if (ranges[i - 1].end > ranges[i].start)