linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: haoxin <xhao@linux.alibaba.com>
To: SeongJae Park <sj@kernel.org>
Cc: akpm@linux-foundation.org, damon@lists.linux.dev,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 2/2] mm/damon/sysfs: use kzmalloc instead kmalloc to simplify codes
Date: Wed, 21 Sep 2022 13:20:21 +0800	[thread overview]
Message-ID: <09ddb8f0-9ea3-2dd0-fa77-430ff3380f85@linux.alibaba.com> (raw)
In-Reply-To: <20220920162542.52554-1-sj@kernel.org>


在 2022/9/21 上午12:25, SeongJae Park 写道:
> Hi Xin,
>
> On Tue, 20 Sep 2022 09:58:41 +0800 haoxin <xhao@linux.alibaba.com> wrote:
>
>> 在 2022/9/20 上午1:22, SeongJae Park 写道:
>>> On Mon, 19 Sep 2022 23:12:01 +0800 Xin Hao <xhao@linux.alibaba.com> 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
>
> [...]


  reply	other threads:[~2022-09-21  5:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 15:12 [PATCH v1 1/2] mm/damon/sysfs: remove unnecessary variables Xin Hao
2022-09-19 15:12 ` [PATCH v1 2/2] mm/damon/sysfs: use kzmalloc instead kmalloc to simplify codes Xin Hao
2022-09-19 17:22   ` SeongJae Park
2022-09-20  1:58     ` haoxin
2022-09-20 16:25       ` SeongJae Park
2022-09-21  5:20         ` haoxin [this message]
2022-09-19 17:03 ` [PATCH v1 1/2] mm/damon/sysfs: remove unnecessary variables SeongJae Park
2022-09-20  1:54   ` haoxin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09ddb8f0-9ea3-2dd0-fa77-430ff3380f85@linux.alibaba.com \
    --to=xhao@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox