From: Mike Rapoport Subject: Re: [PATCH 3/3] memblock: cleanup memblock_free interface Date: Thu, 23 Sep 2021 15:01:04 +0300 Message-ID: References: <20210923074335.12583-1-rppt@kernel.org> <20210923074335.12583-4-rppt@kernel.org> <1101e3c7-fcb7-a632-8e22-47f4a01ea02e@csgroup.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=pp1; bh=pXzEf65A4Oe5+XzfRr8terVnfyIyuO6PQs0+F8aXgGc=; b=ZCv5VVg5Axl96NC4/j5oW2leA+TyRu7PTszC85LX7OnyuvdR/QPrxFJvHee6+ph9/1Ah rUd/1Dr4tZ5yXYAiKoNA4l0g4riJzCer09eV4KmKCsnovao7Ujg6/MQzQ6IVb2C5LRSL 6WitPRreJzNPlii4WW55mXNNAxhzlImWjS7TBI5y3E9CuYqxTL+hR1eRpZFENX5WHVgo 3bzeScRRqqA6eAdFzB/5aWdZYhNxC/HkliRolmuo1Xv4pKsUbXkIzU8GEpyYBQunYUKJ 0M08Qqduz9x2e5o+taGQrQG0ce7A7g963Zzijz3wHvEhl/y43e2FXQI9OwpYg11CHmgU 9g== Content-Disposition: inline In-Reply-To: <1101e3c7-fcb7-a632-8e22-47f4a01ea02e-2tlSp11Fh4xulxpn9UvDqw@public.gmane.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Sender: "iommu" To: Christophe Leroy Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mips-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-riscv-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kasan-dev-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org, linux-snps-arc-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-um-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Linus Torvalds , linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-alpha-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrew Morton , linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org, Mike Rapoport On Thu, Sep 23, 2021 at 11:47:48AM +0200, Christophe Leroy wrote: > = > = > Le 23/09/2021 =E0 09:43, Mike Rapoport a =E9crit=A0: > > From: Mike Rapoport > > = > > For ages memblock_free() interface dealt with physical addresses even > > despite the existence of memblock_alloc_xx() functions that return a > > virtual pointer. > > = > > Introduce memblock_phys_free() for freeing physical ranges and repurpose > > memblock_free() to free virtual pointers to make the following pairing > > abundantly clear: > > = > > int memblock_phys_free(phys_addr_t base, phys_addr_t size); > > phys_addr_t memblock_phys_alloc(phys_addr_t base, phys_addr_t size); > > = > > void *memblock_alloc(phys_addr_t size, phys_addr_t align); > > void memblock_free(void *ptr, size_t size); > > = > > Replace intermediate memblock_free_ptr() with memblock_free() and drop > > unnecessary aliases memblock_free_early() and memblock_free_early_nid(). > > = > > Suggested-by: Linus Torvalds > > Signed-off-by: Mike Rapoport > > --- > = > > diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c > > index 1a04e5bdf655..37826d8c4f74 100644 > > --- a/arch/s390/kernel/smp.c > > +++ b/arch/s390/kernel/smp.c > > @@ -723,7 +723,7 @@ void __init smp_save_dump_cpus(void) > > /* Get the CPU registers */ > > smp_save_cpu_regs(sa, addr, is_boot_cpu, page); > > } > > - memblock_free(page, PAGE_SIZE); > > + memblock_phys_free(page, PAGE_SIZE); > > diag_amode31_ops.diag308_reset(); > > pcpu_set_smt(0); > > } > > @@ -880,7 +880,7 @@ void __init smp_detect_cpus(void) > > /* Add CPUs present at boot */ > > __smp_rescan_cpus(info, true); > > - memblock_free_early((unsigned long)info, sizeof(*info)); > > + memblock_free(info, sizeof(*info)); > > } > > /* > = > I'm a bit lost. IIUC memblock_free_early() and memblock_free() where > identical. Yes, they were, but all calls to memblock_free_early() were using __pa(vaddr) because they had a virtual address at hand. > In the first hunk memblock_free() gets replaced by memblock_phys_free() > In the second hunk memblock_free_early() gets replaced by memblock_free() In the first hunk the memory is allocated with memblock_phys_alloc() and we have a physical range to free. In the second hunk the memory is allocated with memblock_alloc() and we are freeing a virtual pointer. = > I think it would be easier to follow if you could split it in several > patches: It was an explicit request from Linus to make it a single commit: but the actual commit can and should be just a single commit that just fixes 'memblock_free()' to have sane interfaces. I don't feel strongly about splitting it (except my laziness really objects), but I don't think doing the conversion in several steps worth the churn. > - First patch: Create memblock_phys_free() and change all relevant > memblock_free() to memblock_phys_free() - Or change memblock_free() to > memblock_phys_free() and make memblock_free() an alias of it. > - Second patch: Make memblock_free_ptr() become memblock_free() and change > all remaining callers to the new semantics (IIUC memblock_free(__pa(ptr)) > becomes memblock_free(ptr) and make memblock_free_ptr() an alias of > memblock_free() > - Fourth patch: Replace and drop memblock_free_ptr() > - Fifth patch: Drop memblock_free_early() and memblock_free_early_nid() (= All > users should have been upgraded to memblock_free_phys() in patch 1 or > memblock_free() in patch 2) > = > Christophe -- = Sincerely yours, Mike.