From patchwork Mon Sep 19 15:12:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12980588 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 D9AC0C54EE9 for ; Mon, 19 Sep 2022 15:12:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6365180007; Mon, 19 Sep 2022 11:12:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BC1D6B0072; Mon, 19 Sep 2022 11:12:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45DED80007; Mon, 19 Sep 2022 11:12:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 31E556B0071 for ; Mon, 19 Sep 2022 11:12:16 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DA4D2403C2 for ; Mon, 19 Sep 2022 15:12:15 +0000 (UTC) X-FDA: 79929175830.28.758A2A4 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf13.hostedemail.com (Postfix) with ESMTP id EB0472002C for ; Mon, 19 Sep 2022 15:12:14 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VQEvWFT_1663600327; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VQEvWFT_1663600327) by smtp.aliyun-inc.com; Mon, 19 Sep 2022 23:12:08 +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 1/2] mm/damon/sysfs: remove unnecessary variables Date: Mon, 19 Sep 2022 23:12:00 +0800 Message-Id: <20220919151201.66696-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663600335; a=rsa-sha256; cv=none; b=jFOJkPceBqeYYPgk9p0M3nol+7zYT53GsuFyqD9Kazvf/9d2XoGsDVRoOtBdi2gciOHFBg iKjnXPRvZMJAgQS4DuzCUaZ7MqZ5C5L0tqI5s3Eav1MtEtFD+HWxYRc0PVFIVK5HPz4F9J gc8+w0Gsnj9FSbWHP8ZrbAJWTOQlrKk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663600335; 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:references; bh=6kXjt9klxOIJxkIvtVJsSintQwVu+1ck8KoWsUDYBGo=; b=JdFiV0O/ok3+xcy7OYJB+IJidta7HIBmcXG1bbKPBEz7o8MeAng+4vnGsvhc/VPSCKadsw /TW9RhRYiovsuh+DuY7NA0YG0w6NAA4ZYzVQAKnaCDZPBjTEDLf/sDZ3uA0KXLpGdUEqLp ECY2QTaVq5Xyr3aDnDYgpsu/8VxYrHo= X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EB0472002C Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Stat-Signature: ym1z7mg5j7b4j6399gdd7jt6s97xp54j X-HE-Tag: 1663600334-953740 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: Just do a little change here, the 'err' variable really no need to stay here. Signed-off-by: Xin Hao --- mm/damon/sysfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.31.0 diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 0cca1909bf67..b852a75b9f39 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1109,9 +1109,8 @@ static ssize_t start_store(struct kobject *kobj, struct kobj_attribute *attr, { struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - int err = kstrtoul(buf, 0, ®ion->start); - if (err) + if (kstrtoul(buf, 0, ®ion->start)) return -EINVAL; return count; } @@ -1130,9 +1129,8 @@ static ssize_t end_store(struct kobject *kobj, struct kobj_attribute *attr, { struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - int err = kstrtoul(buf, 0, ®ion->end); - if (err) + if (kstrtoul(buf, 0, ®ion->end)) return -EINVAL; return count; } 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)