kernel-doc overly verbose with V=0
Subsystems (2)
Hi,
I recently saw some strange behavior with the Python kernel-doc. I was seeing the verbose info lines from the kernel-doc script, i.e.:
Quoted 19 lines
Info: ice_ptp_hw.c:5377 Scanning doc for function
ice_cgu_get_pin_freq_supp
Info: ice_ptp_hw.c:5406 Scanning doc for functionice_cgu_get_pin_name
Info: ice_ptp_hw.c:5441 Scanning doc for functionice_cgu_state_to_name
Info: ice_ptp_hw.c:5463 Scanning doc for functionice_get_dpll_ref_sw_status
Info: ice_ptp_hw.c:5505 Scanning doc for functionice_set_dpll_ref_sw_status
Info: ice_ptp_hw.c:5544 Scanning doc for functionice_get_cgu_state
Info: ice_ptp_hw.c:5612 Scanning doc for functionice_get_cgu_rclk_pin_info
Info: ice_ptp_hw.c:5671 Scanning doc for functionice_cgu_get_output_pin_state_caps
Info: ice_ptp_hw.c:5733 Scanning doc for functionice_ptp_lock
Info: ice_ptp_hw.c:5770 Scanning doc for functionice_ptp_unlock
Info: ice_ptp_hw.c:5782 Scanning doc for functionice_ptp_init_hw
Info: ice_ptp_hw.c:5811 Scanning doc for functionice_ptp_write_port_cmd
Info: ice_ptp_hw.c:5834 Scanning doc for functionice_ptp_one_port_cmd
Info: ice_ptp_hw.c:5866 Scanning doc for functionice_ptp_port_cmd
Info: ice_ptp_hw.c:5901 Scanning doc for functionice_ptp_tmr_cmd
Info: ice_ptp_hw.c:5934 Scanning doc for functionice_ptp_init_time
Info: ice_ptp_hw.c:5986 Scanning doc for functionice_ptp_write_incval
Info: ice_ptp_hw.c:6035 Scanning doc for functionice_ptp_write_incval_locked
Info: ice_ptp_hw.c:6056 Scanning doc for functionice_ptp_adj_clock
Quoted 8 lines
Info: ice_ptp_hw.c:6107 Scanning doc for function
ice_read_phy_tstamp
Info: ice_ptp_hw.c:6134 Scanning doc for functionice_clear_phy_tstamp
Info: ice_ptp_hw.c:6164 Scanning doc for functionice_ptp_reset_ts_memory
Info: ice_ptp_hw.c:6183 Scanning doc for functionice_ptp_init_phc
Info: ice_ptp_hw.c:6215 Scanning doc for functionice_get_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6247 Scanning doc for functionice_check_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6273 Scanning doc for functionice_ptp_config_sfd
Info: ice_ptp_hw.c:6293 Scanning doc for functionrefsync_pin_id_valid
I didn't understand why I was seeing this as it should only be happening if running kernel-doc in verbose mode. Then I discovered I had set KBUILD_VERBOSE=0 in my environment.
The python kernel-doc implementation reads this in the __init__ for KernelFiles() on line 165:
Quoted 2 lines
if not verbose:
verbose =bool(os.environ.get("KBUILD_VERBOSE", 0))
After some debugging, I realized this reads KBUILD_VERBOSE as a string, then converts it to a boolean using python's standard rules, so "0" becomes true, which enables the verbose output.
This is in contrast to the (now removed) kernel-doc.pl script which checked the value for a 1:
Quoted 1 line
if (
defined($ENV{'KBUILD_VERBOSE'})&& $ENV{'KBUILD_VERBOSE'} =~ '1')
The same behavior happens if you assign V=0 on the command line or to any other non-empty string, since when V is set on the command line it sets KBUILD_VERBOSE.
Of course, I can remove KBUILD_VERBOSE from my environment, I'm not entirely sure when or why I added it.
Would think it would make sense to update the kdoc_files.py script to check and interpret the string value the same way the perl script used to? It seems reasonable to me that users might set "V=0" thinking that it disables the verbosity. Other verbosity checks are based on the string containing a 1, (some even use 2 for even more printing).
I'm not entirely sure what the best implementation for python is to avoid this misinterpretation, so I haven't drafted a proper patch yet.
Thanks,
Jake
Quoted 40 lines · On Tue, 24 Mar 2026 13:37:39 -0700 Jacob Keller <[email protected]>…
Hi,
I recently saw some strange behavior with the Python kernel-doc. I was seeing the verbose info lines from the kernel-doc script, i.e.:
Quoted 19 lines
Info: ice_ptp_hw.c:5377 Scanning doc for function
ice_cgu_get_pin_freq_supp
Info: ice_ptp_hw.c:5406 Scanning doc for functionice_cgu_get_pin_name
Info: ice_ptp_hw.c:5441 Scanning doc for functionice_cgu_state_to_name
Info: ice_ptp_hw.c:5463 Scanning doc for functionice_get_dpll_ref_sw_status
Info: ice_ptp_hw.c:5505 Scanning doc for functionice_set_dpll_ref_sw_status
Info: ice_ptp_hw.c:5544 Scanning doc for functionice_get_cgu_state
Info: ice_ptp_hw.c:5612 Scanning doc for functionice_get_cgu_rclk_pin_info
Info: ice_ptp_hw.c:5671 Scanning doc for functionice_cgu_get_output_pin_state_caps
Info: ice_ptp_hw.c:5733 Scanning doc for functionice_ptp_lock
Info: ice_ptp_hw.c:5770 Scanning doc for functionice_ptp_unlock
Info: ice_ptp_hw.c:5782 Scanning doc for functionice_ptp_init_hw
Info: ice_ptp_hw.c:5811 Scanning doc for functionice_ptp_write_port_cmd
Info: ice_ptp_hw.c:5834 Scanning doc for functionice_ptp_one_port_cmd
Info: ice_ptp_hw.c:5866 Scanning doc for functionice_ptp_port_cmd
Info: ice_ptp_hw.c:5901 Scanning doc for functionice_ptp_tmr_cmd
Info: ice_ptp_hw.c:5934 Scanning doc for functionice_ptp_init_time
Info: ice_ptp_hw.c:5986 Scanning doc for functionice_ptp_write_incval
Info: ice_ptp_hw.c:6035 Scanning doc for functionice_ptp_write_incval_locked
Info: ice_ptp_hw.c:6056 Scanning doc for functionice_ptp_adj_clockQuoted 8 lines
Info: ice_ptp_hw.c:6107 Scanning doc for function
ice_read_phy_tstamp
Info: ice_ptp_hw.c:6134 Scanning doc for functionice_clear_phy_tstamp
Info: ice_ptp_hw.c:6164 Scanning doc for functionice_ptp_reset_ts_memory
Info: ice_ptp_hw.c:6183 Scanning doc for functionice_ptp_init_phc
Info: ice_ptp_hw.c:6215 Scanning doc for functionice_get_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6247 Scanning doc for functionice_check_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6273 Scanning doc for functionice_ptp_config_sfd
Info: ice_ptp_hw.c:6293 Scanning doc for functionrefsync_pin_id_validI didn't understand why I was seeing this as it should only be happening if running kernel-doc in verbose mode. Then I discovered I had set KBUILD_VERBOSE=0 in my environment.
The python kernel-doc implementation reads this in the
__init__forKernelFiles()on line 165:
Quoted 6 lines
Quoted 2 lines
if not verbose:
verbose =bool(os.environ.get("KBUILD_VERBOSE", 0))After some debugging, I realized this reads
KBUILD_VERBOSEas a string, then converts it to a boolean using python's standard rules, so "0" becomes true, which enables the verbose output.
Looking at tools/docs/sphinx-build-wrapper, it implements verbosity by doing:
verbose = bool(os.environ.get("KBUILD_VERBOSE", "") != "")which will also have the same problem as the one you detected.
Perhaps the right fix would be to first convert to int then to bool on both places, in a way that "" will also be handled properly. Perhaps with:
try:
verbose = bool(int(os.environ.get("KBUILD_VERBOSE", 0)))
except ValueError:
# Handles an eventual case where verbosity is not a number # like KBUILD_VERBOSE=""
verbose = False
Quoted 7 lines
This is in contrast to the (now removed) kernel-doc.pl script which checked the value for a 1:
Quoted 1 line
if (
defined($ENV{'KBUILD_VERBOSE'})&& $ENV{'KBUILD_VERBOSE'} =~ '1')The same behavior happens if you assign V=0 on the command line or to any other non-empty string, since when V is set on the command line it sets
KBUILD_VERBOSE.
That's funny... we did test make V=0 htmldocs / make V=1 htmldocs
It sounds that the problem is only if you explicitly set it without relying on gnu make.
Quoted 8 lines
Of course, I can remove
KBUILD_VERBOSEfrom my environment, I'm not entirely sure when or why I added it.Would think it would make sense to update the
kdoc_files.pyscript to check and interpret the string value the same way the perl script used to? It seems reasonable to me that users might set "V=0" thinking that it disables the verbosity. Other verbosity checks are based on the string containing a 1,
kernel-doc has a set of "-W" flags to control its verbosity. Direct support for KBUILD_VERBOSE was added there just to make it bug-compatible with kernel-doc.pl when building via Makefile.
Yet, as using it via "make htmldocs" don't use "-W", IMO it makes sense to ensure that "-Wall" is enabled if V=1.
Quoted 1 line
(some even use 2 for even more printing).
Documentation had support for V=2, but this was dropped on this commit:
c0d3b83100c8 ("kbuild: do not print extra logs for V=2")Quoted 2 lines
I'm not entirely sure what the best implementation for python is to avoid this misinterpretation, so I haven't drafted a proper patch yet.
Perhaps something like the patch below (untested).
Signature · 13 lines
Thanks, Mauro [PATCH] doc tools: better handle KBUILD_VERBOSE As reported by Jacob, there are troubles when KBUILD_VERBOSE is set at the environment. Fix it on both kernel-doc and sphinx-build-wrapper. Reported-by: Jacob Keller <[email protected]> Closes: https://lore.kernel.org/linux-doc/[email protected]/ Signed-off-by: Mauro Carvalho Chehab <[email protected]>
tools/docs/sphinx-build-wrapper +6 -1
@@ -238,7 +238,12 @@ class SphinxBuilder: self.latexopts = os.environ.get("LATEXOPTS", "") if not verbose: - verbose = bool(os.environ.get("KBUILD_VERBOSE", "") != "") + try: + verbose = bool(int(os.environ.get("KBUILD_VERBOSE", 0))) + except ValueError: + # Handles an eventual case where verbosity is not a number + # like KBUILD_VERBOSE="" + verbose = False if verbose is not None: self.verbose = verbose
tools/lib/python/kdoc/kdoc_files.py +16 -1
@@ -238,7 +238,22 @@ class KernelFiles(): """ if not verbose: - verbose = bool(os.environ.get("KBUILD_VERBOSE", 0)) + try: + verbose = bool(int(os.environ.get("KBUILD_VERBOSE", 0))) + except ValueError: + # Handles an eventual case where verbosity is not a number + # like KBUILD_VERBOSE="" + verbose = False + + # + # kernel-doc logic was likelly called via Sphinx. + # Enable all warnings. + # + if verbose: + werror=True + wreturn=True + wshort_desc=True + wcontents_before_sections=True if out_style is None: out_style = OutputFormat()
Quoted 50 lines · Mauro Carvalho Chehab
Quoted 40 lines · On Tue, 24 Mar 2026 13:37:39 -0700 Jacob Keller <[email protected]>…
Hi,
I recently saw some strange behavior with the Python kernel-doc. I was seeing the verbose info lines from the kernel-doc script, i.e.:
Quoted 19 lines
Info: ice_ptp_hw.c:5377 Scanning doc for function
ice_cgu_get_pin_freq_supp
Info: ice_ptp_hw.c:5406 Scanning doc for functionice_cgu_get_pin_name
Info: ice_ptp_hw.c:5441 Scanning doc for functionice_cgu_state_to_name
Info: ice_ptp_hw.c:5463 Scanning doc for functionice_get_dpll_ref_sw_status
Info: ice_ptp_hw.c:5505 Scanning doc for functionice_set_dpll_ref_sw_status
Info: ice_ptp_hw.c:5544 Scanning doc for functionice_get_cgu_state
Info: ice_ptp_hw.c:5612 Scanning doc for functionice_get_cgu_rclk_pin_info
Info: ice_ptp_hw.c:5671 Scanning doc for functionice_cgu_get_output_pin_state_caps
Info: ice_ptp_hw.c:5733 Scanning doc for functionice_ptp_lock
Info: ice_ptp_hw.c:5770 Scanning doc for functionice_ptp_unlock
Info: ice_ptp_hw.c:5782 Scanning doc for functionice_ptp_init_hw
Info: ice_ptp_hw.c:5811 Scanning doc for functionice_ptp_write_port_cmd
Info: ice_ptp_hw.c:5834 Scanning doc for functionice_ptp_one_port_cmd
Info: ice_ptp_hw.c:5866 Scanning doc for functionice_ptp_port_cmd
Info: ice_ptp_hw.c:5901 Scanning doc for functionice_ptp_tmr_cmd
Info: ice_ptp_hw.c:5934 Scanning doc for functionice_ptp_init_time
Info: ice_ptp_hw.c:5986 Scanning doc for functionice_ptp_write_incval
Info: ice_ptp_hw.c:6035 Scanning doc for functionice_ptp_write_incval_locked
Info: ice_ptp_hw.c:6056 Scanning doc for functionice_ptp_adj_clockQuoted 8 lines
Info: ice_ptp_hw.c:6107 Scanning doc for function
ice_read_phy_tstamp
Info: ice_ptp_hw.c:6134 Scanning doc for functionice_clear_phy_tstamp
Info: ice_ptp_hw.c:6164 Scanning doc for functionice_ptp_reset_ts_memory
Info: ice_ptp_hw.c:6183 Scanning doc for functionice_ptp_init_phc
Info: ice_ptp_hw.c:6215 Scanning doc for functionice_get_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6247 Scanning doc for functionice_check_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6273 Scanning doc for functionice_ptp_config_sfd
Info: ice_ptp_hw.c:6293 Scanning doc for functionrefsync_pin_id_validI didn't understand why I was seeing this as it should only be happening if running kernel-doc in verbose mode. Then I discovered I had set KBUILD_VERBOSE=0 in my environment.
The python kernel-doc implementation reads this in the
__init__forKernelFiles()on line 165:Quoted 6 lines
Quoted 2 lines
if not verbose:
verbose =bool(os.environ.get("KBUILD_VERBOSE", 0))After some debugging, I realized this reads
KBUILD_VERBOSEas a string, then converts it to a boolean using python's standard rules, so "0" becomes true, which enables the verbose output.
Quoted 7 lines
Looking at
tools/docs/sphinx-build-wrapper, it implements verbosity by doing:verbose = bool(os.environ.get("KBUILD_VERBOSE", "") != "")which will also have the same problem as the one you detected.
Yep.
Quoted 11 lines
Perhaps the right fix would be to first convert to int then to bool on both places, in a way that "" will also be handled properly. Perhaps with:
try:
verbose =bool(int(os.environ.get("KBUILD_VERBOSE", 0)))
except ValueError:
# Handles an eventual case where verbosity is not a number # like KBUILD_VERBOSE=""
verbose = FalseQuoted 1 line
Quoted 1 line
This is in contrast to the (now removed) kernel-doc.pl script which
Quoted 9 lines
Quoted 6 lines
checked the value for a 1:
Quoted 1 line
if (
defined($ENV{'KBUILD_VERBOSE'})&& $ENV{'KBUILD_VERBOSE'} =~ '1')The same behavior happens if you assign V=0 on the command line or to any other non-empty string, since when V is set on the command line it sets
KBUILD_VERBOSE.That's funny... we did test make V=0 htmldocs / make V=1 htmldocs
Strange. The Makefile does this:
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
I can see KBUILD_VERBOSE=0 from the top level Makefile, but you're right it doesn't seem to trigger the environment variable..
Quoted 3 lines
It sounds that the problem is only if you explicitly set it without relying on gnu make.
Adding some warn prints I do see the Makefile sets KBUILD_VERBOSE=0 when you do V=0.. and it has an export clause for KBUILD_VERBOSE
Oh, it might be your particular build doesn't have W=1 so checkdoc isn't being defined and thus kernel-doc isn't running?
If I do "make W=1 V=0" I do actually see these lines:
Quoted 49 lines
Info:
../drivers/pci/pci.c:3646Scanning doc for functionpci_acs_init
Info:../drivers/pci/pci.c:3663Scanning doc for functionpci_enable_atomic_ops_to_root
Info:../drivers/pci/pci.c:3746Scanning doc for functionpci_release_region
Info:../drivers/pci/pci.c:3772Scanning doc for function__pci_request_region
Info:../drivers/pci/pci.c:3820Scanning doc for functionpci_request_region
Info:../drivers/pci/pci.c:3841Scanning doc for functionpci_release_selected_regions
Info:../drivers/pci/pci.c:3879Scanning doc for functionpci_request_selected_regions
Info:../drivers/pci/pci.c:3894Scanning doc for functionpci_request_selected_regions_exclusive
Info:../drivers/pci/pci.c:3910Scanning doc for functionpci_release_regions
Info:../drivers/pci/pci.c:3925Scanning doc for functionpci_request_regions
Info:../drivers/pci/pci.c:3944Scanning doc for functionpci_request_regions_exclusive
Info:../drivers/pci/pci.c:4026Scanning doc for functionpci_remap_iospace
Info:../drivers/pci/pci.c:4062Scanning doc for functionpci_unmap_iospace
Info:../drivers/pci/pci.c:4097Scanning doc for functionpcibios_setup
Info:../drivers/pci/pci.c:4109Scanning doc for functionpcibios_set_master
Info:../drivers/pci/pci.c:4136Scanning doc for functionpci_set_master
Info:../drivers/pci/pci.c:4150Scanning doc for functionpci_clear_master
Info:../drivers/pci/pci.c:4160Scanning doc for functionpci_set_cacheline_size
Info:../drivers/pci/pci.c:4198Scanning doc for functionpci_set_mwi
Info:../drivers/pci/pci.c:4229Scanning doc for functionpci_try_set_mwi
Info:../drivers/pci/pci.c:4248Scanning doc for functionpci_clear_mwi
Info:../drivers/pci/pci.c:4268Scanning doc for functionpci_disable_parity
Info:../drivers/pci/pci.c:4285Scanning doc for functionpci_intx
Info:../drivers/pci/pci.c:4310Scanning doc for functionpci_wait_for_pending_transaction
Info:../drivers/pci/pci.c:4326Scanning doc for functionpcie_flr
Info:../drivers/pci/pci.c:4366Scanning doc for functionpcie_reset_flr
Info:../drivers/pci/pci.c:4443Scanning doc for functionpci_pm_reset
Info:../drivers/pci/pci.c:4497Scanning doc for functionpcie_wait_for_link_status
Info:../drivers/pci/pci.c:4527Scanning doc for functionpcie_retrain_link
Info:../drivers/pci/pci.c:4592Scanning doc for functionpcie_wait_for_link_delay
Info:../drivers/pci/pci.c:4642Scanning doc for functionpcie_wait_for_link
Info:../drivers/pci/pci.c:4679Scanning doc for functionpci_bridge_wait_for_secondary_bus
Info:../drivers/pci/pci.c:4818Scanning doc for functionpci_bridge_secondary_bus_reset
Info:../drivers/pci/pci.c:5077Scanning doc for function__pci_reset_function_locked
Info:../drivers/pci/pci.c:5135Scanning doc for functionpci_init_reset_methods
Info:../drivers/pci/pci.c:5167Scanning doc for functionpci_reset_function
Info:../drivers/pci/pci.c:5214Scanning doc for functionpci_reset_function_locked
Info:../drivers/pci/pci.c:5252Scanning doc for functionpci_try_reset_functionQuoted 8 lines
Of course, I can remove
KBUILD_VERBOSEfrom my environment, I'm not entirely sure when or why I added it.Would think it would make sense to update the
kdoc_files.pyscript to check and interpret the string value the same way the perl script used to? It seems reasonable to me that users might set "V=0" thinking that it disables the verbosity. Other verbosity checks are based on the string containing a 1,
Quoted 4 lines
kernel-doc has a set of "-W" flags to control its verbosity. Direct support for
KBUILD_VERBOSEwas added there just to make it bug-compatible with kernel-doc.pl when building viaMakefile.
Right.
Quoted 3 lines
Yet, as using it via "make htmldocs" don't use "-W", IMO it makes sense to ensure that "-Wall" is enabled if V=1.
We enable -Wall if KBUILD_EXTRA_WARN contains a 2:
ifeq ($(KBUILD_EXTMOD),)
ifneq ($(KBUILD_EXTRA_WARN),)
cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none
$(KDOCFLAGS) \
$(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
$<endif
endif
If KBUILD_EXTRA_WARN has 2 we do -Wall, and if its any non-zero value we enable checkdoc. KBUILD_VERBOSE is handled internally to the script so not part of the Make invocation.
So V=0 only manifests if KBUILD_EXTRA_WARN is set.
We set KBUILD_EXTRA_WARN in top level:
ifeq ("$(origin W)", "command line")
KBUILD_EXTRA_WARN := $(W)
endif
export KBUILD_EXTRA_WARN
Quoted 6 lines
Quoted 1 line
(some even use 2 for even more printing).
Documentation had support for V=2, but this was dropped on this commit:
c0d3b83100c8 ("kbuild: do not print extra logs for V=2")
Looks like there's some stale leftover bits then:
#
# If KBUILD_VERBOSE contains 1, the whole command is echoed. # If KBUILD_VERBOSE contains 2, the reason for rebuilding is printed. #
# To put more focus on warnings, be less verbose as default # Use 'make V=1' to see the full commands
I don't have strong opinions either way.
Quoted 5 lines
Quoted 2 lines
I'm not entirely sure what the best implementation for python is to avoid this misinterpretation, so I haven't drafted a proper patch yet.
Perhaps something like the patch below (untested).
The patch seems reasonable, though I don't know about the enabling other errors, as those are controlled by W=2 right now. I don't personally have objections to enabling them with V as well, but others might?
Thanks,
Jake
Quoted 181 lines · On Wed, 25 Mar 2026 13:42:44 -0700 Jacob Keller <[email protected]>…
Quoted 50 lines · Mauro Carvalho Chehab
Quoted 40 lines · On Tue, 24 Mar 2026 13:37:39 -0700 Jacob Keller <[email protected]>…
Hi,
I recently saw some strange behavior with the Python kernel-doc. I was seeing the verbose info lines from the kernel-doc script, i.e.:
Quoted 19 lines
Info: ice_ptp_hw.c:5377 Scanning doc for function
ice_cgu_get_pin_freq_supp
Info: ice_ptp_hw.c:5406 Scanning doc for functionice_cgu_get_pin_name
Info: ice_ptp_hw.c:5441 Scanning doc for functionice_cgu_state_to_name
Info: ice_ptp_hw.c:5463 Scanning doc for functionice_get_dpll_ref_sw_status
Info: ice_ptp_hw.c:5505 Scanning doc for functionice_set_dpll_ref_sw_status
Info: ice_ptp_hw.c:5544 Scanning doc for functionice_get_cgu_state
Info: ice_ptp_hw.c:5612 Scanning doc for functionice_get_cgu_rclk_pin_info
Info: ice_ptp_hw.c:5671 Scanning doc for functionice_cgu_get_output_pin_state_caps
Info: ice_ptp_hw.c:5733 Scanning doc for functionice_ptp_lock
Info: ice_ptp_hw.c:5770 Scanning doc for functionice_ptp_unlock
Info: ice_ptp_hw.c:5782 Scanning doc for functionice_ptp_init_hw
Info: ice_ptp_hw.c:5811 Scanning doc for functionice_ptp_write_port_cmd
Info: ice_ptp_hw.c:5834 Scanning doc for functionice_ptp_one_port_cmd
Info: ice_ptp_hw.c:5866 Scanning doc for functionice_ptp_port_cmd
Info: ice_ptp_hw.c:5901 Scanning doc for functionice_ptp_tmr_cmd
Info: ice_ptp_hw.c:5934 Scanning doc for functionice_ptp_init_time
Info: ice_ptp_hw.c:5986 Scanning doc for functionice_ptp_write_incval
Info: ice_ptp_hw.c:6035 Scanning doc for functionice_ptp_write_incval_locked
Info: ice_ptp_hw.c:6056 Scanning doc for functionice_ptp_adj_clockQuoted 8 lines
Info: ice_ptp_hw.c:6107 Scanning doc for function
ice_read_phy_tstamp
Info: ice_ptp_hw.c:6134 Scanning doc for functionice_clear_phy_tstamp
Info: ice_ptp_hw.c:6164 Scanning doc for functionice_ptp_reset_ts_memory
Info: ice_ptp_hw.c:6183 Scanning doc for functionice_ptp_init_phc
Info: ice_ptp_hw.c:6215 Scanning doc for functionice_get_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6247 Scanning doc for functionice_check_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6273 Scanning doc for functionice_ptp_config_sfd
Info: ice_ptp_hw.c:6293 Scanning doc for functionrefsync_pin_id_validI didn't understand why I was seeing this as it should only be happening if running kernel-doc in verbose mode. Then I discovered I had set KBUILD_VERBOSE=0 in my environment.
The python kernel-doc implementation reads this in the
__init__forKernelFiles()on line 165:Quoted 6 lines
Quoted 2 lines
if not verbose:
verbose =bool(os.environ.get("KBUILD_VERBOSE", 0))After some debugging, I realized this reads
KBUILD_VERBOSEas a string, then converts it to a boolean using python's standard rules, so "0" becomes true, which enables the verbose output.Quoted 7 lines
Looking at
tools/docs/sphinx-build-wrapper, it implements verbosity by doing:verbose = bool(os.environ.get("KBUILD_VERBOSE", "") != "")which will also have the same problem as the one you detected.
Yep.
Quoted 11 lines
Perhaps the right fix would be to first convert to int then to bool on both places, in a way that "" will also be handled properly. Perhaps with:
try:
verbose =bool(int(os.environ.get("KBUILD_VERBOSE", 0)))
except ValueError:
# Handles an eventual case where verbosity is not a number # like KBUILD_VERBOSE=""
verbose = FalseQuoted 1 line
Quoted 1 line
This is in contrast to the (now removed) kernel-doc.pl script which
Quoted 9 lines
Quoted 6 lines
checked the value for a 1:
Quoted 1 line
if (
defined($ENV{'KBUILD_VERBOSE'})&& $ENV{'KBUILD_VERBOSE'} =~ '1')The same behavior happens if you assign V=0 on the command line or to any other non-empty string, since when V is set on the command line it sets
KBUILD_VERBOSE.That's funny... we did test make V=0 htmldocs / make V=1 htmldocs
Strange. The
Makefiledoes this:ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE= $(V)
endifI can see KBUILD_VERBOSE=0 from the top level
Makefile, but you're right it doesn't seem to trigger the environment variable..Quoted 3 lines
It sounds that the problem is only if you explicitly set it without relying on gnu make.
Adding some warn prints I do see the
Makefilesets KBUILD_VERBOSE=0 when you do V=0.. and it has an export clause forKBUILD_VERBOSEOh, it might be your particular build doesn't have W=1 so checkdoc isn't being defined and thus kernel-doc isn't running?
If I do "make W=1 V=0" I do actually see these lines:
Quoted 50 lines
Info:
../drivers/pci/pci.c:3646Scanning doc for functionpci_acs_init
Info:../drivers/pci/pci.c:3663Scanning doc for functionpci_enable_atomic_ops_to_root
Info:../drivers/pci/pci.c:3746Scanning doc for functionpci_release_region
Info:../drivers/pci/pci.c:3772Scanning doc for function__pci_request_region
Info:../drivers/pci/pci.c:3820Scanning doc for functionpci_request_region
Info:../drivers/pci/pci.c:3841Scanning doc for functionpci_release_selected_regions
Info:../drivers/pci/pci.c:3879Scanning doc for functionpci_request_selected_regions
Info:../drivers/pci/pci.c:3894Scanning doc for functionpci_request_selected_regions_exclusive
Info:../drivers/pci/pci.c:3910Scanning doc for functionpci_release_regions
Info:../drivers/pci/pci.c:3925Scanning doc for functionpci_request_regions
Info:../drivers/pci/pci.c:3944Scanning doc for functionpci_request_regions_exclusive
Info:../drivers/pci/pci.c:4026Scanning doc for functionpci_remap_iospace
Info:../drivers/pci/pci.c:4062Scanning doc for functionpci_unmap_iospace
Info:../drivers/pci/pci.c:4097Scanning doc for functionpcibios_setup
Info:../drivers/pci/pci.c:4109Scanning doc for functionpcibios_set_master
Info:../drivers/pci/pci.c:4136Scanning doc for functionpci_set_master
Info:../drivers/pci/pci.c:4150Scanning doc for functionpci_clear_master
Info:../drivers/pci/pci.c:4160Scanning doc for functionpci_set_cacheline_size
Info:../drivers/pci/pci.c:4198Scanning doc for functionpci_set_mwi
Info:../drivers/pci/pci.c:4229Scanning doc for functionpci_try_set_mwi
Info:../drivers/pci/pci.c:4248Scanning doc for functionpci_clear_mwi
Info:../drivers/pci/pci.c:4268Scanning doc for functionpci_disable_parity
Info:../drivers/pci/pci.c:4285Scanning doc for functionpci_intx
Info:../drivers/pci/pci.c:4310Scanning doc for functionpci_wait_for_pending_transaction
Info:../drivers/pci/pci.c:4326Scanning doc for functionpcie_flr
Info:../drivers/pci/pci.c:4366Scanning doc for functionpcie_reset_flr
Info:../drivers/pci/pci.c:4443Scanning doc for functionpci_pm_reset
Info:../drivers/pci/pci.c:4497Scanning doc for functionpcie_wait_for_link_status
Info:../drivers/pci/pci.c:4527Scanning doc for functionpcie_retrain_link
Info:../drivers/pci/pci.c:4592Scanning doc for functionpcie_wait_for_link_delay
Info:../drivers/pci/pci.c:4642Scanning doc for functionpcie_wait_for_link
Info:../drivers/pci/pci.c:4679Scanning doc for functionpci_bridge_wait_for_secondary_bus
Info:../drivers/pci/pci.c:4818Scanning doc for functionpci_bridge_secondary_bus_reset
Info:../drivers/pci/pci.c:5077Scanning doc for function__pci_reset_function_locked
Info:../drivers/pci/pci.c:5135Scanning doc for functionpci_init_reset_methods
Info:../drivers/pci/pci.c:5167Scanning doc for functionpci_reset_function
Info:../drivers/pci/pci.c:5214Scanning doc for functionpci_reset_function_locked
Info:../drivers/pci/pci.c:5252Scanning doc for functionpci_try_reset_functionQuoted 8 lines
Of course, I can remove
KBUILD_VERBOSEfrom my environment, I'm not entirely sure when or why I added it.Would think it would make sense to update the
kdoc_files.pyscript to check and interpret the string value the same way the perl script used to? It seems reasonable to me that users might set "V=0" thinking that it disables the verbosity. Other verbosity checks are based on the string containing a 1,Quoted 4 lines
kernel-doc has a set of "-W" flags to control its verbosity. Direct support for
KBUILD_VERBOSEwas added there just to make it bug-compatible with kernel-doc.pl when building viaMakefile.Right.
Quoted 3 lines
Yet, as using it via "make htmldocs" don't use "-W", IMO it makes sense to ensure that "-Wall" is enabled if V=1.
We enable -Wall if
KBUILD_EXTRA_WARNcontains a 2:ifeq ($(KBUILD_EXTMOD),)
ifneq ($(KBUILD_EXTRA_WARN),)
cmd_checkdoc= PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none$(KDOCFLAGS) \ $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \ $<endif
endifIf
KBUILD_EXTRA_WARNhas 2 we do -Wall, and if its any non-zero value we enable checkdoc.KBUILD_VERBOSEis handled internally to the script so not part of the Make invocation.So V=0 only manifests if
KBUILD_EXTRA_WARNis set.
Quoted 7 lines
We set
KBUILD_EXTRA_WARNin top level:ifeq ("$(origin W)", "command line")
KBUILD_EXTRA_WARN:= $(W)
endifexport
KBUILD_EXTRA_WARN
Good point.
Quoted 22 lines
Quoted 7 lines
Quoted 2 lines
(some even use 2 for even more printing).
Documentation had support for V=2, but this was dropped on this commit:
c0d3b83100c8 ("kbuild: do not print extra logs for V=2")Looks like there's some stale leftover bits then:
#
# IfKBUILD_VERBOSEcontains 1, the whole command is echoed. # IfKBUILD_VERBOSEcontains 2, the reason for rebuilding is printed. #
# To put more focus on warnings, be less verbose as default # Use 'make V=1' to see the full commands
I don't have strong opinions either way.Quoted 3 lines
Quoted 2 lines
I'm not entirely sure what the best implementation for python is to avoid this misinterpretation, so I haven't drafted a proper patch yet.
Quoted 6 lines
Quoted 2 lines
Perhaps something like the patch below (untested).
The patch seems reasonable, though I don't know about the enabling other errors, as those are controlled by W=2 right now. I don't personally have objections to enabling them with V as well, but others might?
As W=2 already turns those, I opted to just apply the fix for KBUILD_VERBOSE without touching -W macros:
On a very quick test with:
$ make W=2 V=0 drivers/pci/
and with:
$ KBUILD_VERBOSE="asdf" ./scripts/kernel-doc drivers/pci/ -none $ KBUILD_VERBOSE="" ./scripts/kernel-doc drivers/pci/ -none $ KBUILD_VERBOSE="0" ./scripts/kernel-doc drivers/pci/ -none $ KBUILD_VERBOSE=0 ./scripts/kernel-doc drivers/pci/ -none
None of the above enabled verbosity.
Using either one of the above:
$ KBUILD_VERBOSE=1 ./scripts/kernel-doc drivers/pci/ -none $ KBUILD_VERBOSE="1" ./scripts/kernel-doc drivers/pci/ -none
made it verbose.
So, I guess this should be enough to fix the issue. Please test and reply to the patch if it works or not for you.
Thanks,
Mauro
Quoted 247 lines · Mauro Carvalho Chehab
Quoted 181 lines · On Wed, 25 Mar 2026 13:42:44 -0700 Jacob Keller <[email protected]>…
Quoted 50 lines · Mauro Carvalho Chehab
Quoted 40 lines · On Tue, 24 Mar 2026 13:37:39 -0700 Jacob Keller <[email protected]>…
Hi,
I recently saw some strange behavior with the Python kernel-doc. I was seeing the verbose info lines from the kernel-doc script, i.e.:
Quoted 19 lines
Info: ice_ptp_hw.c:5377 Scanning doc for function
ice_cgu_get_pin_freq_supp
Info: ice_ptp_hw.c:5406 Scanning doc for functionice_cgu_get_pin_name
Info: ice_ptp_hw.c:5441 Scanning doc for functionice_cgu_state_to_name
Info: ice_ptp_hw.c:5463 Scanning doc for functionice_get_dpll_ref_sw_status
Info: ice_ptp_hw.c:5505 Scanning doc for functionice_set_dpll_ref_sw_status
Info: ice_ptp_hw.c:5544 Scanning doc for functionice_get_cgu_state
Info: ice_ptp_hw.c:5612 Scanning doc for functionice_get_cgu_rclk_pin_info
Info: ice_ptp_hw.c:5671 Scanning doc for functionice_cgu_get_output_pin_state_caps
Info: ice_ptp_hw.c:5733 Scanning doc for functionice_ptp_lock
Info: ice_ptp_hw.c:5770 Scanning doc for functionice_ptp_unlock
Info: ice_ptp_hw.c:5782 Scanning doc for functionice_ptp_init_hw
Info: ice_ptp_hw.c:5811 Scanning doc for functionice_ptp_write_port_cmd
Info: ice_ptp_hw.c:5834 Scanning doc for functionice_ptp_one_port_cmd
Info: ice_ptp_hw.c:5866 Scanning doc for functionice_ptp_port_cmd
Info: ice_ptp_hw.c:5901 Scanning doc for functionice_ptp_tmr_cmd
Info: ice_ptp_hw.c:5934 Scanning doc for functionice_ptp_init_time
Info: ice_ptp_hw.c:5986 Scanning doc for functionice_ptp_write_incval
Info: ice_ptp_hw.c:6035 Scanning doc for functionice_ptp_write_incval_locked
Info: ice_ptp_hw.c:6056 Scanning doc for functionice_ptp_adj_clockQuoted 8 lines
Info: ice_ptp_hw.c:6107 Scanning doc for function
ice_read_phy_tstamp
Info: ice_ptp_hw.c:6134 Scanning doc for functionice_clear_phy_tstamp
Info: ice_ptp_hw.c:6164 Scanning doc for functionice_ptp_reset_ts_memory
Info: ice_ptp_hw.c:6183 Scanning doc for functionice_ptp_init_phc
Info: ice_ptp_hw.c:6215 Scanning doc for functionice_get_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6247 Scanning doc for functionice_check_phy_tx_tstamp_ready
Info: ice_ptp_hw.c:6273 Scanning doc for functionice_ptp_config_sfd
Info: ice_ptp_hw.c:6293 Scanning doc for functionrefsync_pin_id_validI didn't understand why I was seeing this as it should only be happening if running kernel-doc in verbose mode. Then I discovered I had set KBUILD_VERBOSE=0 in my environment.
The python kernel-doc implementation reads this in the
__init__forKernelFiles()on line 165:Quoted 6 lines
Quoted 2 lines
if not verbose:
verbose =bool(os.environ.get("KBUILD_VERBOSE", 0))After some debugging, I realized this reads
KBUILD_VERBOSEas a string, then converts it to a boolean using python's standard rules, so "0" becomes true, which enables the verbose output.Quoted 7 lines
Looking at
tools/docs/sphinx-build-wrapper, it implements verbosity by doing:verbose = bool(os.environ.get("KBUILD_VERBOSE", "") != "")which will also have the same problem as the one you detected.
Yep.
Quoted 11 lines
Perhaps the right fix would be to first convert to int then to bool on both places, in a way that "" will also be handled properly. Perhaps with:
try:
verbose =bool(int(os.environ.get("KBUILD_VERBOSE", 0)))
except ValueError:
# Handles an eventual case where verbosity is not a number # like KBUILD_VERBOSE=""
verbose = FalseQuoted 1 line
Quoted 1 line
This is in contrast to the (now removed) kernel-doc.pl script which
Quoted 9 lines
Quoted 6 lines
checked the value for a 1:
Quoted 1 line
if (
defined($ENV{'KBUILD_VERBOSE'})&& $ENV{'KBUILD_VERBOSE'} =~ '1')The same behavior happens if you assign V=0 on the command line or to any other non-empty string, since when V is set on the command line it sets
KBUILD_VERBOSE.That's funny... we did test make V=0 htmldocs / make V=1 htmldocs
Strange. The
Makefiledoes this:ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE= $(V)
endifI can see KBUILD_VERBOSE=0 from the top level
Makefile, but you're right it doesn't seem to trigger the environment variable..Quoted 3 lines
It sounds that the problem is only if you explicitly set it without relying on gnu make.
Adding some warn prints I do see the
Makefilesets KBUILD_VERBOSE=0 when you do V=0.. and it has an export clause forKBUILD_VERBOSEOh, it might be your particular build doesn't have W=1 so checkdoc isn't being defined and thus kernel-doc isn't running?
If I do "make W=1 V=0" I do actually see these lines:
Quoted 50 lines
Info:
../drivers/pci/pci.c:3646Scanning doc for functionpci_acs_init
Info:../drivers/pci/pci.c:3663Scanning doc for functionpci_enable_atomic_ops_to_root
Info:../drivers/pci/pci.c:3746Scanning doc for functionpci_release_region
Info:../drivers/pci/pci.c:3772Scanning doc for function__pci_request_region
Info:../drivers/pci/pci.c:3820Scanning doc for functionpci_request_region
Info:../drivers/pci/pci.c:3841Scanning doc for functionpci_release_selected_regions
Info:../drivers/pci/pci.c:3879Scanning doc for functionpci_request_selected_regions
Info:../drivers/pci/pci.c:3894Scanning doc for functionpci_request_selected_regions_exclusive
Info:../drivers/pci/pci.c:3910Scanning doc for functionpci_release_regions
Info:../drivers/pci/pci.c:3925Scanning doc for functionpci_request_regions
Info:../drivers/pci/pci.c:3944Scanning doc for functionpci_request_regions_exclusive
Info:../drivers/pci/pci.c:4026Scanning doc for functionpci_remap_iospace
Info:../drivers/pci/pci.c:4062Scanning doc for functionpci_unmap_iospace
Info:../drivers/pci/pci.c:4097Scanning doc for functionpcibios_setup
Info:../drivers/pci/pci.c:4109Scanning doc for functionpcibios_set_master
Info:../drivers/pci/pci.c:4136Scanning doc for functionpci_set_master
Info:../drivers/pci/pci.c:4150Scanning doc for functionpci_clear_master
Info:../drivers/pci/pci.c:4160Scanning doc for functionpci_set_cacheline_size
Info:../drivers/pci/pci.c:4198Scanning doc for functionpci_set_mwi
Info:../drivers/pci/pci.c:4229Scanning doc for functionpci_try_set_mwi
Info:../drivers/pci/pci.c:4248Scanning doc for functionpci_clear_mwi
Info:../drivers/pci/pci.c:4268Scanning doc for functionpci_disable_parity
Info:../drivers/pci/pci.c:4285Scanning doc for functionpci_intx
Info:../drivers/pci/pci.c:4310Scanning doc for functionpci_wait_for_pending_transaction
Info:../drivers/pci/pci.c:4326Scanning doc for functionpcie_flr
Info:../drivers/pci/pci.c:4366Scanning doc for functionpcie_reset_flr
Info:../drivers/pci/pci.c:4443Scanning doc for functionpci_pm_reset
Info:../drivers/pci/pci.c:4497Scanning doc for functionpcie_wait_for_link_status
Info:../drivers/pci/pci.c:4527Scanning doc for functionpcie_retrain_link
Info:../drivers/pci/pci.c:4592Scanning doc for functionpcie_wait_for_link_delay
Info:../drivers/pci/pci.c:4642Scanning doc for functionpcie_wait_for_link
Info:../drivers/pci/pci.c:4679Scanning doc for functionpci_bridge_wait_for_secondary_bus
Info:../drivers/pci/pci.c:4818Scanning doc for functionpci_bridge_secondary_bus_reset
Info:../drivers/pci/pci.c:5077Scanning doc for function__pci_reset_function_locked
Info:../drivers/pci/pci.c:5135Scanning doc for functionpci_init_reset_methods
Info:../drivers/pci/pci.c:5167Scanning doc for functionpci_reset_function
Info:../drivers/pci/pci.c:5214Scanning doc for functionpci_reset_function_locked
Info:../drivers/pci/pci.c:5252Scanning doc for functionpci_try_reset_functionQuoted 8 lines
Of course, I can remove
KBUILD_VERBOSEfrom my environment, I'm not entirely sure when or why I added it.Would think it would make sense to update the
kdoc_files.pyscript to check and interpret the string value the same way the perl script used to? It seems reasonable to me that users might set "V=0" thinking that it disables the verbosity. Other verbosity checks are based on the string containing a 1,Quoted 4 lines
kernel-doc has a set of "-W" flags to control its verbosity. Direct support for
KBUILD_VERBOSEwas added there just to make it bug-compatible with kernel-doc.pl when building viaMakefile.Right.
Quoted 3 lines
Yet, as using it via "make htmldocs" don't use "-W", IMO it makes sense to ensure that "-Wall" is enabled if V=1.
We enable -Wall if
KBUILD_EXTRA_WARNcontains a 2:ifeq ($(KBUILD_EXTMOD),)
ifneq ($(KBUILD_EXTRA_WARN),)
cmd_checkdoc= PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none$(KDOCFLAGS) \ $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \ $<endif
endifIf
KBUILD_EXTRA_WARNhas 2 we do -Wall, and if its any non-zero value we enable checkdoc.KBUILD_VERBOSEis handled internally to the script so not part of the Make invocation.So V=0 only manifests if
KBUILD_EXTRA_WARNis set.Quoted 7 lines
We set
KBUILD_EXTRA_WARNin top level:ifeq ("$(origin W)", "command line")
KBUILD_EXTRA_WARN:= $(W)
endifexport
KBUILD_EXTRA_WARNGood point.
Quoted 22 lines
Quoted 7 lines
Quoted 2 lines
(some even use 2 for even more printing).
Documentation had support for V=2, but this was dropped on this commit:
c0d3b83100c8 ("kbuild: do not print extra logs for V=2")Looks like there's some stale leftover bits then:
#
# IfKBUILD_VERBOSEcontains 1, the whole command is echoed. # IfKBUILD_VERBOSEcontains 2, the reason for rebuilding is printed. #
# To put more focus on warnings, be less verbose as default # Use 'make V=1' to see the full commands
I don't have strong opinions either way.Quoted 3 lines
Quoted 2 lines
I'm not entirely sure what the best implementation for python is to avoid this misinterpretation, so I haven't drafted a proper patch yet.
Quoted 6 lines
Quoted 2 lines
Perhaps something like the patch below (untested).
The patch seems reasonable, though I don't know about the enabling other errors, as those are controlled by W=2 right now. I don't personally have objections to enabling them with V as well, but others might?
As W=2 already turns those, I opted to just apply the fix for
KBUILD_VERBOSEwithout touching -W macros:On a very quick test with:
$ make W=2 V=0 drivers/pci/and with:
$ KBUILD_VERBOSE="asdf" ./scripts/kernel-doc drivers/pci/ -none $ KBUILD_VERBOSE="" ./scripts/kernel-doc drivers/pci/ -none $ KBUILD_VERBOSE="0" ./scripts/kernel-doc drivers/pci/ -none $ KBUILD_VERBOSE=0 ./scripts/kernel-doc drivers/pci/ -noneNone of the above enabled verbosity.
Using either one of the above:
$ KBUILD_VERBOSE=1 ./scripts/kernel-doc drivers/pci/ -none $ KBUILD_VERBOSE="1" ./scripts/kernel-doc drivers/pci/ -none
Quoted 7 lines
made it verbose.
So, I guess this should be enough to fix the issue. Please test and reply to the patch if it works or not for you.
Thanks,
Mauro
It looks good to me. I'll reply with a tested-by on the patch.
Thanks,
Jake