[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <946f9111-f799-38a1-a185-d882668fa725@huawei.com>
Date: Fri, 18 Dec 2020 14:02:02 +0800
From: "Leizhen (ThunderTown)" <thunder.leizhen@...wei.com>
To: Dan Williams <dan.j.williams@...el.com>
CC: Vishal Verma <vishal.l.verma@...el.com>,
Dave Jiang <dave.jiang@...el.com>,
linux-nvdimm <linux-nvdimm@...ts.01.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Jane Chu <jane.chu@...cle.com>
Subject: Re: [PATCH 1/1] device-dax: avoid an unnecessary check in
alloc_dev_dax_range()
On 2020/12/18 11:10, Dan Williams wrote:
> On Fri, Nov 20, 2020 at 1:23 AM Zhen Lei <thunder.leizhen@...wei.com> wrote:
>>
>> Swap the calling sequence of krealloc() and __request_region(), call the
>> latter first. In this way, the value of dev_dax->nr_range does not need to
>> be considered when __request_region() failed.
>
> This looks ok, but I think I want to see another cleanup go in first
> before this to add a helper for trimming the last range off the set of
> ranges:
>
> static void dev_dax_trim_range(struct dev_dax *dev_dax)
> {
> int i = dev_dax->nr_range - 1;
> struct range *range = &dev_dax->ranges[i].range;
> struct dax_region *dax_region = dev_dax->region;
>
> dev_dbg(dev, "delete range[%d]: %#llx:%#llx\n", i,
> (unsigned long long)range->start,
> (unsigned long long)range->end);
>
> __release_region(&dax_region->res, range->start, range_len(range));
> if (--dev_dax->nr_range == 0) {
> kfree(dev_dax->ranges);
> dev_dax->ranges = NULL;
> }
> }
>
> Care to do a lead in patch with that cleanup, then do this one?
I don't mind! You can add above helper first. After that, I'll update
and send this patch again.
>
> I think that might also cleanup a memory leak report from Jane in
> addition to not needing the "goto" as well.
>
> http://lore.kernel.org/r/c8a8a260-34c6-dbfc-1f19-25c23d01cb45@oracle.com
>
> .
>
Powered by blists - more mailing lists