From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CA443DCDB6; Thu, 11 Jun 2026 11:19:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781176766; cv=none; b=kzoqNBCZIgoPGt5dpKroxBuJ4lg99Ubl2ezJCIvbg/cTzhZ9i5s15yVFHLo3dKLRKzMiiIzXki1d1948du/ni4PUUhpCnyA1yrwP4HhdM7HJf1SPCuM3DQfWOfXiTjJzFcwtvNbaewUTjtxFRG6zzDbz+W8cy6r6CC0DhFqaSng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781176766; c=relaxed/simple; bh=BFKcm0a5+pCf9HpTGuxNYm633tdLx40f3RyFxLVzlDk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TDs8eHw+Fr6DWDbTT1ORntprl8p2o8VlRd5Baa9mtVVTmC3Q6DDpgx8GqHzSHitZHqYrWHwrsw7VQvyLX20XqWpN46T5rriMCmHiKcNnClKm8FZF0RUqVpswHj3RtkdmXFwg0HpjxcMAJZz+Yh0ImYC8FoffsHureW22syVvYMs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=s5JDMEet; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="s5JDMEet" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EE7041E2F; Thu, 11 Jun 2026 04:19:18 -0700 (PDT) Received: from [10.164.19.15] (unknown [10.164.19.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 754853F99C; Thu, 11 Jun 2026 04:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1781176763; bh=BFKcm0a5+pCf9HpTGuxNYm633tdLx40f3RyFxLVzlDk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=s5JDMEetBzatj0KcVPyKtSrqxRZ0n8vyYYvVcEgtW/Da9QFMoTJTvCIvu5uV9WkOG s7WPy6RK4NQCasc80DpXJFR92QUOa/qIVMByPiIqf1TfTGD6rRvdMC0FouC5G34EUQ ApK8D6oWbMAnB3kV//fObcHOQ/bDDZvQK+G03cv4= Message-ID: Date: Thu, 11 Jun 2026 16:49:15 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests: mm: fix and speedup "droppable" test To: "David Hildenbrand (Arm)" , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , "Jason A. Donenfeld" , Anthony Yznaga , Mark Brown , Sarthak Sharma Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Aishwarya TCV References: <20260611-droppable_test-v1-1-b6a73d99f658@kernel.org> Content-Language: en-US From: Dev Jain In-Reply-To: <20260611-droppable_test-v1-1-b6a73d99f658@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/06/26 3:31 pm, David Hildenbrand (Arm) wrote: > The droppable test currently relies on creating memory pressure in a > child process to trigger dropping the droppable pages. > > That not only takes a long time on some machines (allocating and filling > all that memory), on large machines this will not work as we hardcode the > area size to 134217728 bytes. > > ... further, we rely on timeouts to detect that memory was not dropped, > which is really suboptimal. > > Instead, let's just use MADV_PAGEOUT on a 2 MiB region. MADV_PAGEOUT works > with droppable memory even without swap. > > There is the low chance of MADV_PAGEOUT failing to drop a page because > of speculative references. We'll wait 1s and retry 10 times to > rule that unlikely case out as best as we can. > > On a machine without swap: > > $ ./droppable > TAP version 13 > 1..1 > ok 1 madvise(MADV_PAGEOUT) behavior > # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0 > > Reported-by: Aishwarya TCV > Fixes: 9651fcedf7b9 ("mm: add MAP_DROPPABLE for designating always lazily freeable mappings") > Signed-off-by: David Hildenbrand (Arm) > --- > tools/testing/selftests/mm/droppable.c | 46 +++++++++++++++++++--------------- > 1 file changed, 26 insertions(+), 20 deletions(-) > > diff --git a/tools/testing/selftests/mm/droppable.c b/tools/testing/selftests/mm/droppable.c > index 30c8be37fcb9..57e1b6fc5569 100644 > --- a/tools/testing/selftests/mm/droppable.c > +++ b/tools/testing/selftests/mm/droppable.c > @@ -17,10 +17,10 @@ > > int main(int argc, char *argv[]) > { > - size_t alloc_size = 134217728; > - size_t page_size = getpagesize(); > + const size_t alloc_size = 2 * 1024 * 1024; > + int retry_count = 10; > + bool dropped; > void *alloc; > - pid_t child; > > ksft_print_header(); > ksft_set_plan(1); > @@ -35,26 +35,32 @@ int main(int argc, char *argv[]) > exit(KSFT_FAIL); > } > memset(alloc, 'A', alloc_size); > - for (size_t i = 0; i < alloc_size; i += page_size) > - assert(*(uint8_t *)(alloc + i)); > - > - child = fork(); > - assert(child >= 0); > - if (!child) { > - for (;;) > - *(char *)malloc(page_size) = 'B'; > - } > > - for (bool done = false; !done;) { > - for (size_t i = 0; i < alloc_size; i += page_size) { > - if (!*(uint8_t *)(alloc + i)) { > - done = true; > - break; > + while (retry_count--) { > + if (madvise(alloc, alloc_size, MADV_PAGEOUT)) { > + if (errno == EINVAL) { > + ksft_test_result_skip("madvise(MADV_PAGEOUT) not supported\n"); > + exit(KSFT_SKIP); > } > + ksft_test_result_fail("madvise(MADV_PAGEOUT) error: %s\n", strerror(errno)); > + exit(KSFT_FAIL); > } > + > + dropped = memchr(alloc, 'A', alloc_size) == NULL; > + > + /* > + * Speculative reference can temporarily prevent some > + * pages from getting dropped. So sleep and retry. > + * > + * If a page is not droppable for 10s, something > + * is seriously messed up and we want to fail. > + */ > + if (dropped) > + break; > + sleep(1); > } > - kill(child, SIGTERM); > > - ksft_test_result_pass("MAP_DROPPABLE: PASS\n"); > - exit(KSFT_PASS); > + ksft_test_result(dropped, "madvise(MADV_PAGEOUT) behavior\n"); You meant "MAP_DROPPABLE" behaviour? Perhaps that can be folded in. Otherwise LGTM. Reviewed-by: Dev Jain > + > + ksft_finished(); > } > > --- > > base-commit: d401506a8ee8ac6bc4a7767c17da036e9434a4a3 > > change-id: 20260611-droppable_test-3737bd791dfb > > -- > > Cheers, > > David > >