From patchwork Mon Sep 19 15:12:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12980587 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 15BFEECAAD3 for ; Mon, 19 Sep 2022 15:12:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34CCB940007; Mon, 19 Sep 2022 11:12:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FD396B0072; Mon, 19 Sep 2022 11:12:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1ECB0940007; Mon, 19 Sep 2022 11:12:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 105376B0071 for ; Mon, 19 Sep 2022 11:12:15 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D7CF7C019F for ; Mon, 19 Sep 2022 15:12:14 +0000 (UTC) X-FDA: 79929175788.24.A322A1D Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf03.hostedemail.com (Postfix) with ESMTP id DBCD7200A6 for ; Mon, 19 Sep 2022 15:12:12 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R511e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VQEvWGD_1663600329; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VQEvWGD_1663600329) by smtp.aliyun-inc.com; Mon, 19 Sep 2022 23:12:09 +0800 From: Xin Hao To: sj@kernel.org Cc: akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xhao@linux.alibaba.com Subject: [PATCH v1 2/2] mm/damon/sysfs: use kzmalloc instead kmalloc to simplify codes Date: Mon, 19 Sep 2022 23:12:01 +0800 Message-Id: <20220919151201.66696-2-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220919151201.66696-1-xhao@linux.alibaba.com> References: <20220919151201.66696-1-xhao@linux.alibaba.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663600334; a=rsa-sha256; cv=none; b=p2+7DBWNJoSGQMePFeNKrlDITiAMeORng3jAS8gYsGPrLJaxOuHYho/R3rFITwbeXRqU3b WvoDx9T65FLHRV2A4JVOuv3XRANnPCeG62AJS5ue5EvGW6JYx0pPPHfSEYu6PYXesddfuD HdiEhMTnb6aKwSg3LZR8AuWaZDgb6hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663600334; 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; bh=ptbRmzNkJq2GuKmvanz1Gic4BWOox2JIZqkfbv4Q6ok=; b=aUYtWmW8PXr9VuQa0HEylFDroNmMPIlu6AL7svbd/ERyGGUR/K/w2y6FCFd4uT/JGqY26b gHe9oTe1upiUJ25/auLcZ3Et1GgrMaf/SNtJt9Gl8Ez1TQCnavG5cdQJOpq5vp04fkyLic 2IskmQjafSJDsTwTMDolwFER6MAODF8= Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Stat-Signature: 53b51a45sg4kq41txtc81n6a7qrzrczi X-Rspamd-Queue-Id: DBCD7200A6 X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1663600332-791955 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: In damon_sysfs_access_pattern_alloc() adn damon_sysfs_attrs_alloc(), we can use kzmalloc to alloc instance of the related structs, This makes the function code much cleaner. Signed-off-by: Xin Hao --- mm/damon/sysfs.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index b852a75b9f39..06154ece7960 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -657,13 +657,7 @@ struct damon_sysfs_access_pattern { static struct damon_sysfs_access_pattern *damon_sysfs_access_pattern_alloc(void) { - struct damon_sysfs_access_pattern *access_pattern = - kmalloc(sizeof(*access_pattern), GFP_KERNEL); - - if (!access_pattern) - return NULL; - access_pattern->kobj = (struct kobject){}; - return access_pattern; + return kzalloc(sizeof(struct damon_sysfs_access_pattern), GFP_KERNEL); } static int damon_sysfs_access_pattern_add_range_dir( @@ -1620,12 +1614,7 @@ struct damon_sysfs_attrs { static struct damon_sysfs_attrs *damon_sysfs_attrs_alloc(void) { - struct damon_sysfs_attrs *attrs = kmalloc(sizeof(*attrs), GFP_KERNEL); - - if (!attrs) - return NULL; - attrs->kobj = (struct kobject){}; - return attrs; + return kzalloc(sizeof(struct damon_sysfs_attrs), GFP_KERNEL); } static int damon_sysfs_attrs_add_dirs(struct damon_sysfs_attrs *attrs)