From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 D073F43DA4F for ; Tue, 31 Mar 2026 17:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774979125; cv=none; b=oTxFeCDOTgJxto3LaBPvcVX5iT3z/k6a4x1hg/AvurXFF8SELat+uLYXyr7AdpMe9qdAr4Ggj2273/TZu98VB2mOUhfzVoQvYWTsPMCzfsVEAWIT/t8Tct3DL+xiUzBs5bHkuOuTMbNcEnOXDLGY6xsrXDl8bX5BFgdaSQA2sUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774979125; c=relaxed/simple; bh=kVE41/jM+Naby0ERWk/NQUBdQ21NQNt1htndClbQC9w=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PjK+ALwRkRPMjF/PhNb9IU6cl3N0RvVhxQIoaFzfB4lUeLMYSbdc3bkYHKjpAn9dXquYebzqFTdRK+zQgGJNJ/ZuWln56rEoMiN9O0jvAswXULzVhNFpsOBeQkWsVsAndzscDv7eFmAapLZf364K7/2CNr+uYcRYOqRlBxN4vLQ= 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=Z/eyLkmy; arc=none smtp.client-ip=209.85.167.52 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="Z/eyLkmy" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5a2967e5de4so8073439e87.3 for ; Tue, 31 Mar 2026 10:45:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774979122; x=1775583922; 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=N6FXrG475cDPtduYVwRttERvMXjCgD4c7f7JNUYgbB8=; b=Z/eyLkmyYf/q4yyCWJ87qFYuHLqNKUHRz3GDK9fqulhZIimmCgqekHSHYII96bZ7yt COhhzPAOZfTtbsqeWUN50Z0DSqS5GxL4m/0kqAIt/VFFuZgv2aebl46ZF/Cv3z0DA01C lS+2UfnMCeFyEHZiV9nFEdt/+euspaaNyWiqsFRMm9Fg/7MFwllnZ5WlzkCnfUB80Eb/ Oa6ALqxUZOXn16ZBA6wcXjEQ97AQExqBA636fwpogefPRGiXtuSdVJfKws4HtnRIWUoL rOU8Ro4Y82sIuiLDo27FtdI6mg9I5/bs6q/Ij0tNi6eVE63UTHd9R4yLo38P6V7g0JAA bx0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774979122; x=1775583922; 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=N6FXrG475cDPtduYVwRttERvMXjCgD4c7f7JNUYgbB8=; b=HNu6qbpN75orY2hKWfk/6i5skoZtEWjT6vb2w8gQ+CFQR7a8QKEtFByF8prSQIsDIM dJCWayTygFP6/BLqsxDoWynGo+No0pAmw3e6JvVmjwLYm6hPZx+XBY91bVWWuG2NFmbo 4mTaYQ5w+nnpUY+0U/kDXNdidyCuLdmAbaItHXjUBUn/brZkAzsC3o/m8uRVvyutXr55 75L8FKarcPeNytoxPDmOwjB1hwBECXEkNKSKqUkirUOKOkzgAyNvPdgA9n4idYwXyTXN GHlNpluzDsg8dLh81+akhS5YtAW6jT3wDkmRdS25RAYi9w1T0MFVoGZBhCHZKSlkitTz FHxw== X-Forwarded-Encrypted: i=1; AJvYcCVZAgYgFLXhBfK7dNvPUvB9XmDQiPkSFl6ruDJA71XrK+qe/q8HnIucygoxUl5zVp3XNaMHeJHwga5ca+U=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8kfV3c/99dN0GMn8B1O3v30E9nlQquyXCjn37VaqGdMdAC5UL /y1k0bkt4vpbqi8MoYcdRIakJSFvdimThD02/4e3FE5fyxQ2XQxez8Vw X-Gm-Gg: ATEYQzyfYgLkSHjqyyPn/GjiXRyHBVvxyytuu0JHb4ZflNQbJAmn2iS0TCPLssvQR0m htpuH6oB7fWwl7k4WOxARinzpngoDBiFsRonX387WSfPKlsRzq528/b3jOhSFpKZC0kyM5LzrFz seS/tWemiEiyXbFy5tUDg4Q+g7r2xfd0RN8A2d2RhGieNfbjlSwPi/SyecncUV8nl85gINhqrnT 8SGF0VRdlB5GUWuBCAZZOokF9o3B4hnPbnFwYmDnaZQueO+heAFbDLXTiOa5asP2XpCGLCrzhko rtMSCzt/MrX+VXl0Je8YgUv7YWQfgdm19FaYk1ju12bH0aLd+Eov9NT6Cu6ks3iEGiUEbrPivI1 O69SGqCeCtLQRKNySnNwxTDY7Un9DQqXKO0qbf8qRuIr14YUJGs70LMKbJJl6r7Hj0zR0VogQXL E= X-Received: by 2002:a05:6512:1282:b0:5a2:7ba1:493e with SMTP id 2adb3069b0e04-5a2c1f0d4b7mr160277e87.13.1774979121746; Tue, 31 Mar 2026 10:45:21 -0700 (PDT) Received: from milan ([2001:9b1:d5a0:a500::24b]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a2b145f145sm2594562e87.78.2026.03.31.10.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 10:45:21 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 31 Mar 2026 19:45:19 +0200 To: shivamkalra98@zohomail.in Cc: Andrew Morton , Uladzislau Rezki , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alice Ryhl , Danilo Krummrich Subject: Re: [PATCH v8 6/6] lib/test_vmalloc: add vrealloc test case Message-ID: References: <20260327-vmalloc-shrink-v8-0-cc6b57059ed7@zohomail.in> <20260327-vmalloc-shrink-v8-6-cc6b57059ed7@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: <20260327-vmalloc-shrink-v8-6-cc6b57059ed7@zohomail.in> On Fri, Mar 27, 2026 at 03:18:42PM +0530, Shivam Kalra via B4 Relay wrote: > From: Shivam Kalra > > Introduce a new test case "vrealloc_test" that exercises the vrealloc() > shrink and in-place grow paths: > > - Grow beyond allocated pages (triggers full reallocation). > - Shrink crossing a page boundary (frees tail pages). > - Shrink within the same page (no page freeing). > - Grow within the already allocated page count (in-place). > > Data integrity is validated after each realloc step by checking that > the first byte of the original allocation is preserved. > > The test is gated behind run_test_mask bit 12 (id 4096). > > Signed-off-by: Shivam Kalra > --- > lib/test_vmalloc.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 62 insertions(+) > > diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c > index 876c72c18a0c..b23f85e8f8ca 100644 > --- a/lib/test_vmalloc.c > +++ b/lib/test_vmalloc.c > @@ -55,6 +55,7 @@ __param(int, run_test_mask, 7, > "\t\tid: 512, name: kvfree_rcu_2_arg_vmalloc_test\n" > "\t\tid: 1024, name: vm_map_ram_test\n" > "\t\tid: 2048, name: no_block_alloc_test\n" > + "\t\tid: 4096, name: vrealloc_test\n" > /* Add a new test case description here. */ > ); > > @@ -421,6 +422,66 @@ vm_map_ram_test(void) > return nr_allocated != map_nr_pages; > } > > +static int vrealloc_test(void) > +{ > + void *ptr, *tmp; > + int i; > + > + for (i = 0; i < test_loop_count; i++) { > + int err = -1; > + > + ptr = vrealloc(NULL, PAGE_SIZE, GFP_KERNEL); > + if (!ptr) > + return -1; > + > + *((__u8 *)ptr) = 'a'; > + > + /* Grow: beyond allocated pages, triggers full realloc. */ > + tmp = vrealloc(ptr, 4 * PAGE_SIZE, GFP_KERNEL); > + if (!tmp) > + goto error; > + ptr = tmp; > + > + if (*((__u8 *)ptr) != 'a') > + goto error; > + > + /* Shrink: crosses page boundary, frees tail pages. */ > + tmp = vrealloc(ptr, PAGE_SIZE, GFP_KERNEL); > + if (!tmp) > + goto error; > + ptr = tmp; > + > + if (*((__u8 *)ptr) != 'a') > + goto error; > + > + /* Shrink: within same page, no page freeing. */ > + tmp = vrealloc(ptr, PAGE_SIZE / 2, GFP_KERNEL); > + if (!tmp) > + goto error; > + ptr = tmp; > + > + if (*((__u8 *)ptr) != 'a') > + goto error; > + > + /* Grow: within allocated page, in-place, no realloc. */ > + tmp = vrealloc(ptr, PAGE_SIZE, GFP_KERNEL); > + if (!tmp) > + goto error; > + ptr = tmp; > + > + if (*((__u8 *)ptr) != 'a') > + goto error; > + > + err = 0; > +error: > + vfree(ptr); > + if (err) > + return err; > + } > + > + return 0; > +} > + > struct test_case_desc { > const char *test_name; > int (*test_func)(void); > @@ -440,6 +501,7 @@ static struct test_case_desc test_case_array[] = { > { "kvfree_rcu_2_arg_vmalloc_test", kvfree_rcu_2_arg_vmalloc_test, }, > { "vm_map_ram_test", vm_map_ram_test, }, > { "no_block_alloc_test", no_block_alloc_test, true }, > + { "vrealloc_test", vrealloc_test, }, > /* Add a new test case here. */ > }; > > > -- > 2.43.0 > > Reviewed-by: Uladzislau Rezki (Sony) -- Uladzislau Rezki