From patchwork Wed Oct 19 00:13:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 4371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp48644wrs; Tue, 18 Oct 2022 17:16:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7eIJZ3v/gWJVUXja08GytBBI0cLzMOMmFGrRDoog5dusyC2ydV8rdHeEGlGTbBKgMZY5AC X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr4499408ejn.598.1666138570801; Tue, 18 Oct 2022 17:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666138570; cv=none; d=google.com; s=arc-20160816; b=RI2Yp6QuMWQ+btFnoq4PhC3WfQ5xUllvTgn4vldxOrBfflngkHl3RKm0ygD+uDCtT2 1HqqG3IhVta/QVoqMvZDimZIX/u+KKGwKH4jlnWbYT1Untg6K9xRGhXHvOJjQ3kM1p3M KMACSbdOqkpafSchOzHhRkTkdB8MUSVsEf7T1sjZqmLtP+aSPJpLHsm2Pjyozth/snFb g/Es9BbEg3sC13MqPlhmPw/SzFyfIeMbVyC48WfqH0NGXLc3amJyZfMH6KxUvmlK0sRC 57hWYtvDHxZwAb2GFvCHjH+AOETy2xqEgmXOq/lv8x2jUeTkXo0/VubVrfrAkniBDcJ0 1nEQ== 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=03ly8U/KAwHOuI8XWF1KHkMMfsjMuz58ZNQJDMju10o=; b=bexn4CptwJegGajSqQT0r/9ap4rAjp7ZPIa2WTGDg5xjLnAUqGbfYXxQZQ7Gr+iOmO Xuvu9BF02P70wRZYOpV88vecOc9bMn2d9DnloELLTN1m1BvZYrzA03do7JyCXHFk8Dm3 qccqezTomipHPW2ysgfxpoyQ1WNX3dsZgwa+uMT0Z6Zzfj8ob46VjVJt52C8p4lX31Z4 rSX5qN1vvmZYiyQTgjb5f84WMAvBvfClQs9+BZPVgHtwkMIWIGV1u2nImN2d6AgFzGDt wwvGiU5OhbWzFsPHl5uT45hguwkfwb6ETiv34OhEq/k91p4xgzUXMSydpaNmCfPiu+i1 SZqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jqdDiFtC; 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 m22-20020a056402051600b0045961c7dde9si11245262edv.63.2022.10.18.17.15.19; Tue, 18 Oct 2022 17:16: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=jqdDiFtC; 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 S229498AbiJSANv (ORCPT + 99 others); Tue, 18 Oct 2022 20:13:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229795AbiJSAN3 (ORCPT ); Tue, 18 Oct 2022 20:13:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 568A1D57D7 for ; Tue, 18 Oct 2022 17:13:28 -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 E48AD61739 for ; Wed, 19 Oct 2022 00:13:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03394C43143; Wed, 19 Oct 2022 00:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666138407; bh=ujSci3Jr9yWO8XdHXzr/zi1RpAlYDD3yaad0xsGDwtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqdDiFtCwIgZRauAibxFTY0xxMT21TP4sJWBZxuoXVCoBeOE/nUzDBSSKb/XDoolr H3hSh8l2G2xHPvF3K1Wcf/Yi8+zX88kHSAj0bc242eWmBspKXRxucRxMtRSqYKPaBY N7ahcK87QvjxtfusnABfcZ9nQcZ26u5nJwi/zxHvzTVOEwG/ojX+OKcnQvvrBwJcIy ONFBk8PmkaL3RjDbJCO5g051DKHayZL1Dvf4OMRKr7MITxJqMFNs+NBnLq39y3EXRE ZAeuYmtbGwiRmVaFB1xLiL9jy1IALkSv5U4bZxSHeqVVV22jSTGHSc0ToUcdMWPjFa n6IBUKynEQUGA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 08/18] mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc() Date: Wed, 19 Oct 2022 00:13:07 +0000 Message-Id: <20221019001317.104270-9-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747072918107402537?= X-GMAIL-MSGID: =?utf-8?q?1747072918107402537?= 'damon_sysfs_region_alloc()' is always called with zero-filled 'struct damon_addr_range', because the start and end addresses should set by users. Remove unnecessary parameters of the function and simplify the body by using 'kzalloc()'. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index b9183063bfea..e8bd7367d15b 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1065,17 +1065,9 @@ struct damon_sysfs_region { struct damon_addr_range ar; }; -static struct damon_sysfs_region *damon_sysfs_region_alloc( - struct damon_addr_range ar) +static struct damon_sysfs_region *damon_sysfs_region_alloc(void) { - struct damon_sysfs_region *region = kmalloc(sizeof(*region), - GFP_KERNEL); - - if (!region) - return NULL; - region->kobj = (struct kobject){}; - region->ar = ar; - return region; + return kzalloc(sizeof(struct damon_sysfs_region), GFP_KERNEL); } static ssize_t start_show(struct kobject *kobj, struct kobj_attribute *attr, @@ -1184,7 +1176,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((struct damon_addr_range){}); + region = damon_sysfs_region_alloc(); if (!region) { damon_sysfs_regions_rm_dirs(regions); return -ENOMEM;