Skip to content

Commit

Permalink
appneta#136 memory tuning and dependecy fixes for kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Oct 7, 2014
1 parent 8d0548a commit 9ac8dca
Show file tree
Hide file tree
Showing 27 changed files with 129 additions and 60 deletions.
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ depmod = @depmod@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
extra_debug_flag = @extra_debug_flag@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
Expand Down
63 changes: 42 additions & 21 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ LPCAPLIB
LPCAPINC
DMALLOC_LIB
timestamp_trace_flag
extra_debug_flag
debug_flag
WORDS_BIGENDIAN_FALSE
WORDS_BIGENDIAN_TRUE
Expand Down Expand Up @@ -941,6 +942,7 @@ with_gnu_ld
enable_libtool_lock
enable_largefile
enable_debug
enable_extra_debug
enable_timestamp_trace
enable_dmalloc
enable_pedantic
Expand Down Expand Up @@ -1615,6 +1617,8 @@ Optional Features:
--disable-libtool-lock avoid locking (might break parallel builds)
--disable-largefile omit support for large files
--enable-debug Enable debugging code and support for the -d option
--enable-extra-debug Enable additional debugging code (may affect
performance)
--timestamp-trace Enable dumping of trace timestamps at the end of a
test
--enable-dmalloc Enable linking to dmalloc for better memory
Expand Down Expand Up @@ -5327,13 +5331,13 @@ if test "${lt_cv_nm_interface+set}" = set; then :
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
(eval echo "\"\$as_me:5330: $ac_compile\"" >&5)
(eval echo "\"\$as_me:5334: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
(eval echo "\"\$as_me:5333: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval echo "\"\$as_me:5337: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
(eval echo "\"\$as_me:5336: output\"" >&5)
(eval echo "\"\$as_me:5340: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
Expand Down Expand Up @@ -6539,7 +6543,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 6542 "configure"' > conftest.$ac_ext
echo '#line 6546 "configure"' > conftest.$ac_ext
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
Expand Down Expand Up @@ -8065,11 +8069,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:8068: $lt_compile\"" >&5)
(eval echo "\"\$as_me:8072: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:8072: \$? = $ac_status" >&5
echo "$as_me:8076: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -8404,11 +8408,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:8407: $lt_compile\"" >&5)
(eval echo "\"\$as_me:8411: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:8411: \$? = $ac_status" >&5
echo "$as_me:8415: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -8509,11 +8513,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:8512: $lt_compile\"" >&5)
(eval echo "\"\$as_me:8516: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:8516: \$? = $ac_status" >&5
echo "$as_me:8520: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -8564,11 +8568,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:8567: $lt_compile\"" >&5)
(eval echo "\"\$as_me:8571: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:8571: \$? = $ac_status" >&5
echo "$as_me:8575: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -10948,7 +10952,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 10951 "configure"
#line 10955 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -11044,7 +11048,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11047 "configure"
#line 11051 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -14349,11 +14353,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14352: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14356: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:14356: \$? = $ac_status" >&5
echo "$as_me:14360: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -14448,11 +14452,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14451: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14455: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:14455: \$? = $ac_status" >&5
echo "$as_me:14459: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -14500,11 +14504,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14503: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14507: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:14507: \$? = $ac_status" >&5
echo "$as_me:14511: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -18597,21 +18601,38 @@ fi


debug=no
debug_flag=NDEBUG
# Check whether --enable-debug was given.
if test "${enable_debug+set}" = set; then :
enableval=$enable_debug; if test x$enableval = xyes; then
debug=yes
CFLAGS="${USER_CFLAGS} -g -O0 -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros $wno_format_contains_nul"
# We may also want to add:
# -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"

debug_flag=DEBUG

$as_echo "#define DEBUG 1" >>confdefs.h

fi
fi



extra_debug=no
extra_debug_flag=NEXTRA_DEBUG
# Check whether --enable-extra-debug was given.
if test "${enable_extra_debug+set}" = set; then :
enableval=$enable_extra_debug; if test x$enableval = xyes; then
extra_debug=yes
extra_debug_flag=EXTRA_DEBUG

$as_echo "#define EXTRA_DEBUG 1" >>confdefs.h

fi
fi



timestamp_trace=no
# Check whether --enable-timestamp-trace was given.
if test "${enable_timestamp_trace+set}" = set; then :
Expand Down
16 changes: 15 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,30 @@ AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])

dnl Enable debugging in code/compiler options
debug=no
debug_flag=NDBUG
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
[ if test x$enableval = xyes; then
debug=yes
CFLAGS="${USER_CFLAGS} -g -O0 -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros $wno_format_contains_nul"
# We may also want to add:
# -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
AC_SUBST(debug_flag)
debug_flag=DEBUG
AC_DEFINE([DEBUG], [1], [Enable debugging code and support for the -d option])
fi])
AC_SUBST(debug_flag)

dnl Enable extra debugging in code/compiler options - may slow down performance
extra_debug=no
extra_debug_flag=NEXTRA_DBUG
AC_ARG_ENABLE(extra-debug,
AC_HELP_STRING([--enable-extra-debug], [Enable additional debugging code (may affect performance)]),
[ if test x$enableval = xyes; then
extra_debug=yes
extra_debug_flag=EXTRA_DEBUG
AC_DEFINE([EXTRA_DEBUG], [1], [Enable additional debugging code (may affect performance)])
fi])
AC_SUBST(extra_debug_flag)

dnl Enable timestamp_trace in code/compiler options
timestamp_trace=no
Expand Down
1 change: 1 addition & 0 deletions docs/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ depmod = @depmod@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
extra_debug_flag = @extra_debug_flag@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
Expand Down
1 change: 1 addition & 0 deletions kernel/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ depmod = @depmod@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
extra_debug_flag = @extra_debug_flag@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
Expand Down
1 change: 1 addition & 0 deletions kernel/linux/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ depmod = @depmod@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
extra_debug_flag = @extra_debug_flag@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
Expand Down
1 change: 1 addition & 0 deletions kernel/linux/example/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ depmod = @depmod@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
extra_debug_flag = @extra_debug_flag@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
Expand Down
25 changes: 11 additions & 14 deletions kernel/linux/include/linux/quick_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ extern void quick_tx_worker(struct work_struct *work);
while(0)

#ifdef __x86_64__
# define LOOKUP_TABLE_SIZE (1 << 17) /* 128K */
# define MEM_BLOCK_TABLE_SIZE (1 << 15) /* 64K */
# define LOOKUP_TABLE_SIZE (1 << 15) /* 32K packets */
# define MAX_MEM_BLOCK_TABLE_SIZE (1 << 15) /* 32K blocks (typically one 4096 page per block) */
#else
# define LOOKUP_TABLE_SIZE (1 << 15) /* 64K */
# define MEM_BLOCK_TABLE_SIZE (1 << 13) /* 16K */
# define LOOKUP_TABLE_SIZE (1 << 13) /* 16K packets */
# define MAX_MEM_BLOCK_TABLE_SIZE (1 << 13) /* 16K (typically one 4096 page per block) */
#endif

#define DEV_NAME_PREFIX "quick_tx_"
Expand Down Expand Up @@ -282,7 +282,7 @@ struct quick_tx_shared_data {
__u32 lookup_consumer_index;
__u32 lookup_producer_index;

struct quick_tx_mem_block_entry mem_blocks[MEM_BLOCK_TABLE_SIZE];
struct quick_tx_mem_block_entry mem_blocks[MAX_MEM_BLOCK_TABLE_SIZE];
__u32 mem_producer_index;
__u32 mem_producer_offset;
__u32 num_mem_blocks;
Expand Down Expand Up @@ -377,7 +377,7 @@ static inline int quick_tx_mmap_mem_block(struct quick_tx* dev) {
assert(dev);
assert(dev->data);

if (dev->data->num_mem_blocks < MEM_BLOCK_TABLE_SIZE) {
if (dev->data->num_mem_blocks < MAX_MEM_BLOCK_TABLE_SIZE) {
unsigned int *map;
map = mmap(0, dev->data->num_pages_per_block * PAGE_SIZE,
PROT_READ | PROT_WRITE, MAP_SHARED, dev->fd, 0);
Expand All @@ -394,16 +394,13 @@ static inline int quick_tx_mmap_mem_block(struct quick_tx* dev) {


/*
* TODO update comments - does not apply outside sample program because
* space required is unknown
*
* This function will preallocate the amount of space an application
* might require. Running without calling this function first will yield
* lower speeds. It is recommended to use the full size of the PCAP file
* for this value.
*
* @dev quick_tx device pointer
* @bytes number of bytes the application plans to transmit
* @bytes number of bytes to allocate for the queue
*
* @return will return the number of blocks that was actually allocated in the kernel
* module. If the return is 0 then there is definitely no more space for allocation
Expand All @@ -414,7 +411,7 @@ static inline int quick_tx_alloc_mem_space(struct quick_tx* dev, int64_t bytes)

int num = 0;
int64_t num_blocks = 1 + (bytes / (PAGE_SIZE * dev->data->num_pages_per_block));
while (num_blocks > 0 && dev->data->num_mem_blocks < MEM_BLOCK_TABLE_SIZE) {
while (num_blocks > 0 && dev->data->num_mem_blocks < MAX_MEM_BLOCK_TABLE_SIZE) {
if (quick_tx_mmap_mem_block(dev) == 0) {
num_blocks--;
num++;
Expand All @@ -435,7 +432,7 @@ static inline int quick_tx_mmap_all_mem_blocks(struct quick_tx* dev) {
assert(dev->data);

int num = 0;
while (dev->data->num_mem_blocks < MEM_BLOCK_TABLE_SIZE) {
while (dev->data->num_mem_blocks < MAX_MEM_BLOCK_TABLE_SIZE) {
if (quick_tx_mmap_mem_block(dev) < 0)
break;

Expand Down Expand Up @@ -499,7 +496,7 @@ static inline bool __get_write_offset_and_inc(struct quick_tx* dev, int length,
__u32 new_mem_producer_index = 0;
/* We will have to use the next available DMA block of memory */

new_mem_producer_index = (data->mem_producer_index + 1) % MEM_BLOCK_TABLE_SIZE;
new_mem_producer_index = (data->mem_producer_index + 1) % MAX_MEM_BLOCK_TABLE_SIZE;
struct quick_tx_mem_block_entry* next_mem_block =
&data->mem_blocks[new_mem_producer_index];
rmb();
Expand Down Expand Up @@ -638,7 +635,7 @@ static inline int quick_tx_send_packet(struct quick_tx* dev, const void* buffer,
wmb();

static int qtx_s = 0;
if (qtx_s % (MEM_BLOCK_TABLE_SIZE >> 4) == 0) {
if (qtx_s % (MAX_MEM_BLOCK_TABLE_SIZE >> 4) == 0) {
quick_tx_wakeup(dev);
}
qtx_s++;
Expand Down
25 changes: 25 additions & 0 deletions kernel/linux/quick_tx/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,31 @@
</tool>
</toolChain>
</folderInfo>
<fileInfo id="0.1593729338.1107724167" name="quick_tx_mmap.c" rcbsApplicability="disable" resourcePath="quick_tx_mmap.c" toolsToInvoke="org.eclipse.cdt.build.core.settings.holder.227917135.158475107">
<tool id="org.eclipse.cdt.build.core.settings.holder.227917135.158475107" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder.1632850674">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1619267572" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</fileInfo>
<fileInfo id="0.1593729338.2094585002" name="quick_tx_worker_virtio_net.c" rcbsApplicability="disable" resourcePath="quick_tx_worker_virtio_net.c" toolsToInvoke="org.eclipse.cdt.build.core.settings.holder.227917135.298751000">
<tool id="org.eclipse.cdt.build.core.settings.holder.227917135.298751000" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder.1632850674">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.988573792" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</fileInfo>
<fileInfo id="0.1593729338.636592138" name="quick_tx_main.c" rcbsApplicability="disable" resourcePath="quick_tx_main.c" toolsToInvoke="org.eclipse.cdt.build.core.settings.holder.227917135.115148595">
<tool id="org.eclipse.cdt.build.core.settings.holder.227917135.115148595" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder.1632850674">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.708339869" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</fileInfo>
<fileInfo id="0.1593729338.1366981353" name="quick_tx_worker_e1000.c" rcbsApplicability="disable" resourcePath="quick_tx_worker_e1000.c" toolsToInvoke="org.eclipse.cdt.build.core.settings.holder.227917135.860363688">
<tool id="org.eclipse.cdt.build.core.settings.holder.227917135.860363688" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder.1632850674">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1464566339" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</fileInfo>
<fileInfo id="0.1593729338.1427561375" name="quick_tx_worker.c" rcbsApplicability="disable" resourcePath="quick_tx_worker.c" toolsToInvoke="org.eclipse.cdt.build.core.settings.holder.227917135.204021829">
<tool id="org.eclipse.cdt.build.core.settings.holder.227917135.204021829" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder.1632850674">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.479842476" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="include" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
Expand Down
Loading

0 comments on commit 9ac8dca

Please sign in to comment.