Page MenuHomeFreeBSD

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

Authored by stevek on Wed, Apr 3, 9:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 4:44 AM
Unknown Object (File)
Fri, Apr 19, 1:05 PM
Unknown Object (File)
Thu, Apr 11, 10:57 PM
Unknown Object (File)
Tue, Apr 9, 2:41 PM
Unknown Object (File)
Sat, Apr 6, 6:21 PM
Unknown Object (File)
Wed, Apr 3, 9:59 PM
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.Wed, Apr 3, 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.Thu, Apr 4, 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