From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40FF22F8EB4 for ; Mon, 18 May 2026 18:10:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779127842; cv=none; b=O6SJOXmBtq23YmQ2On6awIqdEeTZWL7CrfRZQoBfHAg1UWgtpTziqYDRDmCr1uqi0oAbjshe7pXBHDFooOQBAFbmBcYiUrpNWe20mkE5lYJ7BIrUt0DZo6//aWQll529NEI5dweQwhkJsD4iHqHak6/4mBxWjiwVzMNzP0BCCHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779127842; c=relaxed/simple; bh=vOKSfV7mCj1OW1Tuz/8ifiEaQruqRgbgsG/nNEJdSyc=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Bvc0Jgjfl1AwjbXHWeWR7rBc3K8CtU/QgEdxOByPvjpM52cRFVw+ct9TnMMbGUlx4XBwv6kWNFySAxdAE4FuGJbUzaMXTVVS25rCHifrPwa/bOVIxU54348kFfYRj66dHykmcP5TptC4H6DUkIIg6+pPF1aBAfSqyN9squmZeMg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NnNCDjJt; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NnNCDjJt" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5a858881ad2so3559427e87.3 for ; Mon, 18 May 2026 11:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779127839; x=1779732639; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=H3wCrNm6GaCIAAw/wLOXqXnfCI0G+Noaf5OWqaDbU0g=; b=NnNCDjJtc6xqoWGY5J0MzaKTuAs8JtnKXZz0EibNh8DlLYIK5nRbxZAK003SbZ9Ums dufkbaIenw2PGXLFB5r78vwZv1VM9ZtFvOIBLc/sxEejkyshJny7Hxymxu28BgdExLHw Jd/ORgJdJdGj0qp6IHJa2UVZgoYIwULW3yIQCd0hhuBXY+GtjNsUwCP2AYj2OP4IWwPn FHSpzUA42qLQUpVD7W/QNjGSnvokMDazadkjlgorjNOQkPl4BaYHuBZLrLWIfhNYS+KI fDxSfDNAbadutnIZqgYE81r9kV62LDzJiuntkDl2/UCdzSBSl4poJINwBSf0g9ZK+n4+ sHwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779127839; x=1779732639; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H3wCrNm6GaCIAAw/wLOXqXnfCI0G+Noaf5OWqaDbU0g=; b=NJPUX4BUQRAlryqzpX5dAd6qSap0Bt+cJv4tHULkXDXHZl78DdpaPF7WyrePxHDR6Z 7DECoKxXnqzuAjdkek2JM+wixwN/4dY7GCn0ER/yKBW3PZSjiIc1iAjhrjD1gxfv3WJb Fz2mD0cXxIf18THPM9ryuMt5wDLcODSx8FtkgmIxujUYR68LpoNrAFK8T2AVbdd4bWWN oxuyp1qWxEA0WdvCwV2vDo8vJOVYvmz+G1xYqKsnPucsEb45vqAWQ7z+hcg4gM4WR/8T V+pm9dHNPO8dlBGFBMXofL83Jq8lgSOm2xjTImKUxQsqEwmey37dk14Fb2nWxKv6/Ena g78Q== X-Forwarded-Encrypted: i=1; AFNElJ/2QJ8WVuJe8yqpMEL8qtv6WwVBjQOfCaE21WwtjqPx6WWohfBv04rwUXFtiS+ySOpwWwtmVmHyK5f67QE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5y7vTnMSttPMAVc6uhWbfgf9ewSTYsVc7J/4tS+q38gYsvi6p 95KJPd4GbGjVBxuvy6PAFCi/1cdg3bGfXxQanNmxmtBKI136MNaE4oq8 X-Gm-Gg: Acq92OGT7eoC1QYgxaKR+tIT9Uy9+gnhRqh3Gkd6T2S6uEkX1HxYH/e190RD02aM/iF JUVY10qUf2jAuENxXJAg0pPtN8cKWy8UKC9NDcFAIRfUR7AQAmnIG3FPEYEzIA6SUQQThBIAGpF 4w5+42Scl84JUf2XQ8cpcTtxtGY/jV/W1NhOrGNyYkCi9hJ9RiVq4lvQhCC63gXjV0+/EuFBdEJ jyC9Pc8dPM8f9hvRdzc94O2p/h7o6KvQa6+PonxbWWsON6FmLhNHjLIgAe6gtYLFz5rR8s47kxU kFA9QOwhoXozRuzlBBwFUwVEReZKPbI15GXv3v3skUiX0L0EZ2m6Y9rPGEG+eVpb9oP5HPMDrun oVFxDXHIcEa7/JwzPeYVqnn2OjHRDleANvwABklBpIY6Ke+yrUYNw9pl/2ux2p8sX X-Received: by 2002:a05:6512:3a92:b0:5a4:194c:d897 with SMTP id 2adb3069b0e04-5aa0e60aeb2mr4105100e87.12.1779127839075; Mon, 18 May 2026 11:10:39 -0700 (PDT) Received: from milan ([2001:9b1:d5a0:a500::24b]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a9164cf003sm3427067e87.73.2026.05.18.11.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 11:10:38 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 18 May 2026 20:10:37 +0200 To: Shivam Kalra Cc: Andrew Morton , Shivam Kalra via B4 Relay , Uladzislau Rezki , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alice Ryhl , Danilo Krummrich Subject: Re: [PATCH v13 0/5] mm/vmalloc: free unused pages on vrealloc() shrink Message-ID: References: <20260511-vmalloc-shrink-v13-0-643b7ec277a9@zohomail.in> <20260512150109.1a7939bb15f3d48ad866c540@linux-foundation.org> <8d678cb6-9f96-47b8-a25a-b3a969976630@zohomail.in> 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-Disposition: inline In-Reply-To: <8d678cb6-9f96-47b8-a25a-b3a969976630@zohomail.in> On Mon, May 18, 2026 at 04:29:11AM +0530, Shivam Kalra wrote: > On 13/05/26 03:31, Andrew Morton wrote: > > On Mon, 11 May 2026 13:47:28 +0530 Shivam Kalra via B4 Relay wrote: > > > >> This series implements the TODO in vrealloc() to unmap and free unused > >> pages when shrinking across a page boundary. > > > > Thanks. AI review asked a few questions. Does anything here look > > legitimate? > > > > https://sashiko.dev/#/patchset/20260511-vmalloc-shrink-v13-0-643b7ec277a9@zohomail.in > > Thanks for flagging this. I went through the Sashiko review, and, > one of the findings is legitimate and needs a fix. > > 1) Patch 3 - vmap() mappings with nr_pages == 0 (LEGITIMATE) > This is correct. For vmap() areas created without VM_MAP_PUT_PAGES, > nr_pages is never set and stays 0 (vm_struct is kzalloc'd). With the > current patch, vread_iter() would compute size = 0 for these areas, > skip them entirely, and zero-fill the region in /proc/kcore. > > Ulad, this is the approach you suggested during v10 review [1]; we > both checked whether nr_pages could be 0 and concluded it couldn't, > but we only considered the VM_ALLOC (vmalloc) path. vmap() areas also > have vm != NULL but never set nr_pages unless VM_MAP_PUT_PAGES is > passed, which most callers don't use. > > Since vrealloc() only operates on VM_ALLOC areas, I think we can > scope the nr_pages path to just that: > if (vm) > /* > * For VM_ALLOC areas, use nr_pages rather than > * get_vm_area_size() because vrealloc() may shrink > * the mapping without updating area->size. Other > * mapping types (vmap, ioremap) don't set nr_pages. > */ > size = (vm->flags & VM_ALLOC) ? > (vm->nr_pages << PAGE_SHIFT) : > get_vm_area_size(vm); > else > size = va_size(va); > Ulad, does this approach look right to you, or would you prefer to > initialize nr_pages unconditionally in vmap() instead? > > [1] https://lore.kernel.org/lkml/aeYBYqPSEJRC8mjh@milan/ > Indeed, we missed that point regarding vmap() code. Checking VM_ALLOC sounds correct to me. -- Uladzislau Rezki