Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2671623rwb; Mon, 19 Sep 2022 08:19:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM55WQQ5LCptCJdV0dzvrfnPAdjCw72XIfFpUZwUbqYS6FExXjCqBil1k0NAPSGrSzA9LU4i X-Received: by 2002:a17:903:2015:b0:178:8022:ff1 with SMTP id s21-20020a170903201500b0017880220ff1mr291007pla.18.1663600754752; Mon, 19 Sep 2022 08:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663600754; cv=none; d=google.com; s=arc-20160816; b=d3R4yAKuVYRPKtYPPyCIWUptw0jAZ8qKq38/JqWVVKzQR6C2u6mBtJ/B0j8+qncHNh ky+23yLWD4fpk4n5OWuN97+dkftm1vrATyzyIcezBmjQIw5hPGbgpPlLaHYq8Y+8tM3S RAltXAoSf0QgrM6DpS2KfyOJ9qRl0Q4A9zyh06AYrDW28/8HByZuSZ5las+vzL01vTs2 Aoy6u4/plh0BivB4xDSSYdPEIgjYNAMidaHattjtH3DKuG04Mu2x8SLodqghRr0zD1lw xybIXqgtyuI11zM88FkF9H0bFnOgPfWH61fWPDnAlZp1iRlsZ+YkQIoG+tk8hRHXbGnK r1PA== 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; bh=ptbRmzNkJq2GuKmvanz1Gic4BWOox2JIZqkfbv4Q6ok=; b=sksaoqHlnef1bI4WDCif1c8ycuP6UL5M87iah9zFZm6X2Zva7JP6udWwm+HS6h/Opp QPwJVxH2S0QtzM2aldwGgSD2BALZrNmoP1Oqws4DA6wmlso2kbf56Ojt1D7uvBO0LAkR IZo8Gux6c6qgGNkmwlvnKSE6+qOYLCdKh+4A59D6EIYcQSY5kACg17OPb0P90lyRqhDa A6LruXZRTdA6ilP3yx/4sfoRlwHQz7mEMs4kASHQ1w8iqI96EaFnjmEhDvytcDhQEtNN V6NVZo03OFu5WfxnkSno5NNyP/tNTA30gh2xZQy6L+ka47Cj1o6KBxgkrSfou0su7dG8 CZQQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bn4-20020a056a02030400b0043961fad9f5si10233193pgb.461.2022.09.19.08.18.59; Mon, 19 Sep 2022 08:19:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbiISPMR (ORCPT + 99 others); Mon, 19 Sep 2022 11:12:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbiISPMO (ORCPT ); Mon, 19 Sep 2022 11:12:14 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62C1B2A734 for ; Mon, 19 Sep 2022 08:12:13 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 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) -- 2.31.0