From 9083cdad756db8ea298c170f65f9f435d238b121 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 13 Aug 2015 19:57:47 +0200 Subject: [PATCH 1/8] genorig.py: Include kernel/locking in orig so we can build liblockdep --- debian/bin/genorig.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/bin/genorig.py b/debian/bin/genorig.py index 76a3b53d98ef..c1e8b70d103e 100755 --- a/debian/bin/genorig.py +++ b/debian/bin/genorig.py @@ -138,6 +138,7 @@ class Main(object): to_copy = ( 'COPYING', + 'Documentation/locking/lockdep-design.txt', 'Kbuild', 'Makefile', 'arch/*/include/', @@ -147,6 +148,7 @@ class Main(object): 'arch/x86/lib/memset_64.S', 'arch/x86/tools/', 'include/', + 'kernel/locking/', 'lib/hweight.c', 'lib/rbtree.c', 'scripts/', From 042546e3a12601034b99d0f4c52565989e03a0e1 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 13 Aug 2015 20:48:12 +0200 Subject: [PATCH 2/8] Add liblockdep packages liblockdep is in fairly bad shape - one patch needed to make it build at all, another to make it build in a separate directory successfully, and a third to fix the soname. And the install rule doesn't install its public headers. But maybe it will be useful. --- debian/build/tools/Makefile | 1 + debian/build/tools/lib/lockdep/Makefile | 26 +++++++++ debian/build/tools/lib/lockdep/lockdep.in | 2 + debian/liblockdep-dev.docs | 1 + debian/liblockdep-dev.install | 3 ++ debian/lockdep.install | 1 + debian/patches/lockdep-fix-headers.patch | 62 ++++++++++++++++++++++ debian/patches/lockdep-fix-oot-build.patch | 33 ++++++++++++ debian/patches/lockdep-fix-soname.patch | 11 ++++ debian/patches/series | 3 ++ debian/rules.real | 26 ++++++++- debian/templates/control.main.in | 25 +++++++++ 12 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 debian/build/tools/lib/lockdep/Makefile create mode 100644 debian/build/tools/lib/lockdep/lockdep.in create mode 100644 debian/liblockdep-dev.docs create mode 100644 debian/liblockdep-dev.install create mode 100644 debian/lockdep.install create mode 100644 debian/patches/lockdep-fix-headers.patch create mode 100644 debian/patches/lockdep-fix-oot-build.patch create mode 100644 debian/patches/lockdep-fix-soname.patch diff --git a/debian/build/tools/Makefile b/debian/build/tools/Makefile index 06bc266092f7..a3cdd8728b79 100644 --- a/debian/build/tools/Makefile +++ b/debian/build/tools/Makefile @@ -1,5 +1,6 @@ SUBDIRS = \ hv \ + lib/lockdep \ perf \ usb/usbip diff --git a/debian/build/tools/lib/lockdep/Makefile b/debian/build/tools/lib/lockdep/Makefile new file mode 100644 index 000000000000..7c8408ffc122 --- /dev/null +++ b/debian/build/tools/lib/lockdep/Makefile @@ -0,0 +1,26 @@ +srcdir := $(top_srcdir)/tools/lib/lockdep + +DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) + +MAKE_LOCKDEP := $(MAKE) -C $(srcdir) O=$(CURDIR)/out V=1 \ + prefix=/usr libdir_relative=lib/$(DEB_HOST_MULTIARCH) \ + LIBLOCKDEP_VERSION=$(VERSION) + +unexport CFLAGS + +all: + mkdir -p out + $(MAKE_LOCKDEP) + +install: + $(MAKE_LOCKDEP) install + mkdir -p $(DESTDIR)/usr/include + cp -R $(srcdir)/include/liblockdep $(DESTDIR)/usr/include/ + ln -s liblockdep.so.$(VERSION) \ + $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/liblockdep.so +# Upstream lockdep preload script is not suitable for installation + sed 's/@VERSION@/$(VERSION)/' lockdep.in > $(DESTDIR)/usr/bin/lockdep + chmod 755 $(DESTDIR)/usr/bin/lockdep + +clean: + rm -rf out diff --git a/debian/build/tools/lib/lockdep/lockdep.in b/debian/build/tools/lib/lockdep/lockdep.in new file mode 100644 index 000000000000..4a0d03ac5211 --- /dev/null +++ b/debian/build/tools/lib/lockdep/lockdep.in @@ -0,0 +1,2 @@ +#!/bin/sh +LD_PRELOAD="liblockdep.so.@VERSION@ $LD_PRELOAD" exec "$@" diff --git a/debian/liblockdep-dev.docs b/debian/liblockdep-dev.docs new file mode 100644 index 000000000000..15b2bbe123e5 --- /dev/null +++ b/debian/liblockdep-dev.docs @@ -0,0 +1 @@ +Documentation/locking/lockdep-design.txt diff --git a/debian/liblockdep-dev.install b/debian/liblockdep-dev.install new file mode 100644 index 000000000000..bd857244bef9 --- /dev/null +++ b/debian/liblockdep-dev.install @@ -0,0 +1,3 @@ +usr/include/liblockdep +usr/lib/*/liblockdep.a +usr/lib/*/liblockdep.so diff --git a/debian/lockdep.install b/debian/lockdep.install new file mode 100644 index 000000000000..236942003fc1 --- /dev/null +++ b/debian/lockdep.install @@ -0,0 +1 @@ +usr/bin/lockdep diff --git a/debian/patches/lockdep-fix-headers.patch b/debian/patches/lockdep-fix-headers.patch new file mode 100644 index 000000000000..c0e3ced12ea7 --- /dev/null +++ b/debian/patches/lockdep-fix-headers.patch @@ -0,0 +1,62 @@ +--- /dev/null ++++ b/tools/lib/lockdep/uinclude/linux/export.h +@@ -0,0 +1,10 @@ ++#ifndef _LINUX_EXPORT_H ++#define _LINUX_EXPORT_H ++ ++#define EXPORT_SYMBOL(sym) ++#define EXPORT_SYMBOL_GPL(sym) ++#define EXPORT_SYMBOL_GPL_FUTURE(sym) ++#define EXPORT_UNUSED_SYMBOL(sym) ++#define EXPORT_UNUSED_SYMBOL_GPL(sym) ++ ++#endif /* _LINUX_EXPORT_H */ +--- a/tools/lib/lockdep/uinclude/linux/kernel.h ++++ b/tools/lib/lockdep/uinclude/linux/kernel.h +@@ -23,7 +23,7 @@ + #define WARN_ON(x) (x) + #define WARN_ON_ONCE(x) (x) + #define likely(x) (x) +-#define WARN(x, y, z) (x) ++#define WARN(x, y...) (x) + #define uninitialized_var(x) x + #define __init + #define noinline +--- a/tools/lib/lockdep/preload.c ++++ b/tools/lib/lockdep/preload.c +@@ -5,7 +5,7 @@ + #include + #include + #include "include/liblockdep/mutex.h" +-#include "../../../include/linux/rbtree.h" ++#include + + /** + * struct lock_lookup - liblockdep's view of a single unique lock +--- a/tools/lib/lockdep/uinclude/linux/rbtree.h ++++ b/tools/lib/lockdep/uinclude/linux/rbtree.h +@@ -1 +1 @@ +-#include "../../../include/linux/rbtree.h" ++#include "../../include/linux/rbtree.h" +--- a/tools/lib/lockdep/uinclude/linux/compiler.h ++++ b/tools/lib/lockdep/uinclude/linux/compiler.h +@@ -4,4 +4,10 @@ + #define __used __attribute__((__unused__)) + #define unlikely + ++#define __ACCESS_ONCE(x) ({ \ ++ __attribute__((__unused__)) typeof(x) __var = (__force typeof(x)) 0; \ ++ (volatile typeof(x) *)&(x); }) ++#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x)) ++#define WRITE_ONCE(x, val) (ACCESS_ONCE(x) = (val)) ++ + #endif +--- a/tools/lib/lockdep/uinclude/linux/rcu.h ++++ b/tools/lib/lockdep/uinclude/linux/rcu.h +@@ -18,4 +18,6 @@ static inline bool rcu_is_watching(void) + return false; + } + ++#define RCU_INIT_POINTER(p, v) (p = v) ++ + #endif diff --git a/debian/patches/lockdep-fix-oot-build.patch b/debian/patches/lockdep-fix-oot-build.patch new file mode 100644 index 000000000000..20117433afad --- /dev/null +++ b/debian/patches/lockdep-fix-oot-build.patch @@ -0,0 +1,33 @@ +--- a/tools/lib/lockdep/Makefile ++++ b/tools/lib/lockdep/Makefile +@@ -98,7 +98,7 @@ build := -f $(srctree)/tools/build/Makef + + do_compile_shared_library = \ + ($(print_shared_lib_compile) \ +- $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='"$@"';$(shell ln -s $@ liblockdep.so)) ++ $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='"$(@F)"';$(shell ln -s $(@F) $(@D)/liblockdep.so)) + + do_build_static_lib = \ + ($(print_static_lib_build) \ +@@ -116,10 +116,10 @@ all_cmd: $(CMD_TARGETS) + $(LIB_IN): force + $(Q)$(MAKE) $(build)=liblockdep + +-liblockdep.so.$(LIBLOCKDEP_VERSION): $(LIB_IN) ++$(OUTPUT)liblockdep.so.$(LIBLOCKDEP_VERSION): $(LIB_IN) + $(Q)$(do_compile_shared_library) + +-liblockdep.a: $(LIB_IN) ++$(OUTPUT)liblockdep.a: $(LIB_IN) + $(Q)$(do_build_static_lib) + + tags: force +@@ -147,7 +147,7 @@ install_lib: all_cmd + install: install_lib + + clean: +- $(RM) *.o *~ $(TARGETS) *.a *liblockdep*.so* $(VERSION_FILES) .*.d ++ $(RM) $(OUTPUT)*.o *~ $(TARGETS) $(OUTPUT)*.a $(OUTPUT)*liblockdep*.so* $(VERSION_FILES) $(OUTPUT).*.d + $(RM) tags TAGS + + PHONY += force diff --git a/debian/patches/lockdep-fix-soname.patch b/debian/patches/lockdep-fix-soname.patch new file mode 100644 index 000000000000..dab83d6d19eb --- /dev/null +++ b/debian/patches/lockdep-fix-soname.patch @@ -0,0 +1,11 @@ +--- a/tools/lib/lockdep/Makefile ++++ b/tools/lib/lockdep/Makefile +@@ -98,7 +98,7 @@ build := -f $(srctree)/tools/build/Makef + + do_compile_shared_library = \ + ($(print_shared_lib_compile) \ +- $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='"$(@F)"';$(shell ln -s $(@F) $(@D)liblockdep.so)) ++ $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='$(@F)';$(shell ln -s $(@F) $(@D)/liblockdep.so)) + + do_build_static_lib = \ + ($(print_static_lib_build) \ diff --git a/debian/patches/series b/debian/patches/series index d2cc300b9667..e1943ce4213f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -7,3 +7,6 @@ kbuild-fix-recordmcount-dependency.patch usbip-include-uninstalled-linux-usbip-h.patch tools-perf-man-date.patch tools-perf-add-empty-build-files-for-architectures-lacking.patch +lockdep-fix-oot-build.patch +lockdep-fix-headers.patch +lockdep-fix-soname.patch diff --git a/debian/rules.real b/debian/rules.real index 3f2669fb1968..feaafa62f0d7 100644 --- a/debian/rules.real +++ b/debian/rules.real @@ -3,7 +3,7 @@ export KBUILD_BUILD_TIMESTAMP := $(shell dpkg-parsechangelog | sed -ne 's,^Date: include debian/rules.defs -binary-arch: install-kbuild install-usbip +binary-arch: install-kbuild install-usbip install-lockdep ifneq ($(filter alpha amd64 arm64 armel armhf hppa i386 mips mips64 mips64el mipsel powerpc powerpcspe ppc64 ppc64el s390 s390x sh4 sparc sparc64 x32,$(DEB_BUILD_ARCH)),) binary-arch: install-perf endif @@ -103,3 +103,27 @@ install-hyperv-daemons: $(STAMPS_DIR)/build dh_gencontrol dh_md5sums dh_builddeb + +install-lockdep: DH_OPTIONS = -plockdep -pliblockdep$(VERSION) -pliblockdep-dev +install-lockdep: DIR = $(CURDIR)/debian/tmp +install-lockdep: $(STAMPS_DIR)/build + dh_testdir + dh_testroot + dh_prep + $(MAKE) -C $(BUILD_DIR)/tools/lib/lockdep install top_srcdir=$(CURDIR) \ + DESTDIR=$(DIR) + env -u DH_OPTIONS dh_install -pliblockdep$(VERSION) \ + 'usr/lib/*/liblockdep.so.*' + dh_install + dh_installchangelogs + dh_installdocs + dh_strip + dh_compress + dh_fixperms + env -u DH_OPTIONS dh_makeshlibs -pliblockdep$(VERSION) \ + liblockdep$(VERSION) + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb diff --git a/debian/templates/control.main.in b/debian/templates/control.main.in index e76b88637f9e..cb88ca5d3f61 100644 --- a/debian/templates/control.main.in +++ b/debian/templates/control.main.in @@ -70,3 +70,28 @@ Description: Support daemons for Linux running on Hyper-V . hv_vss_daemon provides the volume shadow copy service (VSS), allowing the host to freeze the guest filesystems while taking a snapshot. + +Package: lockdep +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, liblockdep@version@ +Recommends: liblockdep-dev +Section: devel +Multi-Arch: allowed +Description: Runtime locking correctness validator + TBD + +Package: liblockdep@version@ +Architecture: linux-any +Depends: ${shlibs:Depends}, ${misc:Depends} +Section: libs +Multi-Arch: same +Description: Runtime locking correctness validator - shared library + TBD + +Package: liblockdep-dev +Architecture: linux-any +Depends: ${shlibs:Depends}, ${misc:Depends} +Section: libdevel +Multi-Arch: same +Description: Runtime locking correctness validator - development files + TBD From a0804637edfbb63340d8d59b0329f32d642c55bc Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 14 Aug 2015 14:25:33 +0200 Subject: [PATCH 3/8] Improve liblockdep documentation a little Add long descriptions for all liblockdep packages, and a README.Debian for liblockdep-dev which links to some articles about it. --- debian/liblockdep-dev.README.Debian | 13 +++++++++++++ debian/templates/control.main.in | 9 ++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 debian/liblockdep-dev.README.Debian diff --git a/debian/liblockdep-dev.README.Debian b/debian/liblockdep-dev.README.Debian new file mode 100644 index 000000000000..a0673a1707d7 --- /dev/null +++ b/debian/liblockdep-dev.README.Debian @@ -0,0 +1,13 @@ +liblockdep for Debian +--------------------- + +liblockdep does not have proper documentation, but these articles +provide an introduction: + + https://lwn.net/Articles/536363/ + http://www.vctlabs.com/posts/2014/Jul/09/liblockdep/ + +'lockdep-design.txt' explains some more detail about what lockdep +does, both in the kernel and as liblockdep. + + -- Ben Hutchings , Fri, 14 Aug 2015 14:22:55 +0200 diff --git a/debian/templates/control.main.in b/debian/templates/control.main.in index cb88ca5d3f61..a1fa00fbdb36 100644 --- a/debian/templates/control.main.in +++ b/debian/templates/control.main.in @@ -78,7 +78,8 @@ Recommends: liblockdep-dev Section: devel Multi-Arch: allowed Description: Runtime locking correctness validator - TBD + lockdep is a wrapper for programs that use the pthreads API, which detects + actual and potential deadlocks and other locking bugs. Package: liblockdep@version@ Architecture: linux-any @@ -86,7 +87,8 @@ Depends: ${shlibs:Depends}, ${misc:Depends} Section: libs Multi-Arch: same Description: Runtime locking correctness validator - shared library - TBD + liblockdep is a library for programs that use the pthreads API, which can + be used to detect actual and potential deadlocks and other locking bugs. Package: liblockdep-dev Architecture: linux-any @@ -94,4 +96,5 @@ Depends: ${shlibs:Depends}, ${misc:Depends} Section: libdevel Multi-Arch: same Description: Runtime locking correctness validator - development files - TBD + liblockdep is a library for programs that use the pthreads API, which can + be used to detect actual and potential deadlocks and other locking bugs. From f9ff7ea6b2e3600ac9d63bd11a36335041db5b86 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 14 Aug 2015 14:30:34 +0200 Subject: [PATCH 4/8] Refresh lockdep-fix-soname.patch to apply on top of lockdep-fix-oot-build.patch --- debian/patches/lockdep-fix-soname.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/patches/lockdep-fix-soname.patch b/debian/patches/lockdep-fix-soname.patch index dab83d6d19eb..0eea891b77db 100644 --- a/debian/patches/lockdep-fix-soname.patch +++ b/debian/patches/lockdep-fix-soname.patch @@ -4,7 +4,7 @@ do_compile_shared_library = \ ($(print_shared_lib_compile) \ -- $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='"$(@F)"';$(shell ln -s $(@F) $(@D)liblockdep.so)) +- $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='"$(@F)"';$(shell ln -s $(@F) $(@D)/liblockdep.so)) + $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='$(@F)';$(shell ln -s $(@F) $(@D)/liblockdep.so)) do_build_static_lib = \ From de56a162e478fec55010ddfe1e276f8a80629e13 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 14 Aug 2015 14:34:43 +0200 Subject: [PATCH 5/8] Add headers to liblockdep patches --- debian/patches/lockdep-fix-headers.patch | 6 ++++++ debian/patches/lockdep-fix-oot-build.patch | 6 ++++++ debian/patches/lockdep-fix-soname.patch | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/debian/patches/lockdep-fix-headers.patch b/debian/patches/lockdep-fix-headers.patch index c0e3ced12ea7..95f16161fcb5 100644 --- a/debian/patches/lockdep-fix-headers.patch +++ b/debian/patches/lockdep-fix-headers.patch @@ -1,3 +1,9 @@ +From: Ben Hutchings +Date: Thu, 13 Aug 2015 20:48:12 +0200 +Subject: liblockdep: Add more headers and definitions needed by lockdep + +Signed-off-by: Ben Hutchings +--- --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/export.h @@ -0,0 +1,10 @@ diff --git a/debian/patches/lockdep-fix-oot-build.patch b/debian/patches/lockdep-fix-oot-build.patch index 20117433afad..03bc43298fe1 100644 --- a/debian/patches/lockdep-fix-oot-build.patch +++ b/debian/patches/lockdep-fix-oot-build.patch @@ -1,3 +1,9 @@ +From: Ben Hutchings +Date: Thu, 13 Aug 2015 20:48:12 +0200 +Subject: liblockdep: Fix object file paths used in an out-of-tree build + +Signed-off-by: Ben Hutchings +--- --- a/tools/lib/lockdep/Makefile +++ b/tools/lib/lockdep/Makefile @@ -98,7 +98,7 @@ build := -f $(srctree)/tools/build/Makef diff --git a/debian/patches/lockdep-fix-soname.patch b/debian/patches/lockdep-fix-soname.patch index 0eea891b77db..a3ac90be902f 100644 --- a/debian/patches/lockdep-fix-soname.patch +++ b/debian/patches/lockdep-fix-soname.patch @@ -1,3 +1,9 @@ +From: Ben Hutchings +Date: Thu, 13 Aug 2015 20:48:12 +0200 +Subject: liblockdep: Remove double-quotes from soname + +Signed-off-by: Ben Hutchings +--- --- a/tools/lib/lockdep/Makefile +++ b/tools/lib/lockdep/Makefile @@ -98,7 +98,7 @@ build := -f $(srctree)/tools/build/Makef From aed0e372616955df9c051d35a50aa439cb96d5af Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 14 Aug 2015 14:39:23 +0200 Subject: [PATCH 6/8] Add liblockdep package build directories to .gitignore --- debian/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/.gitignore b/debian/.gitignore index e94573978eb8..c5589b51b81e 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -11,9 +11,11 @@ /control.md5sum /files /hyperv-daemons/ +/liblockdep*/ /libusbip-dev/ /linux-kbuild-* /linux-perf-* +/lockdep/ /rules.gen /stamps/ /tmp/ From 0c37eee43787f8f711460838271e57eb6a7768a8 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 14 Aug 2015 14:47:02 +0200 Subject: [PATCH 7/8] Note liblockdep packages in changelog --- debian/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/changelog b/debian/changelog index 72b2d00cd9b8..c2a0fdee7aca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ linux-tools (4.2~rc6-1~exp1) UNRELEASED; urgency=medium - Update .gitignore files - debian/control: Update Vcs-* fields - debian/rules: Exclude .git from maintainerclean rule + * Add packages of liblockdep (lockdep, liblockdep, liblockdep-dev) -- Ben Hutchings Tue, 11 Aug 2015 18:56:56 +0200 From bf2ec125301428e88f7fb80eb70b859d57505b4c Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 14 Aug 2015 14:58:37 +0200 Subject: [PATCH 8/8] Change liblockdep short descriptions to be consistent with libusbip --- debian/templates/control.main.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/templates/control.main.in b/debian/templates/control.main.in index a1fa00fbdb36..75ff67258213 100644 --- a/debian/templates/control.main.in +++ b/debian/templates/control.main.in @@ -86,7 +86,7 @@ Architecture: linux-any Depends: ${shlibs:Depends}, ${misc:Depends} Section: libs Multi-Arch: same -Description: Runtime locking correctness validator - shared library +Description: Runtime locking correctness validator (shared library) liblockdep is a library for programs that use the pthreads API, which can be used to detect actual and potential deadlocks and other locking bugs. @@ -95,6 +95,6 @@ Architecture: linux-any Depends: ${shlibs:Depends}, ${misc:Depends} Section: libdevel Multi-Arch: same -Description: Runtime locking correctness validator - development files +Description: Runtime locking correctness validator (development files) liblockdep is a library for programs that use the pthreads API, which can be used to detect actual and potential deadlocks and other locking bugs.