<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 31, 2022 at 10:54 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
> Why not consider encapsulating these two new fields in 'struct<br>
> tst_hugepage' ?<br>
> <br>
> Then the tst_test in the case can simply initialize to:<br>
> <br>
> ....<br>
> static struct tst_test test = {<br>
>     .needs_root = 1,<br>
>     .taint_check = TST_TAINT_D | TST_TAINT_W,<br>
>     .setup = setup,<br>
>     .test_all = run_test,<br>
>     .hugepages = {1, TST_NEEDS, 1, 1},<br>
> };<br>
<br>
I do not like that we have magic constants in the .hugepages that are<br>
not self describing. I would treat the hugetltbfs just as we treat<br>
devfs, that would be:<br>
<br>
#define MNTPOINT "hugetlbfs/"<br>
#define HUGEFILE MNTPOINT "hugefile"<br>
<br>
static int huge_fd;<br>
<br>
static void setup(void)<br>
{<br>
        huge_fd = tst_creat_unlinked(HUGEFILE);<br>
        ...<br>
}<br>
<br>
static void cleanup(void)<br>
{<br>
        if (huge_fd > 0)<br>
                SAFE_CLOSE(huge_fd);<br>
}<br>
<br>
static struct tst_test test = {<br>
        ...<br>
        .mntpoint = MNTPOINT,<br>
        .needs_hugetlbfs = 1,<br>
        .setup = setup,<br>
        .cleanup = cleanup,<br>
        ...<br>
}<br>
<br>
<br>
What do you think?<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">+1 Looks good, this treats it as an FS and is separated from the hugepage usage.</div><div class="gmail_default" style="font-size:small"><br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>