Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1839507pxu; Thu, 17 Dec 2020 22:05:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrgfSf5jeguSq1CcyTlteFeZRQdjrPg8A4xdlIpnR0mndibHONNNy6+5A6i9XM2fV2PkDM X-Received: by 2002:a17:906:e247:: with SMTP id gq7mr2486414ejb.27.1608271538800; Thu, 17 Dec 2020 22:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608271538; cv=none; d=google.com; s=arc-20160816; b=ZcOUV3hdBeZxTqNoAva8cZTBTRRZCEEg6qsOjSW7CJ2l1LX7fhDA5I10oTGzR7rQXw EOXQqKW0Aqj4EIoe3nMXkkb6j4UV8+9W8Iu7zbeacndcYd+pBsAFbM26HlmXYoHmuJun fYDIWWKXeuPVMcAzze3NXVBf9T6XQBx5EimS6Tg54EqTKehJiVfQo7gxOhiHUQ/pDJ8U CSCR3+Mvn9xDZN+h5M9vUnUdUkxc9wxgcLUP8zMert7y2iU3Iy5FesT+O2EqjX9W9dsQ sNoXv9o3TKTeUfpUKOTAA6rvM8l5szQjBVHDDK7ZIllssC1ZAdoTD+hQRTju9Btlf/qd SPjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=FfaJ8YfHVEsjQzy6KHJ3LQvO35LlAiFWrKlgRsl0uqA=; b=P4HF8FT8cXB9f37Ic3jjBS03KmQIswjjW0xhK4KPr9Pg7O3dawgbS/Sh56KxVUmnQN kpESFyFUPD29unbRn9/zSg+eRILwAAmcf7w/WjxcPz2cuej3EaCO31YBJYEe90CtipWY UmcdN3oAFe629JbMWkHDMy4KHCj9MBAyMm6Qu6MR875MLIId07dPyAB0+7amQMHtT9JX nZey6OPnmkmEiR2Y+GkE+n9MQUay3OmmmZJaz2pgWoBcf7Vx2VkjtxKozoFQJrbA2K55 1oZ0W8SYhjrb1m5p7mFvEhQS6PDnsqMly/nhEsTNRK9W+11nrMsrmgd78S+yrTVKqS5i 8k0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si5553099edr.397.2020.12.17.22.05.16; Thu, 17 Dec 2020 22:05:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732619AbgLRGCv (ORCPT + 99 others); Fri, 18 Dec 2020 01:02:51 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:9539 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727153AbgLRGCu (ORCPT ); Fri, 18 Dec 2020 01:02:50 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Cxyt204T3zhttS; Fri, 18 Dec 2020 14:01:30 +0800 (CST) Received: from [127.0.0.1] (10.174.177.9) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Fri, 18 Dec 2020 14:02:03 +0800 Subject: Re: [PATCH 1/1] device-dax: avoid an unnecessary check in alloc_dev_dax_range() To: Dan Williams CC: Vishal Verma , Dave Jiang , linux-nvdimm , linux-kernel , Jane Chu References: <20201120092251.2197-1-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <946f9111-f799-38a1-a185-d882668fa725@huawei.com> Date: Fri, 18 Dec 2020 14:02:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.9] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/12/18 11:10, Dan Williams wrote: > On Fri, Nov 20, 2020 at 1:23 AM Zhen Lei 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 > > . >