Skip to content

Commit

Permalink
Revert "Remove hard kernel threads references"
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcEye authored Nov 26, 2018
1 parent 3cdd782 commit 114a7cb
Show file tree
Hide file tree
Showing 6 changed files with 391 additions and 106 deletions.
7 changes: 7 additions & 0 deletions debian/rules.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ SHLIBDEPS_X += halmeter classicladder halscope
THREADS_POSIX = --without-posix
THREADS_RT_PREEMPT = --without-rt-preempt
THREADS_XENOMAI = --without-xenomai
#THREADS_XENOMAI_KERNEL = --without-xenomai-kernel
#THREADS_RTAI_KERNEL = --without-rtai-kernel

# Kernel threads need a list of configured header source directories
# for each architecture
Expand All @@ -50,6 +52,11 @@ THREADS_XENOMAI = --without-xenomai
#
DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

#HEADERS_XENOMAI_KERNEL_i386 = --with-xenomai-kernel-sources=""
#HEADERS_XENOMAI_KERNEL_amd64 = --with-xenomai-kernel-sources=""
#HEADERS_RTAI_KERNEL_amd64 = --with-rtai-kernel-sources=""
#HEADERS_RTAI_KERNEL_i386 = --with-rtai-kernel-sources=""

# Parallel make
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
Expand Down
184 changes: 115 additions & 69 deletions scripts/check-system-configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ get-conf-files() {
conf_files="$*"
local conflist=""
for i in $conf_files; do
conflist+=" $(readlink -e $i)"
conflist+=" $(readlink -e $i)"
done
echo $conflist
}
Expand All @@ -28,45 +28,45 @@ check-rsyslog() {
local nologfile=false
if test ! -f $logfile
then
echo "Warning: Logfile '$logfile' does not exist."
echo
echo " rsyslogd does not create non-existent log files; be"
echo " sure the (possibly empty) logfile exists and"
echo " restart rsyslogd"
echo
echo " Hint:"
echo " $ sudo touch /var/log/linuxcnc.log"
echo " $ sudo service rsyslog restart"
echo
echo " Gurus: If you intentionally log to another file,"
echo " please be aware of where Machinekit logs go for"
echo " debugging purposes"
echo
res=1
nologfile=true
echo "Warning: Logfile '$logfile' does not exist."
echo
echo " rsyslogd does not create non-existent log files; be"
echo " sure the (possibly empty) logfile exists and"
echo " restart rsyslogd"
echo
echo " Hint:"
echo " $ sudo touch /var/log/linuxcnc.log"
echo " $ sudo service rsyslog restart"
echo
echo " Gurus: If you intentionally log to another file,"
echo " please be aware of where Machinekit logs go for"
echo " debugging purposes"
echo
res=1
nologfile=true
fi

if test -z "$logconfigs"; then
echo "Warning: No rsyslog.conf found; system log daemon not rsyslogd?"
echo
echo " Please check your syslog configuration for"
echo " rate limiting; an example for rsyslogd can be found in"
echo " src/rtapi/rsyslogd-linuxcnc.conf"
echo
echo "Warning: No rsyslog.conf found; system log daemon not rsyslogd?"
echo
echo " Please check your syslog configuration for"
echo " rate limiting; an example for rsyslogd can be found in"
echo " src/rtapi/rsyslogd-linuxcnc.conf"
echo
elif ! grep -q SystemLogRateLimitBurst $logconfigs; then
res=1
echo "Warning: No rate limit in rsyslogd is set."
echo
echo " The 'rsyslogd' daemon drops logs when incoming at"
echo " higher than the rate configured by"
echo " 'SystemLogRateLimitBurst'. The default rate is lower"
echo " than Machinekit requires when running in debug mode."
echo
echo " Hint:"
echo " $ sudo cp rtapi/rsyslogd-linuxcnc.conf" \
"/etc/rsyslog.d/linuxcnc.conf"
echo " $ sudo service rsyslog restart"
echo
res=1
echo "Warning: No rate limit in rsyslogd is set."
echo
echo " The 'rsyslogd' daemon drops logs when incoming at"
echo " higher than the rate configured by"
echo " 'SystemLogRateLimitBurst'. The default rate is lower"
echo " than Machinekit requires when running in debug mode."
echo
echo " Hint:"
echo " $ sudo cp rtapi/rsyslogd-linuxcnc.conf" \
"/etc/rsyslog.d/linuxcnc.conf"
echo " $ sudo service rsyslog restart"
echo
fi
test $res -ne 0 && return 1

Expand All @@ -77,15 +77,15 @@ check-rsyslog() {
if grep -q $tag $logfile >/dev/null 2>/dev/null
then
# logging works
return 0
return 0
else
echo "Warning: Logging appears to be not working"
echo
echo " Found rsyslogd configuration and $logfile"
echo " exists, but a test did not appear in the log."
echo " Please investigate."
echo
return 1
echo "Warning: Logging appears to be not working"
echo
echo " Found rsyslogd configuration and $logfile"
echo " exists, but a test did not appear in the log."
echo " Please investigate."
echo
return 1
fi
}

Expand All @@ -96,7 +96,7 @@ check-rsyslog() {
#
check-ulimits() {
local ulimit_configs="$(get-conf-files \
/etc/security/limits.conf /etc/security/limits.d/*.conf)"
/etc/security/limits.conf /etc/security/limits.d/*.conf)"
# a guess at what a reasonable memlock value should be
local reasonable_memlock=32767

Expand All @@ -110,45 +110,91 @@ check-ulimits() {
local last_ulimit_config
local memlock_found=false
for f in $ulimit_configs; do
mtmp=$(awk '/^\*[ \t]+(-|soft)[ \t]+memlock/ {m=$4} END {print m}' $f)
if test -n "$mtmp"; then
if test $memlock != 0; then
echo "Warning: Multiple configurations for 'memlock' setting"
mtmp=$(awk '/^\*[ \t]+(-|soft)[ \t]+memlock/ {m=$4} END {print m}' $f)
if test -n "$mtmp"; then
if test $memlock != 0; then
echo "Warning: Multiple configurations for 'memlock' setting"
echo
echo " Please check configuration in these files:"
echo " $last_ulimit_config"
echo " $f"
echo
return 1
fi
memlock=$mtmp
memlock_found=true
last_ulimit_config=$f
fi
done
if ! $memlock_found; then
echo "Warning: no configuration for 'memlock' found"
echo
echo " Please check configuration in these files:"
echo " $last_ulimit_config"
echo " $f"
echo " Hint:"
echo " $ sudo cp rtapi/shmdrv/limits.d-machinekit.conf /etc/security/limits.d/machinekit.conf"
return 1
fi

# Next, check the 'memlock' value looks sane
if test $memlock != unlimited && test $memlock -lt $reasonable_memlock; then
echo "Warning: Config 'memlock' value $memlock too small"
echo
echo " Value for 'memlock' in file $last_ulimit_config"
echo " should be raised to $reasonable_memlock or greater"
echo
return 1
fi
memlock=$mtmp
memlock_found=true
last_ulimit_config=$f
fi
}


#
# Check shmdrv udev configuration
#
# The shmdrv converged shared memory driver for kthreads flavors must
# be accessible. Look for a 'shmdrv.rules' file.
check-shmdrv() {
local udev_conf=/etc/udev/rules.d/50-shmdrv.rules
local udev_configs="$(get-conf-files /etc/udev/rules.d/*.rules)"

# If $udev_conf exists, assume the contents are correct
if test -f $udev_conf; then
return 0
fi

# Otherwise, assume any KERNEL=="shmdrv" setting is correct
for f in $udev_configs; do
if grep -q 'KERNEL=="shmdrv"' $f; then
return 0
fi
done
if ! $memlock_found; then
echo "Warning: no configuration for 'memlock' found"

# If we're here, we found no sign of udev configuration.
echo "Warning: No udev configuration for shmdrv was found."
echo
echo " The user running LinuxCNC must have write access to"
echo " /dev/shmdrv when running kernel threads, which may"
echo " be configured in /etc/udev/rules.d."
echo
echo " Hint:"
echo " $ sudo cp rtapi/shmdrv/limits.d-machinekit.conf /etc/security/limits.d/machinekit.conf"
return 1
fi

# Next, check the 'memlock' value looks sane
if test $memlock != unlimited && test $memlock -lt $reasonable_memlock; then
echo "Warning: Config 'memlock' value $memlock too small"
echo " $ sudo cp rtapi/shmdrv/shmdrv.rules $udev_conf"
echo " $ sudo udevadm trigger"
echo
echo " Value for 'memlock' in file $last_ulimit_config"
echo " should be raised to $reasonable_memlock or greater"
echo ""
return 1
fi
}

HAVE_KERNEL_THREADS=false
while getopts k opt; do
case "$opt" in
k) HAVE_KERNEL_THREADS=true ;;
*) echo "Usage: $0 [ -k ]" >&2; exit 1 ;;
esac
done


res=0
check-rsyslog || res=1
check-ulimits || res=1
if $HAVE_KERNEL_THREADS; then
check-shmdrv || res=1
fi

exit $res
73 changes: 73 additions & 0 deletions scripts/platform-is-supported
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/python2
#
# This script returns 0 when run on a platform supported by the current
# branch of LinuxCNC, and 1 when run on an unsupported platform. It is
# intended to guide build automation on whether or not to try to build.
#

import sys
import subprocess
import re


def detect_kernel_flavor(uname):
try:
f = open("/boot/config-%s" % uname)
except IOError:
print "no kernel configuration found for %s" % uname
sys.exit(1)
l = f.read(-1)
f.close()

config_ipipe = re.search('^CONFIG_IPIPE', l, re.MULTILINE)
config_xeno = re.search('^CONFIG_XENO_', l, re.MULTILINE)
config_rtpreempt = re.search('^CONFIG_PREEMPT_RT', l, re.MULTILINE)

if config_ipipe and not config_xeno and not config_rtpreempt:
return 'rtai'
elif config_ipipe and config_xeno and not config_rtpreempt:
return 'xenomai'
elif not config_ipipe and not config_xeno and config_rtpreempt:
return 'rtpreempt'
else:
return 'vanilla'


# use subprocess.Popen() in this funny way, instead of
# subprocess.check_output(), because check_output() is not in Hardy's
# Python 2.5

arch = subprocess.Popen(['dpkg-architecture', '-qDEB_HOST_ARCH'], stdout=subprocess.PIPE).communicate()[0][:-1]
distributor = subprocess.Popen(['lsb_release', '--id', '--short'], stdout=subprocess.PIPE).communicate()[0][:-1]

release = subprocess.Popen(['lsb_release', '--release', '--short'], stdout=subprocess.PIPE).communicate()[0][:-1]
major, minor = re.split('\.', release)
release_major = int(major)
release_minor = int(minor)

uname = subprocess.Popen(['uname', '-r'], stdout=subprocess.PIPE).communicate()[0][:-1]
kernel_flavor = detect_kernel_flavor(uname)

print "arch =", arch
print "distributor =", distributor
print "release =", release
print " major =", release_major
print " minor =", release_minor
print "uname = %s (%s)" % (uname, kernel_flavor)

if arch != "amd64" and arch != "i386":
print "unsupported architecture!"
sys.exit(1)

if distributor == 'Ubuntu':
if release_major < 10:
print "release is too old!"
sys.exit(1)

if kernel_flavor != 'rtai' and kernel_flavor != 'vanilla':
print "unsupported kernel flavor"
sys.exit(1)

print "this platform is supported!"
sys.exit(0)

Loading

0 comments on commit 114a7cb

Please sign in to comment.