From: Jason Gunthorpe <jgg@nvidia.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: <vkoul@kernel.org>, Dan Williams <dan.j.williams@intel.com>,
<dmaengine@vger.kernel.org>
Subject: Re: [PATCH] dmaengine: idxd: Do not use devm for 'struct device' object allocation
Date: Tue, 23 Feb 2021 08:59:56 -0400 [thread overview]
Message-ID: <20210223125956.GY4247@nvidia.com> (raw)
In-Reply-To: <161368391486.325538.12829531932377771231.stgit@djiang5-desk3.ch.intel.com>
On Thu, Feb 18, 2021 at 02:31:54PM -0700, Dave Jiang wrote:
> Remove devm_* allocation of memory of 'struct device' objects.
> The devm_* lifetime is incompatible with device->release() lifetime.
> Address issues flagged by CONFIG_DEBUG_KOBJECT_RELEASE. Add release
> functions for each component in order to free the allocated memory at
> the appropriate time. Each component such as wq, engine, and group now
> needs to be allocated individually in order to setup the lifetime properly.
I really don't understand why idxd has so many struct device objects.
Typically I expect a simple driver to have exactly one, usually
provided by its subsystem.
What is the purpose?
And it is still messed up because it has:
struct idxd_device {
enum idxd_type type;
struct device conf_dev; <-- This is a kref
struct dma_device dma_dev; <-- And this is also a kref
}
The first kref does kfree() and the second does
idxd_conf_device_release() which does nothing - this is obviously
wrong too.
> +static int idxd_allocate_wqs(struct idxd_device *idxd)
> +{
> + struct device *dev = &idxd->pdev->dev;
> + struct idxd_wq *wq;
> + int i, rc;
> +
> + idxd->wqs = devm_kcalloc(dev, idxd->max_wqs, sizeof(struct idxd_wq *),
> + GFP_KERNEL);
Memory stored in the idxd_device should be freed by the release
function, not by devm.
And since the sub objects already have a pointer to the idxd_device,
I'd keep all the types the same but have the sub structs carry a kref
on the idxd_device, so their release function is just kref_put
Would be much less code
But even better would be to get rid of the struct device embedded in
the sub objects
Jason
next prev parent reply other threads:[~2021-02-23 13:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-18 21:31 [PATCH] dmaengine: idxd: Do not use devm for 'struct device' object allocation Dave Jiang
2021-02-23 12:59 ` Jason Gunthorpe [this message]
2021-02-23 15:27 ` Dave Jiang
2021-02-23 17:08 ` Jason Gunthorpe
2021-02-23 18:05 ` Dan Williams
2021-02-23 18:10 ` Jason Gunthorpe
2021-02-23 18:14 ` Dave Jiang
2021-02-23 18:30 ` Dan Williams
2021-02-23 18:34 ` Jason Gunthorpe
2021-02-23 18:42 ` Dave Jiang
2021-02-23 18:47 ` Jason Gunthorpe
2021-02-23 18:53 ` Dan Williams
2021-02-23 19:18 ` Dave Jiang
2021-02-23 19:36 ` Dan Williams
2021-02-23 17:00 ` Dan Williams
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=20210223125956.GY4247@nvidia.com \
--to=jgg@nvidia.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=vkoul@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.