From: "Wilczynski, Michal" <michal.wilczynski@intel.com>
To: Dan Williams <dan.j.williams@intel.com>, <nvdimm@lists.linux.dev>,
<linux-acpi@vger.kernel.org>
Cc: <rafael@kernel.org>, <vishal.l.verma@intel.com>,
<lenb@kernel.org>, <dave.jiang@intel.com>, <ira.weiny@intel.com>,
<linux-kernel@vger.kernel.org>,
Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: Re: [PATCH v2] ACPI: NFIT: Fix local use of devm_*()
Date: Fri, 13 Oct 2023 19:00:37 +0200 [thread overview]
Message-ID: <f7441bb4-c2c9-4eee-9fed-ad8b28de4788@intel.com> (raw)
In-Reply-To: <6529727e18964_f879294ea@dwillia2-mobl3.amr.corp.intel.com.notmuch>
On 10/13/2023 6:38 PM, Dan Williams wrote:
> Michal Wilczynski wrote:
>> devm_*() family of functions purpose is managing memory attached to a
>> device. So in general it should only be used for allocations that should
>> last for the whole lifecycle of the device.
> No, this assertion is not accurate, if it were strictly true then
> devm_kfree() should be deleted. This patch is only a cleanup to switch
> the automatic cleanup pattern from devm to the new cleanup.h helpers.
The memory in question is only used locally in a function, so there is no reason
to use devm_*() family of functions. I think devm_kfree() is more for special
cases where the memory is meant to be used for the whole lifecycle of device,
but some special case occurs and it's not and it needs to be freed.
This is an incorrect API usage. Would you propose to change all memory
allocations currently being done to devm_*() family simply because devm_kfree()
exists ? Why introduce extra overhead if you don't have to ?
>
> I am all for modernizing code over time, but patches that make
> assertions of "memory leaks" and "incorrect API usage" in code that has
> been untouched for almost a decade demand more scrutiny than what
> transpired here.
I understand that it's not necessarily a big problem, and the code works
perfectly, I can change the phrasing if you don't like it, but still the
cleanup.h helpers don't really care that much what functions they call
to allocate/free. They are meant to care about the scope - like constructor
destructor in C++ - you can call anything there.
So this commit changes 2 things:
- change family of function to allocate from
devm_kcalloc() to kcalloc()
- use scope based mechanism to call those functions
Thanks a lot for your review !
Michał
next prev parent reply other threads:[~2023-10-13 17:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-13 8:57 [PATCH v2] ACPI: NFIT: Fix local use of devm_*() Michal Wilczynski
2023-10-13 16:38 ` Dan Williams
2023-10-13 17:00 ` Wilczynski, Michal [this message]
2023-10-13 17:05 ` Dan Williams
2023-10-13 17:18 ` Wilczynski, Michal
2023-10-13 21:20 ` Dan Williams
2023-10-14 10:17 ` Andy Shevchenko
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=f7441bb4-c2c9-4eee-9fed-ad8b28de4788@intel.com \
--to=michal.wilczynski@intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=rafael@kernel.org \
--cc=vishal.l.verma@intel.com \
/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