Skip to content

Commit

Permalink
Use \kconfig and \kconfigval Elixir macros
Browse files Browse the repository at this point in the history
- Allows to provide links to the definition of kernel parameters

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
  • Loading branch information
Michael Opdenacker committed May 27, 2020
1 parent 3113f5f commit 099b910
Show file tree
Hide file tree
Showing 29 changed files with 109 additions and 108 deletions.
1 change: 1 addition & 0 deletions common/common.sty
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
\newcommand\kreldir[2]{\href{https://elixir.bootlin.com/linux/latest/source/#1/#2}{\code{#2/}}} % For relative directory paths
\newcommand\ksubarch[1]{\href{https://elixir.bootlin.com/linux/latest/source/arch/#1/}{\code{#1}}}
\newcommand\kconfig[1]{\href{https://elixir.bootlin.com/linux/latest/K/ident/#1}{\code{#1}}}
\newcommand\kconfigval[2]{\href{https://elixir.bootlin.com/linux/latest/K/ident/#1}{\code{#1=#2}}}
\newcommand\kerneldoctext[1]{\href{https://kernel.org/doc/Documentation/#1}{\code{Documentation/#1}}}
\newcommand\kerneldochtml[1]{\href{https://www.kernel.org/doc/html/latest/#1.html}{\code{#1}}}
\newcommand\kerneldochtmlsection[3]{\href{https://www.kernel.org/doc/html/latest/#1/index.html\##2}{\code{#1} (section {\em #3})}}
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,33 @@ \section{Configuring the Linux kernel}

To enable support for the framebuffer and the PWM backlight:
\begin{itemize}
\item \code{CONFIG_PWM_TIEHRPWM=y}
\item \code{CONFIG_FB_SIMPLE=y}
\item \code{CONFIG_BACKLIGHT_PWM=y}
\item \code{CONFIG_DRM=y}
\item \code{CONFIG_DRM_TILCDC=y}
\item \code{CONFIG_DRM_TI_TFP410=y}
\item \kconfigval{CONFIG_PWM_TIEHRPWM}{y}
\item \kconfigval{CONFIG_FB_SIMPLE}{y}
\item \kconfigval{CONFIG_BACKLIGHT_PWM}{y}
\item \kconfigval{CONFIG_DRM}{y}
\item \kconfigval{CONFIG_DRM_TILCDC}{y}
\item \kconfigval{CONFIG_DRM_TI_TFP410}{y}
\end{itemize}

For USB support:
\begin{itemize}
\item \code{CONFIG_USB=y}
\item \code{CONFIG_USB_MUSB_HDRC=y}
\item \code{CONFIG_USB_MUSB_DSPS=y}
\item \code{CONFIG_MUSB_PIO_ONLY=y}
\item \code{CONFIG_USB_GADGET=y}
\item \code{CONFIG_NOP_USB_XCEIV=y}
\item \code{CONFIG_AM335X_PHY_USB=y}
\item \code{CONFIG_USB_GPIO_VBUS=y}
\item \code{CONFIG_USB_GADGET_VBUS_DRAW=500}
\item \code{CONFIG_USB_CONFIGFS_F_UVC=y}
\item \kconfigval{CONFIG_USB}{y}
\item \kconfigval{CONFIG_USB_MUSB_HDRC}{y}
\item \kconfigval{CONFIG_USB_MUSB_DSPS}{y}
\item \kconfigval{CONFIG_MUSB_PIO_ONLY}{y}
\item \kconfigval{CONFIG_USB_GADGET}{y}
\item \kconfigval{CONFIG_NOP_USB_XCEIV}{y}
\item \kconfigval{CONFIG_AM335X_PHY_USB}{y}
\item \kconfigval{CONFIG_USB_GPIO_VBUS}{y}
\item \kconfigval{CONFIG_USB_GADGET_VBUS_DRAW}{500}
\item \kconfigval{CONFIG_USB_CONFIGFS_F_UVC}{y}
\end{itemize}

For the webcam
\begin{itemize}
\item \code{CONFIG_MEDIA_SUPPORT=y}
\item \code{CONFIG_MEDIA_USB_SUPPORT=y}
\item \code{CONFIG_USB_VIDEO_CLASS=y}
\item \kconfigval{CONFIG_MEDIA_SUPPORT}{y}
\item \kconfigval{CONFIG_MEDIA_USB_SUPPORT}{y}
\item \kconfigval{CONFIG_USB_VIDEO_CLASS}{y}
\end{itemize}

For your convenience, of if you screw up your settings in a later lab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ \section{Initramfs tests}
\item Fill \code{Initramfs source file(s)} with
\code{../../rootfs/rootfs} (or the correct path to the directory
containing your root filesystem)
\item Make sure you set \code{CONFIG_INITRAMFS_COMPRESSION_NONE=y}
\item Make sure you set \kconfigval{CONFIG_INITRAMFS_COMPRESSION_NONE}{y}
to avoid wasting space compressing the initramfs twice.
\end{itemize}
\item Disable \code{Enable the block layer}
Expand Down
12 changes: 6 additions & 6 deletions labs/boot-time-kernel/boot-time-kernel.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ \section{Measuring}

Our default kernel already has the configuration settings that we need:
\begin{itemize}
\item \code{CONFIG_PRINTK_TIME=y}, to add a timestamp to each kernel
\item \kconfigval{CONFIG_PRINTK_TIME}{y}, to add a timestamp to each kernel
message.
\item \code{CONFIG_LOG_BUF_SHIFT=16}, to have a big enough kernel ring buffer.
\item \kconfigval{CONFIG_LOG_BUF_SHIFT}{16}, to have a big enough kernel ring buffer.
\end{itemize}

That's not sufficient. We also need the output of the \code{dmesg}
Expand Down Expand Up @@ -108,21 +108,21 @@ \section{Removing unnecessary functionality}
kernel that doesn't boot any more, but you won't be able to tell which
parameter should have been kept.

Also, don't disable \code{CONFIG_PRINTK} too early
Also, don't disable \kconfig{CONFIG_PRINTK} too early
as you would lose all the kernel messages in the console.

Also, for the moment, don't touch the options related to size and
compression, including compiling the kernel with {\em Thumb2}, as the
impact of each option could depend on the size of the kernel.

Make sure you go through all the possibilities covered in the slides, in
particular to enable \code{CONFIG_EMBEDDED} to allow to unselect further
particular to enable \kconfig{CONFIG_EMBEDDED} to allow to unselect further
features that should be present on a general purpose
system\footnote{Here we have a very specific system and we don't have
to support programs that could be added in the future and could need
more kernel features}.

At the end, you can disable \code{CONFIG_PRINTK}, and observe your
At the end, you can disable \kconfig{CONFIG_PRINTK}, and observe your
total savings in terms of kernel size and boot time.

Last but not least, try to find other ways of reducing the kernel size.
Expand All @@ -147,7 +147,7 @@ \section{Optimizing required functionality}
\hline
\end{tabular}

Now, compile your kernel with \code{CONFIG_ARM_THUMB}. Before you do
Now, compile your kernel with \kconfig{CONFIG_ARM_THUMB}. Before you do
this, you could make a backup copy of your kernel source directory with
\code{cp -al}, as a full rebuild of the kernel will be needed, and we
may want to roll back later. Fortunately, thanks to our feature
Expand Down
2 changes: 1 addition & 1 deletion labs/buildroot-basic/buildroot-basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ \section{Configuring Buildroot}
OMAP2, OMAP3, OMAP4, etc. So the appropriate {\em defconfig} is
named \code{omap2plus_defconfig}. You can open up this file in the
Linux kernel Git repository viewer, and see it contains the line
\code{CONFIG_SOC_AM33XX=y}, which is a good indication that it has
\kconfigval{CONFIG_SOC_AM33XX}{y}, which is a good indication that it has
the support for the processor used in the BeagleBone Black. Now
that we have identified the {\em defconfig} name, enter
\code{omap2plus} in the \code{Defconfig name} option.
Expand Down
2 changes: 1 addition & 1 deletion labs/buildroot-new-packages/buildroot-new-packages.tex
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ \section{Support the Nunchuk}
However, this patch relies on the Linux kernel {\em joystick
interface}, that we need to enable. Go to the Linux kernel
configuration using \code{make linux-menuconfig}, and enable
\code{CONFIG_INPUT_JOYDEV}. Exit, and make sure to save your kernel
\kconfig{CONFIG_INPUT_JOYDEV}. Exit, and make sure to save your kernel
configuration safely using \code{make linux-update-defconfig}. Restart
the overall build by running \code{make}.
Expand Down
6 changes: 3 additions & 3 deletions labs/buildroot-rootfs/buildroot-rootfs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ \section{Linux kernel customization}
\end{itemize}
Once in the kernel \code{menuconfig}, search for the option
\code{CONFIG_JOYSTICK_WIICHUCK} by using the search engine tool
\kconfig{CONFIG_JOYSTICK_WIICHUCK} by using the search engine tool
accessible by typing \code{/}. Make sure to enable the {\em Nintendo
Wiimote Extension connector on i2c bus} option using a \code{*} so
that the driver is part of the kernel image itself (enabling with
\code{M} would lead the driver to be compiled as a module). Also, make
sure the \code{CONFIG_INPUT_EVDEV} option is enabled with \code{*} (by
sure the \kconfig{CONFIG_INPUT_EVDEV} option is enabled with \code{*} (by
default it is enabled as a module).
You can now exit the kernel \code{menuconfig}, and restart the build
Expand Down Expand Up @@ -294,7 +294,7 @@ \section{Linux kernel customization}
configuration file in
\code{board/felabs/beagleboneblack/linux.config}. It will be a {\em
minimal} configuration file (i.e a {\em defconfig}). In this file,
verify that the option \code{CONFIG_JOYSTICK_WIICHUCK} is properly
verify that the option \kconfig{CONFIG_JOYSTICK_WIICHUCK} is properly
set to \code{y}.
\end{enumerate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ \section{Kernel configuration}
Add the below options to support networking over USB device:
\begin{itemize}
\item \code{CONFIG_USB_GADGET=y}
\item \code{CONFIG_USB_MUSB_HDRC=y} {\em Driver for the USB OTG
\item \kconfigval{CONFIG_USB_GADGET}{y}
\item \kconfigval{CONFIG_USB_MUSB_HDRC}{y} {\em Driver for the USB OTG
controller}
\item \code{CONFIG_USB_MUSB_GADGET=y} {\em Use the USB OTG controller
\item \kconfigval{CONFIG_USB_MUSB_GADGET}{y} {\em Use the USB OTG controller
in device (gadget) mode}
\item \code{CONFIG_USB_MUSB_DSPS}=y
\item Check the dependencies of \code{CONFIG_AM335X_PHY_USB}
and find the way to set \code{CONFIG_AM335X_PHY_USB=y}
\item \kconfigval{CONFIG_USB_MUSB_DSPS}{y}
\item Check the dependencies of \kconfig{CONFIG_AM335X_PHY_USB}
and find the way to set \kconfigval{CONFIG_AM335X_PHY_USB}{y}
\item Find the "USB Gadget precomposed configurations" menu
and set it to {\em static} instead of {\em module}
so that \code{CONFIG_USB_ETH=y}
so that \kconfigval{CONFIG_USB_ETH}{y}
\end{itemize}
Make sure that this configuration has \code{CONFIG_ROOT_NFS=y} (support
Make sure that this configuration has \code{CONFIG_ROOT_NFS}{y} (support
booting on an NFS exported root directory).
\section{Kernel compiling}
Expand All @@ -93,7 +93,7 @@ \section{Kernel compiling}
(running 4 compile jobs in parallel):
\begin{verbatim}
make -j 8
make -j 8
\end{verbatim}
Now, copy the \code{zImage} and \code{am335x-boneblack.dtb}
Expand Down
8 changes: 4 additions & 4 deletions labs/kernel-debugging/kernel-debugging.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ \section{pr\_debug() and dynamic debugging}

Check what happens with your module. Do you see the debugging messages
that you added? Your kernel probably does not have
\code{CONFIG_DYNAMIC_DEBUG} set and your driver is not compiled with
\kconfig{CONFIG_DYNAMIC_DEBUG} set and your driver is not compiled with
\code{DEBUG} defined., so you shouldn't see any message.

Now, recompile your kernel with the following options:

\begin{itemize}
\item \code{CONFIG_DYNAMIC_DEBUG}: this will allow you to see
\item \kconfig{CONFIG_DYNAMIC_DEBUG}: this will allow you to see
debugging messages.
\item \code{CONFIG_DEBUG_INFO}: this option will make it
\item \kconfig{CONFIG_DEBUG_INFO}: this option will make it
possible to see source code in disassembled kernel code.
We will need it in a later part of this lab, but enabling
it now will allow to avoid recompiling the whole kernel again.
Expand Down Expand Up @@ -102,7 +102,7 @@ \section{Locating the exact line where the error happens}
this happens. Let's disassemble the code for this function to
understand exactly where the issue happened.

That's where we need a kernel compiled with \code{CONFIG_DEBUG_INFO}
That's where we need a kernel compiled with \kconfig{CONFIG_DEBUG_INFO}
as we did at the beginning of this lab. This way, the kernel is
compiled with \code{$(CROSSCOMPILE)gcc -g}, which keeps the source
code inside the binaries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ \section{Add polled input device support to the kernel}
polling API described in the lectures.

Rebuild your kernel with static support for polled input device
(\code{CONFIG_INPUT_POLLDEV=y}) and for event interface
(\code{CONFIG_INPUT_EVDEV}) support. With the default configuration,
(\kconfigval{CONFIG_INPUT_POLLDEV}{y}) and for event interface
(\kconfig{CONFIG_INPUT_EVDEV}) support. With the default configuration,
these features are available as modules, which is less convenient.

Update and reboot your kernel.
Expand Down Expand Up @@ -251,7 +251,7 @@ \subsubsection{Connect through SSH}
\subsubsection{Recompile your kernel}

Recompile your kernel with support for the joystick interface
(\code{CONFIG_INPUT_JOYDEV}).
(\kconfig{CONFIG_INPUT_JOYDEV}).

Reboot to the new kernel.

Expand Down
2 changes: 1 addition & 1 deletion labs/sysdev-flash-filesystems/sysdev-flash-filesystems.tex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ \section{Enabling NAND flash and filesystems}
First, make sure your kernel has support for UBI and UBIFS, and also
the option allowing us to pass the partition table through the command
line:
(\code{CONFIG_MTD_CMDLINE_PARTS}).
(\kconfig{CONFIG_MTD_CMDLINE_PARTS}).
Recompile your kernel if needed. We will update your kernel image on flash
in the next section.
Expand Down
14 changes: 7 additions & 7 deletions labs/sysdev-real-time/sysdev-real-time.tex
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ \section{Compile a standard Linux kernel}
Configure your kernel for your Xplained board, and then make sure
that the below settings are disabled:
\code{CONFIG_PROVE_LOCKING}, \code{CONFIG_DEBUG_LOCK_ALLOC},
\code{CONFIG_DEBUG_MUTEXES} and \code{CONFIG_DEBUG_SPINLOCK}.
\kconfig{CONFIG_PROVE_LOCKING}, \kconfig{CONFIG_DEBUG_LOCK_ALLOC},
\kconfig{CONFIG_DEBUG_MUTEXES} and \kconfig{CONFIG_DEBUG_SPINLOCK}.
Also, for the moment, disable the \code{CONFIG_HIGH_RES_TIMERS}
Also, for the moment, disable the \kconfig{CONFIG_HIGH_RES_TIMERS}
option which impact we want to measure.
Boot the Xplained board by mounting the root filesystem that you
Expand Down Expand Up @@ -150,14 +150,14 @@ \section{Compiling with the POSIX RT library}
Execute the program on the board. Is the clock resolution good or bad?
Compare it to the timer tick of your system, as defined by
\code{CONFIG_HZ}.
\kconfig{CONFIG_HZ}.
Copy the results in a file, in order to be able to compare them
with further results.
Obviously, this resolution will not provide accurate sleep times, and
this is because our kernel doesn't use high-resolution timers. So
let's add back the \code{CONFIG_HIGH_RES_TIMERS} option in the kernel
let's add back the \kconfig{CONFIG_HIGH_RES_TIMERS} option in the kernel
configuration.
Recompile your kernel, boot your Xplained with the new version, and
Expand All @@ -182,7 +182,7 @@ \section{Testing the non-preemptible kernel}
\section{Testing the preemptible kernel}
Recompile your kernel with \code{CONFIG_PREEMPT} enabled, which
Recompile your kernel with \kconfig{CONFIG_PREEMPT} enabled, which
enables kernel preemption (except for critical sections protected by
spinlocks).
Expand All @@ -194,7 +194,7 @@ \section{Compiling and testing the PREEMPT\_RT kernel}
Download the latest \code{PREEMPT_RT} kernel patch and apply it to
your kernel sources.
Configure your kernel with \code{CONFIG_PREEMPT_RT} and boot it.
Configure your kernel with \kconfig{CONFIG_PREEMPT_RT} and boot it.
Repeat the tests and compare the results again. You should see a massive
improvement in the maximum latency.
Expand Down
6 changes: 3 additions & 3 deletions labs/sysdev-thirdparty/sysdev-thirdparty.tex
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
\section{Audio support in the Kernel}

Recompile your kernel with audio support. The options we want are:
\code{CONFIG_SOUND}, \code{CONFIG_SND}, \code{CONFIG_SND_USB} and
\code{CONFIG_SND_USB_AUDIO}.
\kconfig{CONFIG_SOUND}, \kconfig{CONFIG_SND}, \kconfig{CONFIG_SND_USB} and
\kconfig{CONFIG_SND_USB_AUDIO}.

At this stage, the easiest solution to update your kernel is probably
to get back to copying it to RAM from \code{tftp}. Anyway, we will have
to modify U-Boot environment variables, as we are going to switch back to
NFS booting anyway.

Make sure that your board still boots with this new kernel.
Make sure that your board still boots with this new kernel.

\section{Figuring out library dependencies}

Expand Down
6 changes: 3 additions & 3 deletions slides/boot-time-application/boot-time-application.tex
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ \section{Optimizing applications}
\item {\em legacy} mode:
\begin{itemize}
\item Low accuracy, use a kernel driver to profile
\item \code{CONFIG_OPROFILE}
\item \kconfig{CONFIG_OPROFILE}
\item User space tools: \code{opcontrol} and \code{oprofiled}
\end{itemize}
\item {\em perf\_events} mode:
\begin{itemize}
\item Uses hardware performance counters
\item \code{CONFIG_PERF_EVENTS} and \code{CONFIG_HW_PERF_EVENTS}
\item \kconfig{CONFIG_PERF_EVENTS} and \kconfig{CONFIG_HW_PERF_EVENTS}
\item User space tools: \code{operf}
\end{itemize}
\end{itemize}
Expand Down Expand Up @@ -113,7 +113,7 @@ \section{Optimizing applications}
\frametitle{perf}
\begin{itemize}
\item Uses hardware performance counters
\item \code{CONFIG_PERF_EVENTS} and \code{CONFIG_HW_PERF_EVENTS}
\item \kconfig{CONFIG_PERF_EVENTS} and \kconfig{CONFIG_HW_PERF_EVENTS}
\item User space tool: \code{perf}. It is part of the kernel
sources so it is always in sync with your kernel.
\item Usage:
Expand Down
4 changes: 2 additions & 2 deletions slides/boot-time-bootloader/boot-time-bootloader.tex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ \section{Bootloader optimizations}
\code{setenv bootdelay 0}
\item This usually saves several seconds!
\item Before you do that, recompile U-Boot with
\code{CONFIG_ZERO_BOOTDELAY_CHECK}, documented in
\kconfig{CONFIG_ZERO_BOOTDELAY_CHECK}, documented in
\code{doc/README.autoboot}. It allows to stop the autoboot
process by hitting a key even if the boot delay is set to
\code{0}.
Expand Down Expand Up @@ -151,7 +151,7 @@ \section{Bootloader optimizations}
\frametitle{Further U-Boot optimizations}
\begin{itemize}
\item Silence U-Boot console output. You will need to compile
U-Boot with \code{CONFIG_SILENT_CONSOLE} and
U-Boot with \kconfig{CONFIG_SILENT_CONSOLE} and
\code{setenv silent yes}.\\
See \code{doc/README.silent} for details.
\end{itemize}
Expand Down
8 changes: 4 additions & 4 deletions slides/boot-time-filesystems/boot-time-filesystems.tex
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ \section{Filesystem optimizations}
\item Mount time depending on filesystem size: the kernel has to
scan the whole filesystem at mount time, to read which block
belongs to each file.
\item Need to use the \code{CONFIG_JFFS2_SUMMARY} kernel option
\item Need to use the \kconfig{CONFIG_JFFS2_SUMMARY} kernel option
to store such information in flash. This dramatically reduces
mount time.
\item Benchmark on ARM:\\
Expand Down Expand Up @@ -133,7 +133,7 @@ \section{Filesystem optimizations}
\begin{frame}
\frametitle{Using UBI Fastmap}
\begin{itemize}
\item Compile your kernel with \code{CONFIG_UBI_FASTMAP}
\item Compile your kernel with \kconfig{CONFIG_UBI_FASTMAP}
\item Boot your system at least once with the
\code{ubi.fm_autoconvert=1} kernel parameter.
\item Reboot your system in a clean way
Expand Down Expand Up @@ -170,7 +170,7 @@ \section{Filesystem optimizations}
For raw flash storage
\begin{itemize}
\item {\em ubiblock}: read-only block device on top of UBI
(\code{CONFIG_MTD_UBI_BLOCK}). Available in Linux 3.15
(\kconfig{CONFIG_MTD_UBI_BLOCK}). Available in Linux 3.15
(developed on his spare time by Ezequiel Garcia,
a Bootlin contractor).
\item Allows to put SquashFS on a UBI volume.
Expand All @@ -183,7 +183,7 @@ \section{Filesystem optimizations}
\begin{frame}
\frametitle{Finding the best filesystem}
\begin{itemize}
\item Raw flash storage: UBIFS with \code{CONFIG_UBI_FASTMAP} is
\item Raw flash storage: UBIFS with \kconfig{CONFIG_UBI_FASTMAP} is
probably the best solution.
\item Block storage: SquashFS best solution for root filesystems
which can be read-only. Btrfs and f2fs probably the best solutions
Expand Down
Loading

0 comments on commit 099b910

Please sign in to comment.