Page MenuHomeFreeBSD

vm: add macro to mark arguments used when NUMA is defined
ClosedPublic

Authored by stevek on Apr 3 2024, 9:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 3 2024, 3:27 PM
Unknown Object (File)
Oct 3 2024, 1:17 PM
Unknown Object (File)
Oct 2 2024, 11:57 PM
Unknown Object (File)
Sep 30 2024, 2:00 PM
Unknown Object (File)
Sep 27 2024, 5:32 PM
Unknown Object (File)
Sep 26 2024, 12:10 AM
Unknown Object (File)
Sep 24 2024, 11:37 PM
Unknown Object (File)
Sep 17 2024, 7:38 AM
Subscribers

Details

Summary

This fixes compiler warnings when -Wunused-arguments is enabled and
not quieted.

Obtained from: Juniper Networks, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

stevek requested review of this revision.Apr 3 2024, 9:11 PM
stevek created this revision.

I have some bad feeling about all that <feature>_unused macros. Would it better to change it to unconditionally apply unused globall?

This revision is now accepted and ready to land.Apr 4 2024, 2:47 AM
In D44623#1017481, @kib wrote:

I have some bad feeling about all that <feature>_unused macros. Would it better to change it to unconditionally apply unused globall?

I guess __unused has no effect if the compiler can observe that the annotated variable is in fact used? Maybe it would trigger warnings?

I don't really like all the __unused aliases either, but I also don't want to just use __unused everywhere, it would be confusing.

In D44623#1017481, @kib wrote:

I have some bad feeling about all that <feature>_unused macros. Would it better to change it to unconditionally apply unused globall?

I guess __unused has no effect if the compiler can observe that the annotated variable is in fact used? Maybe it would trigger warnings?

I don't really like all the __unused aliases either, but I also don't want to just use __unused everywhere, it would be confusing.

gcc manual describes the attribute((unused)) as possible unused, with the only mentioned consequence of gcc not issuing warning if really unused.

In D44623#1017858, @kib wrote:
In D44623#1017481, @kib wrote:

I have some bad feeling about all that <feature>_unused macros. Would it better to change it to unconditionally apply unused globall?

I guess __unused has no effect if the compiler can observe that the annotated variable is in fact used? Maybe it would trigger warnings?

I don't really like all the __unused aliases either, but I also don't want to just use __unused everywhere, it would be confusing.

gcc manual describes the attribute((unused)) as possible unused, with the only mentioned consequence of gcc not issuing warning if really unused.

I believe it only suppresses warnings that the compiler would generate. Although, it can sometimes confuse people when one flags an argument as unused, but it is actually used.

Mismarking __unused is harmless

Do you want me to just switch things to use __unused instead of the macros to conditionally add it?

Go ahead with the current patch.

What about stub functions for !NUMA ?
For example, converting

static inline int
vm_page_domain(vm_page_t m)
{
#ifdef NUMA
	int domn, segind;

	segind = m->segind;
	KASSERT(segind < vm_phys_nsegs, ("segind %d m %p", segind, m));
	domn = vm_phys_segs[segind].domain;
	KASSERT(domn >= 0 && domn < vm_ndomains, ("domain %d m %p", domn, m));
	return (domn);
#else
	return (0);
#endif
}

to

#ifdef NUMA
static inline int
vm_page_domain(vm_page_t m)
{
	int domn, segind;

	segind = m->segind;
	KASSERT(segind < vm_phys_nsegs, ("segind %d m %p", segind, m));
	domn = vm_phys_segs[segind].domain;
	KASSERT(domn >= 0 && domn < vm_ndomains, ("domain %d m %p", domn, m));
	return (domn);
}
#else
static inline int
vm_page_domain(vm_page_t m __unused)
{

	return (0);
}
#endif