tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Unused functions in kernels



Krister Walfridsson wrote:

> On Sun, 5 Jun 2016, Izumi Tsutsui wrote:
> 
> > It should be static instead?  (note fpu_cordic.c was added in 2013)
> > https://nxr.netbsd.org/search?q=fpu_cordit2&project=src
> 
> It is only used when CORDIC_BOOTSTRAP is defined (i.e. when running as a 
> standalone applicaion), so it should probably be moved into that section.

Ah, I see. I'll ask isaki@ (the author of the cordic based trigonometric
FPE functions) if it should be wraped by the bootstrap.

> > I wonder if others are really unused.
> > DCIU() is referred in sun3/sun3/sys_machdep.c and sun3/sun3/trap.c.
> > _Idle() is referred in sun3/sun3/clock.c, via an awful cast.
> > etc. etc.
> 
> DCIU() seems to be re-defined in sys/arch/m68k/include/cacheops.h
>    #define DCIU()          DCIU_20()
> so it does not seem like DCIU() from locore.s is used (and the kernel 
> built when I #if 0:ed it...)

Ah. This one might be missed m68k cacheops cleanup,
http://mail-index.netbsd.org/source-changes/2002/11/02/0062.html
but maybe we need double check why functions in sun3/locore.s were not
removed..

> For _Idle, it looks like its use is protected by LED_IDLE_CHECK in 
> clock.c, and LED_IDLE_CHECK is not set in in the GENERIC kernel...

Note _Idle is not a function but an address, as well as eintrcnt etc.

> That said, there are cases where my tool incorrectly claims symbols are 
> unused:
> [..]

There are more possible concerns:

* some ports have multiple GENERIC like kernels
  (sun3 also has GENERIC3X for 68030 based sun3x machines)

* some symbols are also prepared for userland binaries,
  like pmap(1) (which required kernel_text etc.) and vmstat(1)
  (that still refers historical eintrnames and eintrcnt) etc.

* some debug functions are designed to be called from ddb prompt
  after panic in the driver
  (like osiop_dump_trace() in sys/dev/ic/osiop.c etc)

* device drivers might have MI hooks which will be called some
  specific MD startup functions
  (like vga_reset() in sys/dev/ic/vga_subr.c)

Probably it's still better to use i386/conf/ALL rather than
(poor and rarely to be tested) Tier-II GENERIC, though
there are some exclusive options even in conf/ALL..

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index