From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Li Wang <liwang@redhat.com>
Cc: akpm@linux-foundation.org, rppt@kernel.org, ljs@kernel.org,
Liam.Howlett@oracle.com, vbabka@kernel.org, surenb@google.com,
mhocko@suse.com, shuah@kernel.org, aubaker@redhat.com,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3] selftests/mm: skip hugetlb_dio tests when DIO alignment is incompatible
Date: Mon, 30 Mar 2026 12:43:26 +0200 [thread overview]
Message-ID: <a1054c28-b574-4fcc-afe9-5e902209a22c@kernel.org> (raw)
In-Reply-To: <acpMD8tRCJhgXHeg@redhat.com>
On 3/30/26 12:10, Li Wang wrote:
>>> Why can't we simply open the file once and pass the fd to run_dio_using_hugetlb()?
>>>
>>> fd = open("/tmp", O_TMPFILE | O_RDWR | O_DIRECT, 0664);
>>> if (fd < 0)
>>> ksft_exit_skip("Unable to allocate file: %s\n", strerror(errno));
>>> dio_align = get_dio_alignment(fd);
>>> if (dio_align <= 0)
>>> ksft_exit_skip("Unable to obtain DIO alignment: %s\n", strerror(errno));
>>
>> Yes, apparently this is a good suggestion. Thanks!
>
> And, to make the test elegant, I'm going to add check_dio_alignment() dedicated
> to alignment checking. Then we don't need to pass too many args.
>
> Tell me your thoughts if you don't like this:
>
> static int get_dio_alignment(int fd)
> {...}
>
> static bool check_dio_alignment(unsigned int start_off, unsigned int end_off)
> {...}
>
> static void run_test(int fd, unsigned int start_off, unsigned int end_off)
> {
> if (!check_dio_alignment(start_off, end_off))
> return;
>
> run_dio_using_hugetlb(fd, start_off, end_off);
> }
>
> int main(void)
> {
> ...
> fd = open("/tmp", O_TMPFILE | O_RDWR | O_DIRECT, 0664);
> if (fd < 0)
> ksft_exit_skip("Unable to allocate file: %s\n", strerror(errno));
>
> if (get_dio_alignment(fd) < 0)
I would suggest that you query the alignment only once, and forward it
to the test.
--
Cheers,
David
next prev parent reply other threads:[~2026-03-30 10:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 5:39 Li Wang
2026-03-30 6:02 ` David Hildenbrand (Arm)
2026-03-30 7:23 ` Li Wang
2026-03-30 10:10 ` Li Wang
2026-03-30 10:43 ` David Hildenbrand (Arm) [this message]
2026-03-30 11:35 ` Li Wang
2026-03-30 11:57 ` Li Wang
2026-03-30 9:58 ` Li Wang
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=a1054c28-b574-4fcc-afe9-5e902209a22c@kernel.org \
--to=david@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=aubaker@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liwang@redhat.com \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/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