From mboxrd@z Thu Jan 1 00:00:00 1970 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 5EB04C32771 for ; Wed, 21 Sep 2022 05:20:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93FDD6B0072; Wed, 21 Sep 2022 01:20:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EF9C6B0073; Wed, 21 Sep 2022 01:20:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80645940007; Wed, 21 Sep 2022 01:20:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 71F5F6B0072 for ; Wed, 21 Sep 2022 01:20:28 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 49FD5805CF for ; Wed, 21 Sep 2022 05:20:28 +0000 (UTC) X-FDA: 79934942136.30.6575C19 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf14.hostedemail.com (Postfix) with ESMTP id 9801510001D for ; Wed, 21 Sep 2022 05:20:26 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VQMWsxm_1663737621; Received: from 30.240.97.89(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VQMWsxm_1663737621) by smtp.aliyun-inc.com; Wed, 21 Sep 2022 13:20:22 +0800 Message-ID: <09ddb8f0-9ea3-2dd0-fa77-430ff3380f85@linux.alibaba.com> Date: Wed, 21 Sep 2022 13:20:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v1 2/2] mm/damon/sysfs: use kzmalloc instead kmalloc to simplify codes To: SeongJae Park Cc: akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220920162542.52554-1-sj@kernel.org> From: haoxin In-Reply-To: <20220920162542.52554-1-sj@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.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=1663737627; a=rsa-sha256; cv=none; b=zmkEwVt9LXvB8isFGudQAxIoAVgUAqQr9RxXdjbG3VRuArgLi/taS8cDNLqoANSpUiSNXM DlbVB0sAe9TnXHLN348moBQkrrr61dVkLAZvF+axZpOPTkYy1nSUNJRRT8NWW6a86SGbw/ kClDvVGWESxk1s7+RiRcrq2mmJvCDV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663737627; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CbtFEWkCfMa/mTH5Rce1fGF7acsLQSY/DmwIMnKE9sU=; b=saj0moOyAcRjrYzf3UilAydrHvm8F3CtQKSvfu4txJM+QeCdySGLzLO3ei/W3LzFIxZ5Gw puBgJLsXPQIWEats8EcMvck9QTI3eqbIEaWxPurRtWyf11IUifWT9xTLgmjzNeL7fqSkYj ok4oIxUP1NwLMfeM9JB1olmZGgz7BS4= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9801510001D X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.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: endn6qixmsdaf38q6tqpo1y6qegeuywq X-HE-Tag: 1663737626-843706 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: 在 2022/9/21 上午12:25, SeongJae Park 写道: > Hi Xin, > > On Tue, 20 Sep 2022 09:58:41 +0800 haoxin wrote: > >> 在 2022/9/20 上午1:22, SeongJae Park 写道: >>> On Mon, 19 Sep 2022 23:12:01 +0800 Xin Hao wrote: >>> >>>> 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. >>> This definitely makes the code cleaner, thank you. But, the initial intent of >>> the code is to initialize the fiedls that really need to be initialized at the >>> point, for the efficiency and also for making it clear which field is needed to >>> be initialized to what value here. It's also intended to make readers wonder >>> about where and how the remaining fields are initialized. >> Maybe the other func like damon_sysfs_kdamonds_alloc() also need to do >> like this, you can see it return directly by >> >> kzalloc. >> >> static struct damon_sysfs_kdamonds *damon_sysfs_kdamonds_alloc(void) >> { >> return kzalloc(sizeof(struct damon_sysfs_kdamonds), >> GFP_KERNEL); >> } > In this case, all the fields of the struct need to be initialized as zero. > That's why we use kzalloc() there. > > Of course, my opinion is not a static and concrete rule, but changing mind. > And obviously everyone makes many mistakes and DAMON code has many rooms for > improvement. Understand your concern,  at least, there is no point in simplifying the code too mush if we are ignoring its readability. > I really appreciate for your greatful efforts for that. But, at > least in this case, I think it doesn't really need the change at the moment, > IMHO. > > > Thanks, > SJ > > [...]