From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EF302D97B7 for ; Thu, 23 Apr 2026 17:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776965815; cv=none; b=TXtN2t69BcvvI+nGCrIrCUZepw7Fjkr/b+2R1dgqQEXKxyOddolQRMQ2ZgBbp4AEQVzx8HmYPab2S6/f3k2I+U30IdYcDVkGIp+uJbHl4fM/AUl98HVs64RSj8oac8xb5AlbT1IUpaRYbfFxqFpJwYLbw5vrELXMW6KaltdH/bI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776965815; c=relaxed/simple; bh=aq2g+jZWsNZTJkO5FPtIHFH3eDsNeBvnwajJo5P/d58=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=f0A46zZ9mOQmeYCErGXwPyuOWpCXzEZqcOAbFksnW9x25ez6y0gdvdQBstt/tDJQthxWA9+vZikh90KQcO8KctCtgOUDdieoVhzgYvwo3QuTkprAFJ2hSaTZuFpZchzccVBhaxF9ldrLIzIT1CZabAZT8BCXv0Qa/4s34NeLg5Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=0b1tYMt/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="0b1tYMt/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16CECC2BCB2; Thu, 23 Apr 2026 17:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1776965815; bh=aq2g+jZWsNZTJkO5FPtIHFH3eDsNeBvnwajJo5P/d58=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=0b1tYMt/GK8QB4PkPymnjth2zN8Z7LqgiIWyLc+uhtf6zscCH+7qdas+u7xRLSNCf vCitMdwlb8AKylRSZa00dVMdJxe8a/X4LLoqatsw9zJ3Lkchtcjitllj5U+VsdRLWH o8p2v1PfaSn++f/kpFXY7c6WdQvHT8beO/NLVDTM= Date: Thu, 23 Apr 2026 10:36:54 -0700 From: Andrew Morton To: shivamkalra98@zohomail.in Cc: Shivam Kalra via B4 Relay , Uladzislau Rezki , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alice Ryhl , Danilo Krummrich Subject: Re: [PATCH v11 1/5] mm/vmalloc: extract vm_area_free_pages() helper from vfree() Message-Id: <20260423103654.2b50501df33f9fd03d48eb34@linux-foundation.org> In-Reply-To: <20260420-vmalloc-shrink-v11-1-cad80b00853a@zohomail.in> References: <20260420-vmalloc-shrink-v11-0-cad80b00853a@zohomail.in> <20260420-vmalloc-shrink-v11-1-cad80b00853a@zohomail.in> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 20 Apr 2026 22:27:09 +0530 Shivam Kalra via B4 Relay wrote: > From: Shivam Kalra > > Extract the page-freeing loop and NR_VMALLOC stat accounting from > vfree() into a reusable vm_area_free_pages() helper. The helper operates > on a range [start_idx, end_idx) of pages from a vm_struct, making it > suitable for both full free (vfree) and partial free (upcoming vrealloc > shrink). > > Freed page pointers in vm->pages[] are set to NULL to prevent stale > references when the vm_struct outlives the free (as in vrealloc shrink). > > ... > > * vfree - Release memory allocated by vmalloc() > * @addr: Memory base address > @@ -3436,7 +3468,6 @@ void vfree_atomic(const void *addr) > void vfree(const void *addr) > { > struct vm_struct *vm; > - int i; > > if (unlikely(in_interrupt())) { > vfree_atomic(addr); > @@ -3459,19 +3490,7 @@ void vfree(const void *addr) > > if (unlikely(vm->flags & VM_FLUSH_RESET_PERMS)) > vm_reset_perms(vm); > - for (i = 0; i < vm->nr_pages; i++) { > - struct page *page = vm->pages[i]; > - > - BUG_ON(!page); > - /* > - * High-order allocs for huge vmallocs are split, so > - * can be freed as an array of order-0 allocations > - */ > - if (!(vm->flags & VM_MAP_PUT_PAGES)) > - mod_lruvec_page_state(page, NR_VMALLOC, -1); > - __free_page(page); > - cond_resched(); > - } > + vm_area_free_pages(vm, 0, vm->nr_pages); > kvfree(vm->pages); > kfree(vm); Ryan's "vmalloc: optimize vfree with free_pages_bulk()" just altered all of this. Can you please redo this series against mm.git's mm-new branch? I'll be pushing that out later today. Thanks.