On Mon, Mar 30, 2026 at 08:02:01AM +0200, David Hildenbrand (Arm) wrote:
> > /* Open the file to DIO */
>
> This comment is misleading as we are not opening "the" file, but we create a
> new one.
> See below, maybe we should clean that up.
+1
> > int main(void)
> > {
> > - size_t pagesize = 0;
> > - int fd;
> > + size_t pagesize = psize();
> > + unsigned int dio_align = get_dio_alignment();
>
> Both could be const.
+1
> 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!
--
Regards,
Li Wang