From patchwork Wed Oct 26 22:59:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp524865wru; Wed, 26 Oct 2022 16:02:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM51NizGC2WJPuAMtDyDoJQghrzpFzTpWIgcqzziK09DQknGzZSwUZYusaWBl59TMIt0aFTd X-Received: by 2002:a17:902:ce8a:b0:186:b051:1c8d with SMTP id f10-20020a170902ce8a00b00186b0511c8dmr15993168plg.82.1666825331474; Wed, 26 Oct 2022 16:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666825331; cv=none; d=google.com; s=arc-20160816; b=JDsDoWnq0KJjDtdoqBx+1xTbwdyrKgoRSwMdG7f3kvycLOa7A49Nj3BJpl255S69cS l0cCrgLg5nVOI1kHV/lGHJDlginNLpEFwAjVUIFIRz+5V8hslvNB9waQxzli5bEso+zJ FSCw7VvgKqsmX3Gz6xZ53joSCta59OwuJ+jdPiIvx2QBBFBVGAgdHKCfnX7UE9E35sHk B4D6cpTGgi4s5JVqpjHiWhhW/ZFgDAGV2ztizK9OVGGi2CzRcnMDkNmN1DKdVeRooZUi 6thgBbVJK6eBAwBZdAWVb1MgAb04D+Y2w6zcooHehn7b1/JrYlOo/FbMrqnv9k+6Rqj8 sSQA== 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=L28YNXLf0uhk0U/cHSmwPZeVXX1Fbjnp962qI+74q7Y=; b=HMBjIKbGtcd0kEBMe3/+fPjjdgXtJYCEqgB9r9j0Oqeb1c3w4XR4kBe6AMc2DYtho3 ia2BH+5XrmEYEJ3iMXemqQ+akLMxkJmo1T2racIsSMniDc0Xv8r1tTOCOe5L3zI8e7Nl HhrAYZtJV8eckOwHJ5ZSsfm3XSeSLQ/9T3FfOCo+RAMfR66wejkNV49Oj5quvMh5lnHO iRgWihDPuhETrm41mzitimn+UuejMTfRm755lydnETLrqdQ5kLVzHaQaEPlCTWPioBC1 Z0RmR0uqgukIH58Dav7vBNjig4h6UshoX0bCas4rB0q58oBYg4J615nyms9w8HEqa9FE tmwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MePX4QP7; 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 c3-20020a056a000ac300b0050d80e4935fsi9309160pfl.256.2022.10.26.16.01.58; Wed, 26 Oct 2022 16:02:11 -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=MePX4QP7; 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 S233301AbiJZXA1 (ORCPT + 99 others); Wed, 26 Oct 2022 19:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234003AbiJZXAA (ORCPT ); Wed, 26 Oct 2022 19:00:00 -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 5BF7B27CD0 for ; Wed, 26 Oct 2022 15:59:55 -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 274DAB80CA9 for ; Wed, 26 Oct 2022 22:59:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E743C433D6; Wed, 26 Oct 2022 22:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666825192; bh=8GL00RPKqf41iTTBqJzSvs8lE7BF3n/Dkon2+BFR2Rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MePX4QP7b/+bsXbvuYDWVKEzt8T7ttgcmo+ROEtbeepA6gq+RAYM+Hsv0n5MZf6HR fOoJ7LQbDBQ7v3IRo7/ROwd6lLUpT6cU9hRCtPe42QeE9yahzPn39o6qYY4HZAXszM WMjWy38qDWJp5lPr52IEJMiGkOi2vR3U/8zKGDomoHsUxjGV1Xms72lV21B8XHV2FX sCZZY9ZwHNRf3X1FJ+/hjUjSHcvpyLLbkxY6mRBWxWaVNLgPZ83mX+cCZkJCdMKZeA 2LIeGNczowR3Brpwwht3QTd/GBnbqwBhiftq+gGAm2xeLrCnxfnX73vg/VLhWky2Nb jHhgtItkwIP6g== 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 06/12] mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc() Date: Wed, 26 Oct 2022 22:59:37 +0000 Message-Id: <20221026225943.100429-7-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?1747793038514534541?= X-GMAIL-MSGID: =?utf-8?q?1747793038514534541?= '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 Signed-off-by: Andrew Morton --- 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;