[LTP] hugetlb/hugefallocate: Add hugefallocate03 to stress test fallocate on hugetlbfs
Cyril Hrubis
chrubis@suse.cz
Mon Nov 2 16:59:39 CET 2026
Hi!
> > + SAFE_SIGACTION(SIGBUS, &sa, NULL);
> > +
> > + fault_mmap_addr = SAFE_MMAP(NULL, max_hpages * hpage_size,
> > + PROT_READ | PROT_WRITE, MAP_SHARED,
> > + fd, 0);
> > +
> > + pthread_cleanup_push(thread_fault_cleanup, NULL);
> > +
> > + while (1) {
> > + tpage = ((long long)random()) % (max_hpages);
> > +
> > + if (sigsetjmp(fault_jmp, 1) == 0) {
> > + foo = *((char *)(fault_mmap_addr + (tpage * hpage_size)));
> > + *((volatile char *)(fault_mmap_addr + (tpage * hpage_size))) = foo;
> > + }
>
> Save the original SIGBUS handler and restore it upon thread termination or in
> cleanup. If SIGBUS is raised after this thread terminates, siglongjmp() jumps
> to an invalid stack.
More generally we can just remove all the thread cleanup registration
and cancelation points if we just do:
static volatile int run;
...
void *pthread_func(void *)
{
...
while (run) {
...
}
SAFE_MUNMAP(...);
reutrn NULL;
}
The main thread can then stop all three threads by setting run = 0 and
the cleanup runs without the pthread cleanup complexity.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list