From patchwork Mon Oct 24 20:49:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp683888wru; Mon, 24 Oct 2022 15:36:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4FxsuNdmO1tuIRD2hdQPNDuVIKcqP/e1uP75e9l/14tpzMBFgG469il9EwCeOBuMSt4mpQ X-Received: by 2002:a17:907:70b:b0:740:ef93:2ffb with SMTP id xb11-20020a170907070b00b00740ef932ffbmr29128636ejb.93.1666650962213; Mon, 24 Oct 2022 15:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650962; cv=none; d=google.com; s=arc-20160816; b=mDz+g9lNIJz6RZdLB46/w5Ztemo9FrdKJxlO3arhgWn07gMp/24dl5Zg0KBN66i92X ftO4WGJ6N/JYUddOio8ruriZgVF6jC0xYw4i6k/gOdjG1FOTm13xx919hG8bosxrb4eQ iS4gU50G76RM/d7+Yuj6fUhJXXom7+Vi+diDIm/K3vj4daedxD83691q9fhVrcEcK06r L6LuXSr/1lpXGskWnIf7mIJTZaPhaIYSLgNUj+7DT/xS1hnJs7ESRoYSJlJnr9Tk2qAM 3rlWonIGS+LXdkRVw/sbdYS9eI2JjHMgJP1UXKQzOD/4ZnMd/WSiKMzFwd6vp1uVlEP+ HnJw== 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=mr90G6ZMuhnsX/SfPy3lt8a8rjK7AgwVrTpEY47GZ4gZVaJmS4c1m2qCqxx8GkL0Tw M/0jZ1yC/YCNkKvG2DESismCzOifyso6lo+N64GQmLNC0yv8BpJdVvy44BhkDaHO5LXC dQp8C6eqwhP1eRvNEK3gY+tuyoBOB7ncfebSQH7OQ1wD+XRoEqh5AIeT98oFCdje5noT SHZWpmFFzyltXdCV1hhZmKOMpJaO3tN0G/j/eVh53/zwq9k85guvSEM3qG9rZEzLn0LP w1Vywr92Grpp4h+eCj+k2TapzG7CP9oYnOP23BeGU0j/Rx8eKJN49i1Q3aQ1mQUgKe2n lILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G0PNJwF7; 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 cf14-20020a0564020b8e00b00461dbe292e0si775835edb.270.2022.10.24.15.35.38; Mon, 24 Oct 2022 15:36:02 -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=G0PNJwF7; 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 S230493AbiJXWdj (ORCPT + 99 others); Mon, 24 Oct 2022 18:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbiJXWdT (ORCPT ); Mon, 24 Oct 2022 18:33:19 -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 78AF12BE880 for ; Mon, 24 Oct 2022 13:56:12 -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 D3772B811FB for ; Mon, 24 Oct 2022 20:49:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C5A2C433D6; Mon, 24 Oct 2022 20:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644568; bh=ujSci3Jr9yWO8XdHXzr/zi1RpAlYDD3yaad0xsGDwtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0PNJwF7F8B6wDCT8U5OvUuUzVBgp8YQ/xYp56NtYF3J+apq8tV363lbDS/dAVE9x fmE1KhGzme+66U40xnPxhCiGER08YnmCVpFOOoXzMNwJdsHg9XkhE0h2IglBKku8Qk 0R3GZqSNZtFaMKpOjz9jv3aamgzvzty7b1BBMqBiUTBM5Z3QCKDU2LJ1lVnuJfzih4 YiMPbVNMnUXZTngRymS02lmsG8cD41erv/DtQA2mKokmw5y+4FXwKDV4hBH/tUKLJY 2YNKfkUPrm/R4hseLEskL/AinkQdMCyRdNeV3Gza0l5JxjrTscQ6MhU4BaaSFDNiXW zkY/9xpZ6LDRg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/11] mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc() Date: Mon, 24 Oct 2022 20:49:14 +0000 Message-Id: <20221024204919.18524-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-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?1747610199453836543?= X-GMAIL-MSGID: =?utf-8?q?1747610199453836543?= '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;