Remove redundant dependencies
Ramesh Thomas
cover Remove redundant dependencies
libkmod and libudev are not necessary and are removed in this patchset. Presence of idxd kernel module is validated and if not loaded, an error message is printed before exiting the app. Accel-config will not try to load the kernel modules. The asumption is that systems where accel-config is run will have the necessary kernel modules already installed.
Ramesh Thomas (5):
accel-config: Remove use of libkmod
accel-config: Remove libkmod dependencies in build files
accel-config: Remove references to unused libudev
accel-config: Remove libkmod dependencies in build files
accel-config: Check for file existence instead of read permission
Makefile.am.in | 2 -- README.md | 4 +-- accfg-test.spec.in | 2 -- accfg.spec.in | 2 -- accfg/Makefile.am | 3 +-- accfg/accel-config.c | 40 +++------------------------- accfg/lib/Makefile.am | 4 +-- accfg/lib/libaccfg.c | 4 +-- accfg/lib/private.h | 12 +-------- configure.ac | 2 -- debian/control | 2 -- test/Makefile.am | 2 +- test/core.c | 1 - test/libaccfg.c | 61 +++++++------------------------------------ 14 files changed, 21 insertions(+), 120 deletions(-)
Signature · 1 line
2.26.3
Ramesh Thomas
PATCH 1/5 accel-config: Remove use of libkmod
From: Ramesh Thomas <ramesh.thomas(a)linux.intel.com>
Systems running accel-config is expected to have idxd kernel module already installed. Accel-config would fail if it is not loaded and would not try to load it. This removes the dependency on installion of kmod development package.
--- accfg/accel-config.c | 40 +++-------------------------- accfg/lib/private.h | 6 +---- test/core.c | 1 - test/libaccfg.c | 61 +++++++------------------------------------- 4 files changed, 14 insertions(+), 94 deletions(-)
accfg/accel-config.c +4 -36
@@ -7,7 +7,6 @@#include <unistd.h> #include <sys/stat.h> #include <sys/types.h> -#include <libkmod.h> #include <builtin.h> #include <accfg/libaccel_config.h> #include <ccan/array_size/array_size.h>
@@ -75,34 +74,9 @@ static struct cmd_struct commands[] = {#endif }; -static int idxd_kmod_init (struct kmod_ctx **ctx,struct kmod_module **mod) -{ -int rc; - - *ctx =kmod_new (NULL ,NULL ); -if (!*ctx) -return -ENXIO ; - - rc =kmod_module_new_from_name (*ctx,"idxd" , mod); -if (rc <0 ) { -kmod_unref (*ctx); -return rc; - } - - rc =kmod_module_get_initstate (*mod); -if (rc <0 ) { -kmod_module_unref (*mod); -kmod_unref (*ctx); - } - -return rc; -} -int main (int argc,const char **argv) {struct accfg_ctx *ctx; -struct kmod_ctx *kmod_ctx; -struct kmod_module *mod;unsigned int last_error;int rc;
@@ -122,18 +96,14 @@ int main(int argc, const char **argv)return -EINVAL ; } - rc =idxd_kmod_init (&kmod_ctx, &mod); -if (rc <0 ) { -fprintf (stderr,"Failed initializing kernel module\n" ); - goto error_exit; +if (access ("/sys/module/idxd" ,F_OK )) { +fprintf (stderr,"idxd kernel module not loaded\n" ); +return EXIT_FAILURE ; } rc =accfg_new (&ctx); -if (rc) { -kmod_module_unref (mod); -kmod_unref (kmod_ctx); +if (rc) goto error_exit; - } rc =main_handle_internal_command (argc, argv, ctx, commands,ARRAY_SIZE (commands));
@@ -161,8 +131,6 @@ int main(int argc, const char **argv)printf (": %s\n" ,accfg_ctx_get_last_error_str (ctx)); }accfg_unref (ctx); -kmod_module_unref (mod); -kmod_unref (kmod_ctx);if (!rc)return EXIT_SUCCESS ;
accfg/lib/private.h +1 -5
@@ -8,8 +8,8 @@#include <stdbool.h> #include <syslog.h> #include <string.h> +#include <inttypes.h> #include <libudev.h> -#include <libkmod.h> #include <util/log.h> #include <uuid/uuid.h> #include <ccan/list/list.h>
@@ -165,8 +165,4 @@ static inline int check_udev(struct udev *udev) return udev ? 0 : -ENXIO; } -static inline int check_kmod (struct kmod_ctx *kmod_ctx) -{ -return kmod_ctx ?0 : -ENXIO ; -}#endif /* _LIBACCFG_PRIVATE_H_ */
test/core.c +0 -1
@@ -3,7 +3,6 @@#include <linux/version.h> #include <sys/utsname.h> -#include <libkmod.h> #include <stdlib.h> #include <errno.h> #include <stdio.h>
test/libaccfg.c +9 -52
94 lines not on this page · raw message
Signature · 1 line
2.26.3
Ramesh Thomas
PATCH 2/5 accel-config: Remove libkmod dependencies in build files
In reply to Ramesh ThomasFrom: Ramesh Thomas <ramesh.thomas(a)linux.intel.com>
Remove libkmod package dependencies and references in build files and README.
--- Makefile.am.in | 1 - README.md | 4 ++-- accfg-test.spec.in | 1 - accfg.spec.in | 1 - accfg/Makefile.am | 3 +-- accfg/lib/Makefile.am | 3 +-- configure.ac | 1 - debian/control | 1 - test/Makefile.am | 2 +- 9 files changed, 5 insertions(+), 12 deletions(-)
Makefile.am.in +0 -1
@@ -12,7 +12,6 @@ AM_CPPFLAGS = \ -I${top_srcdir}/accfg/lib \ -I${top_srcdir}/accfg \ -I${top_srcdir}/ \ - $(KMOD_CFLAGS) \ $(UDEV_CFLAGS) \ $(UUID_CFLAGS) \ $(JSON_CFLAGS)
README.md +2 -2
@@ -9,13 +9,13 @@ sub-system in the Linux kernel ```bash yum groupinstall "Development Tools" yum install autoconf automake libtool pkgconf rpm-build rpmdevtools -yum install asciidoc xmlto libuuid-devel json-c-devel kmod-devel libudev-devel +yum install asciidoc xmlto libuuid-devel json-c-devel libudev-devel ``` ### Debian ```bash apt install build-essential apt install autoconf automake autotools-dev libtool pkgconf asciidoc xmlto -apt install uuid-dev libjson-c-dev libkmod-dev libudev-dev libkeyutils-dev +apt install uuid-dev libjson-c-dev libudev-dev libkeyutils-dev apt install debhelper devscripts debmake quilt fakeroot lintian asciidoctor apt install file gnupg patch patchutils ```
accfg-test.spec.in +0 -1
@@ -13,7 +13,6 @@ BuildRequires: xmlto BuildRequires: automake BuildRequires: libtool BuildRequires: pkgconfig -BuildRequires: pkgconfig(libkmod) BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(libudev)
accfg.spec.in +0 -1
@@ -13,7 +13,6 @@ BuildRequires: xmlto BuildRequires: automake BuildRequires: libtool BuildRequires: pkgconfig -BuildRequires: pkgconfig(libkmod) BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(libudev)
accfg/Makefile.am +1 -2
@@ -23,8 +23,7 @@ accel_config_LDADD =\ lib/libaccel-config.la \ ../libutil.a \ $(JSON_LIBS) \ - $(UUID_LIBS) \ - $(KMOD_LIBS) + $(UUID_LIBS) if ENABLE_TEST accel_config_SOURCES += ../test/libaccfg.c \
accfg/lib/Makefile.am +1 -2
@@ -24,8 +24,7 @@ libaccel_config_la_SOURCES =\ libaccel_config_la_LIBADD =\ $(UDEV_LIBS) \ - $(UUID_LIBS) \ - $(KMOD_LIBS) + $(UUID_LIBS) EXTRA_DIST += libaccel-config.sym
configure.ac +0 -1
@@ -97,7 +97,6 @@ AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = "xyes"]) PKG_CHECK_MODULES([UUID], [uuid], [AC_DEFINE([HAVE_UUID], [1], [Define to 1 if using libuuid])]) PKG_CHECK_MODULES([JSON], [json-c]) -PKG_CHECK_MODULES([KMOD], [libkmod]) PKG_CHECK_MODULES([UDEV], [libudev]) AC_ARG_WITH([bash-completion-dir],
debian/control +0 -1
@@ -11,7 +11,6 @@ Build-Depends: asciidoctor, debhelper-compat (= 12), libjson-c-dev, libkeyutils-dev, - libkmod-dev, libudev-dev, pkg-config, uuid-dev
test/Makefile.am +1 -1
@@ -31,7 +31,7 @@ testcore =\ accfg_test.h libaccfg_SOURCES = libaccfg.c $(testcore) -libaccfg_LDADD = $(LIBACCFG_LIB) $(UUID_LIBS) $(KMOD_LIBS) +libaccfg_LDADD = $(LIBACCFG_LIB) $(UUID_LIBS) dsa_test_SOURCES = dsa_test.c dsa.c prep.c dsa_test_LDADD = $(LIBACCFG_LIB) $(UUID_LIBS)
Signature · 1 line
2.26.3
Ramesh Thomas
PATCH 3/5 accel-config: Remove references to unused libudev
In reply to Ramesh ThomasFrom: Ramesh Thomas <ramesh.thomas(a)linux.intel.com>
Removing references to unused libudev to reduce redundant depencies in the build.
--- accfg/lib/private.h | 6 ------ 1 file changed, 6 deletions(-)
accfg/lib/private.h +0 -6
@@ -9,7 +9,6 @@#include <syslog.h> #include <string.h> #include <inttypes.h> -#include <libudev.h> #include <util/log.h> #include <uuid/uuid.h> #include <ccan/list/list.h>
@@ -160,9 +159,4 @@ struct accfg_ctx { struct accfg_error_ctx *error_ctx; }; -static inline int check_udev (struct udev *udev) -{ -return udev ?0 : -ENXIO ; -} -#endif /* _LIBACCFG_PRIVATE_H_ */
Signature · 1 line
2.26.3
Ramesh Thomas
PATCH 4/5 accel-config: Remove libkmod dependencies in build files
In reply to Ramesh ThomasFrom: Ramesh Thomas <ramesh.thomas(a)linux.intel.com>
Remove libkmod dependencies and references in build files and README
--- Makefile.am.in | 1 - README.md | 4 ++-- accfg-test.spec.in | 1 - accfg.spec.in | 1 - accfg/lib/Makefile.am | 1 - configure.ac | 1 - debian/control | 1 - 7 files changed, 2 insertions(+), 8 deletions(-)
Makefile.am.in +0 -1
@@ -12,7 +12,6 @@ AM_CPPFLAGS = \ -I${top_srcdir}/accfg/lib \ -I${top_srcdir}/accfg \ -I${top_srcdir}/ \ - $(UDEV_CFLAGS) \ $(UUID_CFLAGS) \ $(JSON_CFLAGS)
README.md +2 -2
@@ -9,13 +9,13 @@ sub-system in the Linux kernel ```bash yum groupinstall "Development Tools" yum install autoconf automake libtool pkgconf rpm-build rpmdevtools -yum install asciidoc xmlto libuuid-devel json-c-devel libudev-devel +yum install asciidoc xmlto libuuid-devel json-c-devel ``` ### Debian ```bash apt install build-essential apt install autoconf automake autotools-dev libtool pkgconf asciidoc xmlto -apt install uuid-dev libjson-c-dev libudev-dev libkeyutils-dev +apt install uuid-dev libjson-c-dev libkeyutils-dev apt install debhelper devscripts debmake quilt fakeroot lintian asciidoctor apt install file gnupg patch patchutils ```
accfg-test.spec.in +0 -1
@@ -15,7 +15,6 @@ BuildRequires: libtool BuildRequires: pkgconfig BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(json-c) -BuildRequires: pkgconfig(libudev) BuildRequires: systemd %description
accfg.spec.in +0 -1
@@ -15,7 +15,6 @@ BuildRequires: libtool BuildRequires: pkgconfig BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(json-c) -BuildRequires: pkgconfig(libudev) BuildRequires: systemd %description
accfg/lib/Makefile.am +0 -1
@@ -23,7 +23,6 @@ libaccel_config_la_SOURCES =\ libaccfg.c libaccel_config_la_LIBADD =\ - $(UDEV_LIBS) \ $(UUID_LIBS) EXTRA_DIST += libaccel-config.sym
configure.ac +0 -1
@@ -97,7 +97,6 @@ AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = "xyes"]) PKG_CHECK_MODULES([UUID], [uuid], [AC_DEFINE([HAVE_UUID], [1], [Define to 1 if using libuuid])]) PKG_CHECK_MODULES([JSON], [json-c]) -PKG_CHECK_MODULES([UDEV], [libudev]) AC_ARG_WITH([bash-completion-dir], AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
debian/control +0 -1
@@ -11,7 +11,6 @@ Build-Depends: asciidoctor, debhelper-compat (= 12), libjson-c-dev, libkeyutils-dev, - libudev-dev, pkg-config, uuid-dev
Signature · 1 line
2.26.3
Ramesh Thomas
PATCH 5/5 accel-config: Check for file existence instead of read permission
In reply to Ramesh ThomasFrom: Ramesh Thomas <ramesh.thomas(a)linux.intel.com>
Pass F_OK to access to check for existence of files instead of R_OK which checks for read permission. Even though it does not matter, F_OK is more relevant in the usage.
--- accfg/lib/libaccfg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
accfg/lib/libaccfg.c +2 -2
@@ -151,7 +151,7 @@ static void save_last_error(struct accfg_device *device, struct accfg_wq *wq,static inline bool is_mdev_registered (struct accfg_device *device) { -return device->mdev_path && !access (device->mdev_path,R_OK ); +return device->mdev_path && !access (device->mdev_path,F_OK ); } static int accfg_set_param(struct accfg_ctx *ctx, int dfd, char *name,
@@ -398,7 +398,7 @@ ACCFG_EXPORT int accfg_new(struct accfg_ctx **ctx) c->refcount =1 ;log_init (&c->ctx,"libaccfg" ,"ACCFG_LOG" ); c->timeout =5000 ; -if (access (IDXD_DRIVER_BIND_PATH ,R_OK )) +if (access (IDXD_DRIVER_BIND_PATH ,F_OK )) c->compat = true;list_head_init (&c->devices);
Signature · 1 line
2.26.3
Dave Jiang
Reviewed-by on the v1 seriesQuoted 14 lines · Ramesh Thomas
libkmod and libudev are not necessary and are removed in this patchset. Presence of idxd kernel module is validated and if not loaded, an error message is printed before exiting the app. Accel-config will not try to load the kernel modules. The asumption is that systems where accel-config is run will have the necessary kernel modules already installed.
Ramesh Thomas (5):
accel-config: Remove use of libkmod
accel-config: Remove libkmod dependencies in build files
accel-config: Remove references to unused libudev
accel-config: Remove libkmod dependencies in build files
accel-config: Check for file existence instead of read permission
Quoted 15 lines
Makefile.am.in | 2 -- README.md | 4 +-- accfg-test.spec.in | 2 -- accfg.spec.in | 2 -- accfg/Makefile.am | 3 +-- accfg/accel-config.c | 40 +++------------------------- accfg/lib/Makefile.am | 4 +-- accfg/lib/libaccfg.c | 4 +-- accfg/lib/private.h | 12 +-------- configure.ac | 2 -- debian/control | 2 -- test/Makefile.am | 2 +- test/core.c | 1 - test/libaccfg.c | 61 +++++++------------------------------------ 14 files changed, 21 insertions(+), 120 deletions(-)
LGTM