From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8DF3C369AB for ; Thu, 24 Apr 2025 06:28:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E12E6B0006; Thu, 24 Apr 2025 02:28:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 690086B0007; Thu, 24 Apr 2025 02:28:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57E9C6B0008; Thu, 24 Apr 2025 02:28:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3B67C6B0006 for ; Thu, 24 Apr 2025 02:28:41 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 82E4B8031F for ; Thu, 24 Apr 2025 06:28:41 +0000 (UTC) X-FDA: 83367958842.11.83CFFA6 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf18.hostedemail.com (Postfix) with ESMTP id B8B9E1C0010 for ; Thu, 24 Apr 2025 06:28:38 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=nH6GAbVj; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf18.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745476119; a=rsa-sha256; cv=none; b=vpqJ6TBQ2tCCoAu6yDFApH3Kuly3ex6u0NxWcXxw6DPKAln2ywqw27hZ4gA1EMSWtrpw/E WcYs2zB8A0CrMDl8EUy7/5sUYb/O1/Q/mZ0nG4gxueZjhoX+PaRJNIa/X/aIi7GMI2LlfO jJmyGl6lABe+eXWE7mVJC2wQBSBK6Hw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=nH6GAbVj; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf18.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745476119; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wVkWw2jUzxAnlkfc6gLfJQociDbxExR7LUr/+zeyl20=; b=IoMWwWoAsR9uuH3/J86t5/ccZMcjIq4JdaTz7U7Tgo2Ny09zv3zcdmL0vWSBZrYCg7joHq bVm5qLXdDkIuUpBkplTVrfyHdiRBSiaH3PLSnDqJa2pAmCe/o1mSws1gEyJxz2maQy58Ix zD3w+qwR3p15G7oMO1mNoKxbLzTN2hU= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1745476115; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=wVkWw2jUzxAnlkfc6gLfJQociDbxExR7LUr/+zeyl20=; b=nH6GAbVjQCvoavubG4I6Gw/HR8/V0fK0Dn+kkBx41aYdMdeRlDOA8q0zs0yeOEraeVk/nk8G3PuRfCFY5KiHyDeLNIUhAGfXpnaVD/LieVOPiBhzPFlqTKxviHWa+174fER5BEZXkIJw2dYsD4VjwJiel062F8ruMJPNnulfrDY= Received: from 30.74.146.225(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WXxgDaN_1745476114 cluster:ay36) by smtp.aliyun-inc.com; Thu, 24 Apr 2025 14:28:34 +0800 Message-ID: Date: Thu, 24 Apr 2025 14:28:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests/mm: compaction_test: Support platform with huge mount of memory To: Feng Tang , Andrew Morton , Shuah Khan , Sri Jayaramappa , linux-mm@kvack.org, linux-kselftest@vger.kernel.org References: <20250423103645.2758-1-feng.tang@linux.alibaba.com> From: Baolin Wang In-Reply-To: <20250423103645.2758-1-feng.tang@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B8B9E1C0010 X-Stat-Signature: jkxa8akptkghb9ccfh6wd8g815pg1wu6 X-HE-Tag: 1745476118-429347 X-HE-Meta: U2FsdGVkX1+aZiqIcnXpCyb3EzODb50N4b8hYDg3ClrFYG+ywweL6Lqxc286NGcMPuLODPCCgqI6Qev04G3mMZVQvOnkl5yeiAC1uYccgkTeXgFlf4+MTmR8gkvfVYJCCZZAjogRdm+tRknex+UV6/2UByqfre7P6GHQYxbFTe7gz4watxW2vGxC6ElD8TSyy3pd9LQeZPLBUc3SOoY/4zzlBJu0I8cZ5Z/LVWQbC5eRbXsbVUAVoNKbijMDl58dl8FFgkstduYF/QsQBzXzDyrrHf4fnfmHPiT0XjKIZZjxY+mbGMAW6UdG6cWAKTJ36evJcwuIpdY8VJY5ff5VntrrA3z7iccPyn8DPdCzR1Yh6BLwFIjEnoBgmZzqBc9/PRTUiHtRYQMbBqyjToKcbWP0nc7n0DicjuE8vayHGwSn7yksBk++qdBjCZFeF5aISJ0wi1StI1GP4fPqPixi04ZgfCSFFtY8Eh2HS2bvBqPgL4swj1WXRZLrWA4SYdHgVnD7qi3efjOTZxfloGKlKAVbeU0Ca5Y0QxHwrixaW+GQI0C8SpD+jo8DkreIN3Dn4pyBdyQ5Lgt4Nc9FKsjfkLR2dz6qv5ObH2zPlGbOz/ClvSvPwETLPFUvPCzOtSjHFWuXKX5rCv169pyHx1zExcYMzWDtz2+mhshnfa75S7X2dENPYWa1wMEHi92qVqRSF0PwRVDDbjAjFIRYB45Lp4hYfrHN43ZnrrmJ49ka8QJL501G+JLvmmbAt2Ohv0m0lmkMWlGtz4Yfg0zgfFH1JcepUkIndpRXB82gVurvld7ZMXFOr6pCtT0HWGv5ym0NSQqaaDKJ8rKNXSx9EF9JKNfrKUTziXvlAXQ5Kfhnz4nBxKh75FPp8fwz2jU1BcRbUSVx9/GE29E86VLg+EzgG60dcHOwHp2Sy/Mns6iYzstd2phEN7BlP72muXT+bdpS9KXZ5p0puKA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2025/4/23 18:36, Feng Tang wrote: > When running mm selftest to verify mm patches, 'compaction_test' case > failed on an x86 server with 1TB memory. And the root cause is that it > has too much free memory than what the test supports. > > The test case tries to allocate 100000 huge pages, which is about 200 GB > for that x86 server, and when it succeeds, it expects it's large than > 1/3 of 80% of the free memory in system. This logic only works for > platform with 750 GB ( 200 / (1/3) / 80% ) or less free memory, and may > raise false alarm for others. > > Fix it by changing the fixed page number to self-adjustable number > according to the real number of free memory. > > Fixes: bd67d5c15cc19 ("Test compaction of mlocked memory") > Signed-off-by: Feng Tang Make sense to me. I tested it and passed on my platform. So: Reviewed-by: Baolin Wang Tested-by: Baolin Wang > --- > tools/testing/selftests/mm/compaction_test.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/mm/compaction_test.c b/tools/testing/selftests/mm/compaction_test.c > index 2c3a0eb6b22d..9bc4591c7b16 100644 > --- a/tools/testing/selftests/mm/compaction_test.c > +++ b/tools/testing/selftests/mm/compaction_test.c > @@ -90,6 +90,8 @@ int check_compaction(unsigned long mem_free, unsigned long hugepage_size, > int compaction_index = 0; > char nr_hugepages[20] = {0}; > char init_nr_hugepages[24] = {0}; > + char target_nr_hugepages[24] = {0}; > + int slen; > > snprintf(init_nr_hugepages, sizeof(init_nr_hugepages), > "%lu", initial_nr_hugepages); > @@ -106,11 +108,18 @@ int check_compaction(unsigned long mem_free, unsigned long hugepage_size, > goto out; > } > > - /* Request a large number of huge pages. The Kernel will allocate > - as much as it can */ > - if (write(fd, "100000", (6*sizeof(char))) != (6*sizeof(char))) { > - ksft_print_msg("Failed to write 100000 to /proc/sys/vm/nr_hugepages: %s\n", > - strerror(errno)); > + /* > + * Request huge pages for about half of the free memory. The Kernel > + * will allocate as much as it can, and we expect it will get at least 1/3 > + */ > + nr_hugepages_ul = mem_free / hugepage_size / 2; > + snprintf(target_nr_hugepages, sizeof(target_nr_hugepages), > + "%lu", nr_hugepages_ul); > + > + slen = strlen(target_nr_hugepages); > + if (write(fd, target_nr_hugepages, slen) != slen) { > + ksft_print_msg("Failed to write %lu to /proc/sys/vm/nr_hugepages: %s\n", > + nr_hugepages_ul, strerror(errno)); > goto close_fd; > } >