public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Wei Gao via ltp <ltp@lists.linux.it>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v7 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code
Date: Wed, 26 Mar 2025 05:11:39 -0400	[thread overview]
Message-ID: <Z+PEy9Ap9OBeNDkI@wegao> (raw)
In-Reply-To: <CAEemH2dNduMxZZzvC-ENpCMLcrD7CXYuV8iLsRJXisRu6LLSLA@mail.gmail.com>

On Wed, Mar 26, 2025 at 03:38:35PM +0800, Li Wang wrote:
> On Wed, Mar 26, 2025 at 12:15 PM Wei Gao via ltp <ltp@lists.linux.it> wrote:
> 
> > On Tue, Mar 25, 2025 at 03:00:18PM +0100, Petr Vorel wrote:
> > > Hi Wei,
> > >
> > > ...
> > > > +static void run_test(void)
> > > > +{
> > > > +   int pid;
> > > > +   char node_id_str[256];
> > > > +
> > > > +   cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
> > > > +
> > > > +   sprintf(node_id_str, "%u", check_node_id);
> > > > +   SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
> > > > +   SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 1);
> > >
> > > You changed the /proc/sys/vm/nr_hugepages to 1, because Cyril objected
> > the code
> > > in v6:
> > >
> > > SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);
> > >
> > > But as I note there [1], the original shell test did it this way and
> > kernel docs
> > > allows more than 1 to allocate. I'm obviously missing something.
> > >
> > > [1] https://lore.kernel.org/ltp/20250325133611.GB372417@pevik/
> > >
> > My understanding from Cyril's comments is no need reserve more hugepages,
> > since
> > this test case ONLY allocate 1 page through mmap.
> 
> 
> It depends on what you wanted there, if only 1 general huge page,
>  `echo 1 > /proc/sys/vm/nr_hugepages` will try to reserve 1
> from a NUMA node randomly.
Thanks for your valuable information, now i guess i find out why 
original code using 2 * node->cnt instead of 1, it try to make 
sure every node have at least reserve some pages.
> 
> But if you prefer to get 1 hugepage from a specified node, we need:
>  `echo 1 >
> /sys/devices/system/node/node%u/hugepages/hugepages-%dkB/nr_hugepages`
> 
> However, both ways won't guarantee the reservation will be 100% successful,
> which is based on the memory fragmentation situations.
> 
> To be on the safe side, I would suggest using LTP unified API to reserve:
> https://github.com/linux-test-project/ltp/blob/master/doc/old/C-Test-API.asciidoc#134-reserving-hugepages
> 
> You could reference usage from:
>   mem/hugetlb/hugemmap/hugemmap16.c,
>   syscalls/move_pages/move_pages12.c
This case is check allocate memory on specific node, so if we set .hugepages = {1, TST_NEEDS}, 
then 1 page will reserve on NUMA node randomly, that means case still has chance to fail.
Also i guess current .hugepages can not support ".hugepages = {2 * node->cnt, TST_NEEDS}"
So the easy way is keep v6 implementation like following:
SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

Correct me if any misunderstanding.
> 
> 
> 
> >
> > @Cyril could you help confirm this?
> >
> > >
> > > Kind regards,
> > > Petr
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
> >
> >
> 
> -- 
> Regards,
> Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2025-03-26  9:12 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-01 10:40 [LTP] [PATCH v1] cpuset_memory_test.c: Use $TMPDIR as prefix for HUGEPAGE file path Wei Gao via ltp
2024-08-01 12:16 ` Petr Vorel
2024-08-01 12:20 ` Cyril Hrubis
2024-08-19  4:49 ` [LTP] [PATCH v2] cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase Wei Gao via ltp
2024-09-26  6:19   ` [LTP] [PATCH v3] " Wei Gao via ltp
2024-09-27 10:30     ` Cyril Hrubis
2024-09-30 13:58     ` [LTP] [PATCH v4] " Wei Gao via ltp
2024-11-01 10:58       ` Petr Vorel
2024-11-05  5:30         ` Wei Gao via ltp
2024-11-05 11:44       ` Petr Vorel
2024-11-07  4:20         ` Wei Gao via ltp
2024-11-08  5:45         ` Wei Gao via ltp
2024-12-09  6:01       ` [LTP] [PATCH v5 0/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code Wei Gao via ltp
2024-12-09  6:01         ` [LTP] [PATCH v5 1/2] " Wei Gao via ltp
2025-02-27 16:02           ` Petr Vorel
2024-12-09  6:01         ` [LTP] [PATCH v5 2/2] cpuset_memory_testset.sh: Remove test6 Wei Gao via ltp
2025-02-27 16:04           ` Petr Vorel
2025-03-05  4:29             ` Wei Gao via ltp
2025-03-05  5:08         ` [LTP] [PATCH v6 0/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code Wei Gao via ltp
2025-03-05  5:08           ` [LTP] [PATCH v6 1/2] " Wei Gao via ltp
2025-03-06 18:35             ` Petr Vorel
2025-03-10 16:51             ` Cyril Hrubis
2025-03-25 13:36               ` Petr Vorel
2025-03-05  5:08           ` [LTP] [PATCH v6 2/2] cpuset_memory_testset.sh: Remove test6 Wei Gao via ltp
2025-03-06 18:32             ` Petr Vorel
2025-03-24 12:00           ` [LTP] [PATCH v7 0/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code Wei Gao via ltp
2025-03-24 12:00             ` [LTP] [PATCH v7 1/2] " Wei Gao via ltp
2025-03-25 14:00               ` Petr Vorel
2025-03-26  4:14                 ` Wei Gao via ltp
2025-03-26  7:38                   ` Li Wang via ltp
2025-03-26  8:26                     ` Li Wang via ltp
2025-03-26  9:11                     ` Wei Gao via ltp [this message]
2025-03-26 11:01                       ` Li Wang via ltp
2025-03-26  8:38                 ` Li Wang via ltp
2025-03-24 12:00             ` [LTP] [PATCH v7 2/2] cpuset_memory_testset.sh: Remove test6 Wei Gao via ltp
2025-03-24 15:32               ` Petr Vorel
2025-03-25  3:32                 ` Wei Gao via ltp
2025-03-25  3:54                   ` Wei Gao via ltp
2025-03-28  7:59             ` [LTP] [PATCH v8 0/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code Wei Gao via ltp
2025-03-28  7:59               ` [LTP] [PATCH v8 1/2] " Wei Gao via ltp
2025-03-28  9:35                 ` Li Wang via ltp
2025-03-28 10:20                   ` Petr Vorel
2025-03-28 10:57                     ` Li Wang via ltp
2025-03-28 11:04                       ` Li Wang via ltp
2025-03-28 11:47                       ` Petr Vorel
2025-03-28  7:59               ` [LTP] [PATCH v8 2/2] cpuset_memory_testset.sh: Remove test6 Wei Gao via ltp
2025-03-31  3:19               ` [LTP] [PATCH v9 0/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code Wei Gao via ltp
2025-03-31  3:19                 ` [LTP] [PATCH v9 1/2] " Wei Gao via ltp
2025-03-31  5:05                   ` Li Wang via ltp
2025-03-31  6:13                     ` Wei Gao via ltp
2025-03-31 10:25                     ` Petr Vorel
2025-03-31 10:37                   ` Petr Vorel
2025-03-31 11:05                     ` Li Wang via ltp
2025-03-31 11:30                     ` Wei Gao via ltp
2025-03-31  3:19                 ` [LTP] [PATCH v9 2/2] cpuset_memory_testset.sh: Remove test6 Wei Gao via ltp
2025-03-31  5:05                   ` Li Wang via ltp
2025-03-31 10:58                   ` Petr Vorel
2025-03-31 10:21                 ` [LTP] [PATCH v9 0/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code Petr Vorel
2025-03-31 13:25                 ` [LTP] [PATCH v10 " Wei Gao via ltp
2025-03-31 13:25                   ` [LTP] [PATCH v10 1/2] " Wei Gao via ltp
2025-04-01  9:58                     ` Li Wang via ltp
2025-03-31 13:25                   ` [LTP] [PATCH v10 2/2] cpuset_memory_testset.sh: Remove test6 Wei Gao via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z+PEy9Ap9OBeNDkI@wegao \
    --to=ltp@lists.linux.it \
    --cc=liwang@redhat.com \
    --cc=wegao@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox