From patchwork Tue Oct 13 23:49:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11836285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0746E61C for ; Tue, 13 Oct 2020 23:50:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B686321D81 for ; Tue, 13 Oct 2020 23:50:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="tdWl3Rb1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B686321D81 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7462E6B0092; Tue, 13 Oct 2020 19:50:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6F4E66B0093; Tue, 13 Oct 2020 19:50:02 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 632406B0095; Tue, 13 Oct 2020 19:50:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 375606B0092 for ; Tue, 13 Oct 2020 19:50:02 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BE1408249980 for ; Tue, 13 Oct 2020 23:50:01 +0000 (UTC) X-FDA: 77368547802.11.news81_25147a027207 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 891D2180F8B86 for ; Tue, 13 Oct 2020 23:50:01 +0000 (UTC) X-Spam-Summary: 1,0,0,c40041ba9bd32e00,d41d8cd98f00b204,akpm@linux-foundation.org,,RULES_HIT:2:41:69:152:355:379:800:960:966:967:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1381:1431:1437:1513:1515:1516:1518:1521:1535:1593:1594:1605:1606:1730:1747:1777:1792:1981:2194:2196:2199:2200:2393:2525:2553:2559:2563:2682:2685:2693:2859:2902:2903:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3167:3503:3504:3865:3866:3867:3868:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4119:4250:4321:4385:4423:4605:5007:6261:6653:6737:6738:7576:7808:7875:7903:9025:9163:9545:10004:11026:11473:11658:11914:12043:12048:12114:12295:12296:12297:12438:12517:12519:12555:12679:12986:13149:13161:13229:13230:13255:14096:14097:21080:21220:21451:21627:21939:21972:21987:21990:30003:30012:30029:30054:30064:30070:30090,0,RBL:198.145.29.99:@linux-foundation.org:.lbl8.mailshell.net-62.2.0.100 64.100.201.201;04y878zpq5um6azjw55qqf8dphaajypenzkjwh6gwp84m7nbcf8inct61xag5iy .tkxjbbn X-HE-Tag: news81_25147a027207 X-Filterd-Recvd-Size: 8207 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 13 Oct 2020 23:50:00 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9396221FF; Tue, 13 Oct 2020 23:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602633000; bh=k5MRtz2FmH2p/WutJa1cpFq/QS3FIU9bXcdzbbLUwGY=; h=Date:From:To:Subject:In-Reply-To:From; b=tdWl3Rb1VH1gAbB+d2aoflJ0NJKf0QjrYHr4iDfimecT+PBzEgjuMuvi1uRUqfoUt nX4jxn7Kxv74inD4n/DvloonjjMn7cbhYYlbDEir0pI4tQkVM9DueTLMN5mnit0snT cYXjEp5YhnZF3vohDHTy6uJC7+Q3E+th8bbBL5VQ= Date: Tue, 13 Oct 2020 16:49:58 -0700 From: Andrew Morton To: airlied@linux.ie, akpm@linux-foundation.org, ard.biesheuvel@linaro.org, ardb@kernel.org, benh@kernel.crashing.org, bhelgaas@google.com, boris.ostrovsky@oracle.com, bp@alien8.de, Brice.Goglin@inria.fr, bskeggs@redhat.com, catalin.marinas@arm.com, dan.j.williams@intel.com, daniel@ffwll.ch, dave.hansen@linux.intel.com, dave.jiang@intel.com, david@redhat.com, gregkh@linuxfoundation.org, hpa@zytor.com, hulkci@huawei.com, ira.weiny@intel.com, jgg@mellanox.com, jglisse@redhat.com, jgross@suse.com, jmoyer@redhat.com, joao.m.martins@oracle.com, Jonathan.Cameron@huawei.com, justin.he@arm.com, linux-mm@kvack.org, lkp@intel.com, luto@kernel.org, mingo@redhat.com, mm-commits@vger.kernel.org, mpe@ellerman.id.au, pasha.tatashin@soleen.com, paulus@ozlabs.org, peterz@infradead.org, rafael.j.wysocki@intel.com, rdunlap@infradead.org, richard.weiyang@linux.alibaba.com, rppt@linux.ibm.com, sstabellini@kernel.org, tglx@linutronix.de, thomas.lendacky@amd.com, torvalds@linux-foundation.org, vgoyal@redhat.com, vishal.l.verma@intel.com, will@kernel.org, yanaijie@huawei.com Subject: [patch 038/181] device-dax/kmem: replace release_resource() with release_mem_region() Message-ID: <20201013234958.FOTI8zIwm%akpm@linux-foundation.org> In-Reply-To: <20201013164658.3bfd96cc224d8923e66a9f4e@linux-foundation.org> User-Agent: s-nail v14.8.16 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Dan Williams Subject: device-dax/kmem: replace release_resource() with release_mem_region() Towards removing the mode specific @dax_kmem_res attribute from the generic 'struct dev_dax', and preparing for multi-range support, change the kmem driver to use the idiomatic release_mem_region() to pair with the initial request_mem_region(). This also eliminates the need to open code the release of the resource allocated by request_mem_region(). As there are no more dax_kmem_res users, delete this struct member. Link: https://lkml.kernel.org/r/160106112239.30709.15909567572288425294.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams Cc: David Hildenbrand Cc: Vishal Verma Cc: Dave Hansen Cc: Pavel Tatashin Cc: Brice Goglin Cc: Dave Jiang Cc: David Hildenbrand Cc: Ira Weiny Cc: Jia He Cc: Joao Martins Cc: Jonathan Cameron Cc: Andy Lutomirski Cc: Ard Biesheuvel Cc: Ard Biesheuvel Cc: Benjamin Herrenschmidt Cc: Ben Skeggs Cc: Bjorn Helgaas Cc: Borislav Petkov Cc: Boris Ostrovsky Cc: Catalin Marinas Cc: Daniel Vetter Cc: David Airlie Cc: Greg Kroah-Hartman Cc: "H. Peter Anvin" Cc: Hulk Robot Cc: Ingo Molnar Cc: Jason Gunthorpe Cc: Jason Yan Cc: Jeff Moyer Cc: "Jérôme Glisse" Cc: Juergen Gross Cc: kernel test robot Cc: Michael Ellerman Cc: Mike Rapoport Cc: Paul Mackerras Cc: Peter Zijlstra Cc: "Rafael J. Wysocki" Cc: Randy Dunlap Cc: Stefano Stabellini Cc: Thomas Gleixner Cc: Tom Lendacky Cc: Vivek Goyal Cc: Wei Yang Cc: Will Deacon Signed-off-by: Andrew Morton --- drivers/dax/dax-private.h | 3 --- drivers/dax/kmem.c | 20 +++++++------------- 2 files changed, 7 insertions(+), 16 deletions(-) --- a/drivers/dax/dax-private.h~device-dax-kmem-replace-release_resource-with-release_mem_region +++ a/drivers/dax/dax-private.h @@ -42,8 +42,6 @@ struct dax_region { * @dev - device core * @pgmap - pgmap for memmap setup / lifetime (driver owned) * @range: resource range for the instance - * @dax_mem_res: physical address range of hotadded DAX memory - * @dax_mem_name: name for hotadded DAX memory via add_memory_driver_managed() */ struct dev_dax { struct dax_region *region; @@ -52,7 +50,6 @@ struct dev_dax { struct device dev; struct dev_pagemap *pgmap; struct range range; - struct resource *dax_kmem_res; }; static inline u64 range_len(struct range *range) --- a/drivers/dax/kmem.c~device-dax-kmem-replace-release_resource-with-release_mem_region +++ a/drivers/dax/kmem.c @@ -33,7 +33,7 @@ int dev_dax_kmem_probe(struct device *de { struct dev_dax *dev_dax = to_dev_dax(dev); struct range range = dax_kmem_range(dev_dax); - struct resource *new_res; + struct resource *res; char *res_name; int numa_node; int rc; @@ -56,8 +56,8 @@ int dev_dax_kmem_probe(struct device *de return -ENOMEM; /* Region is permanently reserved if hotremove fails. */ - new_res = request_mem_region(range.start, range_len(&range), res_name); - if (!new_res) { + res = request_mem_region(range.start, range_len(&range), res_name); + if (!res) { dev_warn(dev, "could not reserve region [%#llx-%#llx]\n", range.start, range.end); kfree(res_name); return -EBUSY; @@ -69,23 +69,20 @@ int dev_dax_kmem_probe(struct device *de * inherit flags from the parent since it may set new flags * unknown to us that will break add_memory() below. */ - new_res->flags = IORESOURCE_SYSTEM_RAM; + res->flags = IORESOURCE_SYSTEM_RAM; /* * Ensure that future kexec'd kernels will not treat this as RAM * automatically. */ - rc = add_memory_driver_managed(numa_node, new_res->start, - resource_size(new_res), kmem_name); + rc = add_memory_driver_managed(numa_node, range.start, range_len(&range), kmem_name); if (rc) { - release_resource(new_res); - kfree(new_res); + release_mem_region(range.start, range_len(&range)); kfree(res_name); return rc; } dev_set_drvdata(dev, res_name); - dev_dax->dax_kmem_res = new_res; return 0; } @@ -95,7 +92,6 @@ static int dev_dax_kmem_remove(struct de { struct dev_dax *dev_dax = to_dev_dax(dev); struct range range = dax_kmem_range(dev_dax); - struct resource *res = dev_dax->dax_kmem_res; const char *res_name = dev_get_drvdata(dev); int rc; @@ -114,10 +110,8 @@ static int dev_dax_kmem_remove(struct de } /* Release and free dax resources */ - release_resource(res); - kfree(res); + release_mem_region(range.start, range_len(&range)); kfree(res_name); - dev_dax->dax_kmem_res = NULL; return 0; }