Sample Header Ad - 728x90

GPL/CCO: Fedora 38 driver module build takes hours instead of minutes

0 votes
1 answer
129 views
FYI: The driver's Linux specific content if GPL. Everything else is CC0. I made a virgin installation of Fedora 38. To verify that all was setup suitably, I went on to build one of my drivers. The output to the screen was slightly different than previous Fedora releases, but such changes are common. What was new was that the build takes a long time - a very long time. At present, three different builds have been running for over 22 hours. Each build should have taken about seven minutes. Looking at the .o file dates, it emphasized texttakes about 20 minutes to compile each driver source file. Each eventually completed successfully after about 25 hours. I'm seeking assistance to correct the excruciatingly slow driver builds. Any help would be greatly appreciated. Thank you, **Generate the problem:** 1. Download the "Fedora Workstation 38 Live ISO" image for "For Intel and AMD x86_64 systems" from "https://fedoraproject.org/workstation/download/ ". 2. Install to suitable media. 3. Boot the installable media and perform installation. 4. Boot to the virgin installation and proceed with user account generation and so forth. 5. Install various packages: elfutils-libelf-devel, "kernel-headers-xxx" for current kernel version, "kernel-devel-xxx" for current kernel version 6. Download the driver archive from the General Standards web site (the version number will change over time): http://www.generalstandards.com/downloads/24dsi6c500k.linux.2.3.104.47.1.tar.gz 7. Decompress the archive: tar -xf ./Download/24dsi6c500k.linux.2.3.104.47.0.tar.gz 8. Change into the driver directory: cd 24dsi6c500k/driver 9. Build the driver: make -f Makefile 10. Some initial output is generated, but the build output otherwise proceeds at about one source file compiled every 20 minutes. The final steps take even longer. **The output generated is as follows:**
make: Entering directory '/usr/src/kernels/6.2.9-300.fc38.x86_64'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (GCC) 13.0.1 20230318 (Red Hat 13.0.1-0)
  You are using:           gcc (GCC) 13.0.1 20230401 (Red Hat 13.0.1-0)
  CC [M]  /root/c/gsc/24dsi6c500k/linux/driver/close.o
  CC [M]  /root/c/gsc/24dsi6c500k/linux/driver/device.o
  CC [M]  /root/c/gsc/24dsi6c500k/linux/driver/io.o
....
  CC [M]  /root/c/gsc/24dsi6c500k/linux/driver/os_spinlock.o
  CC [M]  /root/c/gsc/24dsi6c500k/linux/driver/os_time.o
  CC [M]  /root/c/gsc/24dsi6c500k/linux/driver/os_write.o"
It does eventually go to completion. **What I've tried to remedy the problem:** 1. The build’s initial screen output is shown here.
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (GCC) 13.0.1 20230318 (Red Hat 13.0.1-0)
  You are using:           gcc (GCC) 13.2.1 20230728 (Red Hat 13.2.1-0)
Supposing that the slowdown could be a compiler issue I downgraded gcc to the version reported to have been used to build the kernel. The initial output is now as follows, but the build is still extremely slow.
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (GCC) 13.0.1 20230318 (Red Hat 13.0.1-0)
  You are using:           gcc (GCC) 13.0.1 20230401 (Red Hat 13.0.1-0)
2. I reinstalled Fedora 38 and tried again, but there was no improvement. 3. I applied all available updates, but this too did not help. 4. I’ve also turned off the firewall, disabled SELinux and logged in as root, but none of these helped. 5. My builds are normally done over the network on a SAMBA mounted Windows 10 share. So, I tried the build on the local drive, which was a USB 3.0 based M.2 drive. There was no improvement. 6. I then tried another virgin installation on a SATA drive. There was no improvement when building over the network or when building on the local SATA drive. 7. I’ve tried the build under Fedora 38 on three entirely different hosts and have observed the same, very slow results. 8. I've built the driver on several different Fedora installations and hosts to demonstrate the build times for Fedora 38 and for some previous Fedora releases. A. Fedora 38, 64-bit, 8 core, 3.6GHz, 8GB, 2-year-old motherboard (Gigabyte Z390 Designare), Samba mount: 22 hours so far B. Fedora 38, 64-bit, 8 core, 3.6GHz, 8GB, 2-year-old motherboard (Gigabyte Z390 Designare), SATA drive: 22 hours so far C. Fedora 38, 64-bit, 8 core, 3.2GHz, 32GB, 7-year-old motherboard (Asus X99-A/USB 3.1), USB 3 M.2: 22 hours so far D. Fedora 37, 64-bit, 2 core, 2.5GHz, 8GB, 12-year-old motherboard (Asus X99-A/USB 3.1), USB 2 M.2: 7 minutes E. Fedora 36, 64-bit, 2 core, 2.5GHz, 8GB, 12-year-old motherboard (Super X7SBA), SATA drive: 7 minutes F. Fedora 3, 32-bit, 2 core, 2.2GHz, 1GB, 20-year-old motherboard (Iwill DP400), IEDE drive: 37 seconds Over the years I’ve used every formal Fedora release since Fedora Core 3, plus many other distributions. Builds have never taken more than about seven minutes for any of the 45 different drivers I’ve written, maintain and built thousands of times. Build obstacles under new distributions and versions have, until now, been trivial in comparison. (For those who suggest I contact the manufacturer of this driver, well, that would be me.) **Here are my make files:** **Makefile:**
TARGET      := 24dsi6c500k

.NOTPARALLEL: %.o

OBJ_FILES   =                   \
            close.o             \
            device.o            \
            io.o                \
            ioctl.o             \
            irq.o               \
            open.o              \
            read.o              \
            reg.o               \
                                \
            gsc_bar.o           \
            gsc_close.o         \
            gsc_dma.o           \
            gsc_dma_pci.o       \
            gsc_eeprom.o        \
            gsc_endian.o        \
            gsc_endian_pci.o    \
            gsc_init.o          \
            gsc_io.o            \
            gsc_ioctl.o         \
            gsc_irq.o           \
            gsc_irq_pci.o       \
            gsc_open.o          \
            gsc_read.o          \
            gsc_reg.o           \
            gsc_utils.o         \
            gsc_wait.o          \
            gsc_write.o         \
                                \
            os_bar.o            \
            os_close.o          \
            os_event.o          \
            os_init.o           \
            os_ioctl.o          \
            os_irq.o            \
            os_kernel_2_2.o     \
            os_kernel_2_4.o     \
            os_kernel_2_6.o     \
            os_kernel_3.o       \
            os_kernel_4.o       \
            os_kernel_5.o       \
            os_kernel_6.o       \
            os_mem.o            \
            os_metrics.o        \
            os_open.o           \
            os_pci.o            \
            os_proc.o           \
            os_read.o           \
            os_reg.o            \
            os_sem.o            \
            os_spinlock.o       \
            os_time.o           \
            os_write.o



###############################################################################
# Everything here is needed so we can access os_makefile.inc.

.EXPORT_ALL_VARIABLES:

# Locate the source from the starting directory.
ifndef GSC_DEV_DIR
GSC_DEV_DIR := $(shell pwd)
endif

include ${GSC_DEV_DIR}/os_makefile.inc
**os_makefile.inc:**
default: all

# Identify the /dev/nul(l) device
NULL    := $(shell ls /dev/nu[l]* | grep -w null | wc -l )
NULL    := $(shell expr ${NULL})

ifeq ("${NULL}","1")
NULL    := /dev/null
else
NULL    := /dev/nul
endif

.PHONY: all clean default makefile release

# Most of this is ignored by the 2.6 (and later) module builder.
CC          = gcc
CC_FLAGS    += -c -O6 -pipe -fomit-frame-pointer -Wall
CC_FLAGS    += -D__KERNEL__ -DLINUX
CC_FLAGS    += -I. -I${KERNELDIR}
DEP_FILE    = ${GSC_DEV_DIR}/makefile.dep
KERNELDIR   =
KERNELVER   = $(shell uname -r | cut -d . -f1-2 )
KERNELMAJOR = $(shell uname -r | cut -d . -f1 )
RELEASE_RM  = ${OBJ_FILES} .tmp* .*.o.cmd .*.ko.cmd .*.mod.cmd .*.ko.*.cmd *.ko.unsigned *.mod.* *.mod Modules*



# kernel 2.2 ==================================================================
ifeq ("${KERNELVER}","2.2")
KERNELDIR   = /usr/src/linux
MODULE_NAME = ${TARGET}.o

${MODULE_NAME}: ${OBJ_FILES}
    @echo ==== Linking: $@
    @ld -r -o $@ ${OBJ_FILES}
endif

# kernel 2.4 ==================================================================
ifeq ("${KERNELVER}","2.4")

K_DIR   := $(shell ls -d /usr/src/linux/include 2>/dev/null | wc -l )
K_DIR   := $(shell echo $(K_DIR) | sed -e 's/[ \t]*//g')

ifeq ("${K_DIR}","1")
KERNELDIR   = /usr/src/linux/include
else
KERNELDIR   = /usr/src/linux-2.4/include
endif

MODULE_NAME = ${TARGET}.o

${MODULE_NAME}: ${OBJ_FILES}
    @echo ==== Linking: $@
    @ld -r -o $@ ${OBJ_FILES}
endif

# kernel 2.6 ==================================================================
ifeq ("${KERNELVER}","2.6")

${TARGET}-objs  = ${OBJ_FILES}
KERNELDIR       = /lib/modules/$(shell uname -r)/build
MODULE_NAME     = ${TARGET}.ko
obj-m           = ${TARGET}.o
PWD             = $(shell pwd)
RELEASE_RM      += ${TARGET}.o Module.symvers

${MODULE_NAME}: $(shell ls ${GSC_DEV_DIR}/*.[ch])
    @-chmod +rw ${DEP_FILE}
    @-echo -n > ${DEP_FILE}
    @make -C ${KERNELDIR} SUBDIRS=${PWD} modules
    @strip -d --strip-unneeded $@
    @rm -f *.mod.c
endif

# kernel 3.x ==================================================================
ifeq ("${KERNELMAJOR}","3")

${TARGET}-objs  = ${OBJ_FILES}
KERNELDIR       = /lib/modules/$(shell uname -r)/build
MODULE_NAME     = ${TARGET}.ko
obj-m           = ${TARGET}.o
PWD             = $(shell pwd)
RELEASE_RM      += ${TARGET}.o Module.symvers

${MODULE_NAME}: $(shell ls ${GSC_DEV_DIR}/*.[ch])
    @-chmod +rw ${DEP_FILE}
    @-echo -n > ${DEP_FILE}
    @make -C ${KERNELDIR} SUBDIRS=${PWD} modules
    @strip -d --strip-unneeded $@
    @rm -f *.mod.c
endif

# kernel 4.x ==================================================================
ifeq ("${KERNELMAJOR}","4")

${TARGET}-objs  = ${OBJ_FILES}
KERNELDIR       = /lib/modules/$(shell uname -r)/build
MODULE_NAME     = ${TARGET}.ko
obj-m           = ${TARGET}.o
PWD             = $(shell pwd)
RELEASE_RM      += ${TARGET}.o Module.symvers

${MODULE_NAME}: $(shell ls ${GSC_DEV_DIR}/*.[ch])
    @-chmod +rw ${DEP_FILE}
    @-echo -n > ${DEP_FILE}
    @make -C ${KERNELDIR} SUBDIRS=${PWD} modules
    @strip -d --strip-unneeded $@
    @rm -f *.mod.c
endif

# kernel 5.x ==================================================================
ifeq ("${KERNELMAJOR}","5")

${TARGET}-objs  = ${OBJ_FILES}
KERNELDIR       = /lib/modules/$(shell uname -r)/build
MODULE_NAME     = ${TARGET}.ko
obj-m           = ${TARGET}.o
PWD             = $(shell pwd)
RELEASE_RM      += ${TARGET}.o Module.symvers

${MODULE_NAME}: $(shell ls ${GSC_DEV_DIR}/*.[ch])
    @-chmod +rw ${DEP_FILE}
    @-echo -n > ${DEP_FILE}
    @make -C ${KERNELDIR} M=${PWD} modules
    @strip -d --strip-unneeded $@
    @rm -f *.mod.c
endif

# kernel 6.x ==================================================================
ifeq ("${KERNELMAJOR}","6")

${TARGET}-objs  = ${OBJ_FILES}
KERNELDIR       = /lib/modules/$(shell uname -r)/build
MODULE_NAME     = ${TARGET}.ko
obj-m           = ${TARGET}.o
PWD             = $(shell pwd)
RELEASE_RM      += ${TARGET}.o Module.symvers

${MODULE_NAME}: $(shell ls ${GSC_DEV_DIR}/*.[ch])
    @-chmod +rw ${DEP_FILE}
    @-echo -n > ${DEP_FILE}
    @make -C ${KERNELDIR} M=${PWD} modules
    @strip -d --strip-unneeded $@
    @rm -f *.mod.c
endif

# kernel OTHER ================================================================
ifeq ("${KERNELDIR}","")

KERNELDIR   = KERNELDIR_os_makefile.inc_not_known_at_this_time
MODULE_NAME = MODULE_NAME_os_makefile.inc_not_known_at_this_time

${MODULE_NAME}:
    @echo ERROR: KERNEL ${KERNELVER} IS NOT SUPPORTED BY THIS MAKEFILE.
    @_ERROR_ERROR_ERROR_ERROR_ERROR_ERROR_ERROR_ERROR_ERROR
endif



# COMMON ======================================================================

#This is ignored by the 2.6 (and later) module builder.
.c.o:
    @echo == Compiling: $  .tmp1
    @# Remove trailing white space and backslash, if present.
    @-sed -e "s/[ ]*[\\\\]//g"  .tmp2
    @# Put everything on seperate lines.
    @-tr [:space:] \\n  .tmp3
    @# Remove all of the system include files.
    @-grep -v "^[ ]*/"  .tmp4
    @# Remove all empty lines.
    @-grep [[:alnum:]]  .tmp5
    @# Put everything on the same line.
    @-tr '\n' '\040'  .tmp6
    @-echo -e '\012' >> .tmp6
    @# Add all the other dependencies to the end of this file.
    @-echo >> ${DEP_FILE}
    @-grep -v "^[ ]*$@" > .tmp6
    @# Remove blank lines from the list.
    @-grep "[[:alnum:]]"  .tmp7
    @# Sort the list and put it in the dependency file.
    @-sort  ${DEP_FILE}
    @# Cleanup.
    @rm -f .tmp?
    @rm -r -f -d .tmp*\*
    @# Compile the module.
    @${CC} ${CC_FLAGS} $ ${DEP_FILE}

${DEP_FILE}:
    @echo ==== Creating: $@
    @echo > ${DEP_FILE}
    @-chmod +rw ${DEP_FILE}

include ${DEP_FILE}
**makefile.dep:** (an empty file essentially ignored under 2.6 and later kernel builds)
Asked by Don (11 rep)
Aug 22, 2023, 01:01 PM
Last activity: Oct 5, 2023, 09:30 PM