linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fixing the compilation errors for liblockdep
@ 2016-06-09 13:34 Vishal Thanki
  2016-06-09 13:34 ` [PATCH 1/2] liblockdep: Fix compile errors Vishal Thanki
  2016-06-09 13:34 ` [PATCH 2/2] liblockdep: Remove -lpthread compiler option Vishal Thanki
  0 siblings, 2 replies; 7+ messages in thread
From: Vishal Thanki @ 2016-06-09 13:34 UTC (permalink / raw)
  To: sasha.levin, linux-kernel; +Cc: Vishal Thanki

The patch tries to fix the compilation errors in liblockdep which were
introduced due to recent changes in kernel. I am not familiar with the internal
working of lockdep, so please suggest if I have done anything wrong while
fixing liblockdep errors.

Vishal Thanki (2):
  liblockdep: Fix compile errors
  liblockdep: Remove -lpthread compiler option

 tools/lib/lockdep/lockdep.c                |  2 +-
 tools/lib/lockdep/run_tests.sh             |  4 ++--
 tools/lib/lockdep/uinclude/linux/jhash.h   | 20 ++++++++++++++++++++
 tools/lib/lockdep/uinclude/linux/kernel.h  |  1 +
 tools/lib/lockdep/uinclude/linux/lockdep.h |  2 +-
 5 files changed, 25 insertions(+), 4 deletions(-)
 create mode 100644 tools/lib/lockdep/uinclude/linux/jhash.h

-- 
2.4.11

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] liblockdep: Fix compile errors
  2016-06-09 13:34 [PATCH 0/2] Fixing the compilation errors for liblockdep Vishal Thanki
@ 2016-06-09 13:34 ` Vishal Thanki
  2016-06-11  3:53   ` Sasha Levin
  2016-06-09 13:34 ` [PATCH 2/2] liblockdep: Remove -lpthread compiler option Vishal Thanki
  1 sibling, 1 reply; 7+ messages in thread
From: Vishal Thanki @ 2016-06-09 13:34 UTC (permalink / raw)
  To: sasha.levin, linux-kernel; +Cc: Vishal Thanki

Following commit caused failures.

dfaaf3fa0: (Use __jhash_mix() for iterate_chain_key())
Fixed by adding jhash.h with minimal stuff required

75dd602a5: (lockdep: Fix lock_chain::base size)
Fixed by adding ARRAY_SIZE macro definition and
changing the MAX_LOCK_DEPTH value to similar defined
in linux/sched.h

Signed-off-by: Vishal Thanki <vishalthanki@gmail.com>
---
 tools/lib/lockdep/lockdep.c                |  2 +-
 tools/lib/lockdep/uinclude/linux/jhash.h   | 20 ++++++++++++++++++++
 tools/lib/lockdep/uinclude/linux/kernel.h  |  1 +
 tools/lib/lockdep/uinclude/linux/lockdep.h |  2 +-
 4 files changed, 23 insertions(+), 2 deletions(-)
 create mode 100644 tools/lib/lockdep/uinclude/linux/jhash.h

diff --git a/tools/lib/lockdep/lockdep.c b/tools/lib/lockdep/lockdep.c
index a0a2e3a..1ba6f33 100644
--- a/tools/lib/lockdep/lockdep.c
+++ b/tools/lib/lockdep/lockdep.c
@@ -4,5 +4,5 @@
 #define hlist_for_each_entry_rcu	hlist_for_each_entry
 #define hlist_add_head_rcu		hlist_add_head
 #define hlist_del_rcu			hlist_del
-
+#define prandom_u32			rand
 #include "../../../kernel/locking/lockdep.c"
diff --git a/tools/lib/lockdep/uinclude/linux/jhash.h b/tools/lib/lockdep/uinclude/linux/jhash.h
new file mode 100644
index 0000000..5c40bd1
--- /dev/null
+++ b/tools/lib/lockdep/uinclude/linux/jhash.h
@@ -0,0 +1,20 @@
+#ifndef _LINUX_JHASH_H
+#define _LINUX_JHASH_H
+
+static inline __u32 rol32(__u32 word, unsigned int shift)
+{
+	return (word << shift) | (word >> ((-shift) & 31));
+}
+
+/* __jhash_mix -- mix 3 32-bit values reversibly. */
+#define __jhash_mix(a, b, c)			\
+{						\
+	a -= c;  a ^= rol32(c, 4);  c += b;	\
+	b -= a;  b ^= rol32(a, 6);  a += c;	\
+	c -= b;  c ^= rol32(b, 8);  b += a;	\
+	a -= c;  a ^= rol32(c, 16); c += b;	\
+	b -= a;  b ^= rol32(a, 19); a += c;	\
+	c -= b;  c ^= rol32(b, 4);  b += a;	\
+}
+
+#endif /* _LINUX_JHASH_H */
diff --git a/tools/lib/lockdep/uinclude/linux/kernel.h b/tools/lib/lockdep/uinclude/linux/kernel.h
index 276c7a8..ab204c8 100644
--- a/tools/lib/lockdep/uinclude/linux/kernel.h
+++ b/tools/lib/lockdep/uinclude/linux/kernel.h
@@ -44,4 +44,5 @@
 #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
 #endif
 
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 #endif
diff --git a/tools/lib/lockdep/uinclude/linux/lockdep.h b/tools/lib/lockdep/uinclude/linux/lockdep.h
index c808c7d..8f6e725 100644
--- a/tools/lib/lockdep/uinclude/linux/lockdep.h
+++ b/tools/lib/lockdep/uinclude/linux/lockdep.h
@@ -8,7 +8,7 @@
 #include <linux/utsname.h>
 #include <linux/compiler.h>
 
-#define MAX_LOCK_DEPTH 2000UL
+#define MAX_LOCK_DEPTH 48UL
 
 #define asmlinkage
 #define __visible
-- 
2.4.11

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] liblockdep: Remove -lpthread compiler option
  2016-06-09 13:34 [PATCH 0/2] Fixing the compilation errors for liblockdep Vishal Thanki
  2016-06-09 13:34 ` [PATCH 1/2] liblockdep: Fix compile errors Vishal Thanki
@ 2016-06-09 13:34 ` Vishal Thanki
  1 sibling, 0 replies; 7+ messages in thread
From: Vishal Thanki @ 2016-06-09 13:34 UTC (permalink / raw)
  To: sasha.levin, linux-kernel; +Cc: Vishal Thanki

With -lpthread option, the test for ABBA_2threads was
failing, and test passed if it was removed.
Since -pthread compiler option is sufficient for linking
to pthread libraries, this patch removes -lpthread.

Signed-off-by: Vishal Thanki <vishalthanki@gmail.com>
---
 tools/lib/lockdep/run_tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/lockdep/run_tests.sh b/tools/lib/lockdep/run_tests.sh
index 1069d96..3fd297b 100755
--- a/tools/lib/lockdep/run_tests.sh
+++ b/tools/lib/lockdep/run_tests.sh
@@ -4,7 +4,7 @@ make &> /dev/null
 
 for i in `ls tests/*.c`; do
 	testname=$(basename "$i" .c)
-	gcc -o tests/$testname -pthread -lpthread $i liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &> /dev/null
+	gcc -o tests/$testname -pthread $i liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &> /dev/null
 	echo -ne "$testname... "
 	if [ $(timeout 1 ./tests/$testname | wc -l) -gt 0 ]; then
 		echo "PASSED!"
@@ -18,7 +18,7 @@ done
 
 for i in `ls tests/*.c`; do
 	testname=$(basename "$i" .c)
-	gcc -o tests/$testname -pthread -lpthread -Iinclude $i &> /dev/null
+	gcc -o tests/$testname -pthread -Iinclude $i &> /dev/null
 	echo -ne "(PRELOAD) $testname... "
 	if [ $(timeout 1 ./lockdep ./tests/$testname | wc -l) -gt 0 ]; then
 		echo "PASSED!"
-- 
2.4.11

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] liblockdep: Fix compile errors
  2016-06-09 13:34 ` [PATCH 1/2] liblockdep: Fix compile errors Vishal Thanki
@ 2016-06-11  3:53   ` Sasha Levin
  2016-06-11  8:36     ` Vishal Thanki
  0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2016-06-11  3:53 UTC (permalink / raw)
  To: Vishal Thanki, linux-kernel

On 06/09/2016 09:34 AM, Vishal Thanki wrote:
> dfaaf3fa0: (Use __jhash_mix() for iterate_chain_key())
> Fixed by adding jhash.h with minimal stuff required

Can we, instead of copying it over, include jhash.h directly
(just like we do for hash.h)?


Thanks,
Sasha

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] liblockdep: Fix compile errors
  2016-06-11  3:53   ` Sasha Levin
@ 2016-06-11  8:36     ` Vishal Thanki
  2016-06-13 20:38       ` Sasha Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Vishal Thanki @ 2016-06-11  8:36 UTC (permalink / raw)
  To: Sasha Levin; +Cc: linux-kernel

On Sat, Jun 11, 2016 at 5:53 AM, Sasha Levin <sasha.levin@oracle.com> wrote:
> On 06/09/2016 09:34 AM, Vishal Thanki wrote:
>> dfaaf3fa0: (Use __jhash_mix() for iterate_chain_key())
>> Fixed by adding jhash.h with minimal stuff required
>
> Can we, instead of copying it over, include jhash.h directly
> (just like we do for hash.h)?
>
>
That was the first thing I tried, but then it caused more compilation
errors due to nested header dependencies and I ended up taking the
only required stuff. Better ideas are welcome.

Thanks,
Vishal

> Thanks,
> Sasha

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] liblockdep: Fix compile errors
  2016-06-11  8:36     ` Vishal Thanki
@ 2016-06-13 20:38       ` Sasha Levin
  2016-06-14 10:26         ` Vishal Thanki
  0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2016-06-13 20:38 UTC (permalink / raw)
  To: Vishal Thanki; +Cc: linux-kernel

On 06/11/2016 04:36 AM, Vishal Thanki wrote:
> On Sat, Jun 11, 2016 at 5:53 AM, Sasha Levin <sasha.levin@oracle.com> wrote:
>> On 06/09/2016 09:34 AM, Vishal Thanki wrote:
>>> dfaaf3fa0: (Use __jhash_mix() for iterate_chain_key())
>>> Fixed by adding jhash.h with minimal stuff required
>>
>> Can we, instead of copying it over, include jhash.h directly
>> (just like we do for hash.h)?
>>
>>
> That was the first thing I tried, but then it caused more compilation
> errors due to nested header dependencies and I ended up taking the
> only required stuff. Better ideas are welcome.

I just gave it a quick go and didn't see anything beyond needing to take
in linux/unaligned/packed_struct.h as well. What sort of errors did you
hit?


Thanks,
Sasha

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] liblockdep: Fix compile errors
  2016-06-13 20:38       ` Sasha Levin
@ 2016-06-14 10:26         ` Vishal Thanki
  0 siblings, 0 replies; 7+ messages in thread
From: Vishal Thanki @ 2016-06-14 10:26 UTC (permalink / raw)
  To: Sasha Levin; +Cc: linux-kernel

On Mon, Jun 13, 2016 at 04:38:01PM -0400, Sasha Levin wrote:
> On 06/11/2016 04:36 AM, Vishal Thanki wrote:
> > On Sat, Jun 11, 2016 at 5:53 AM, Sasha Levin <sasha.levin@oracle.com> wrote:
> >> On 06/09/2016 09:34 AM, Vishal Thanki wrote:
> >>> dfaaf3fa0: (Use __jhash_mix() for iterate_chain_key())
> >>> Fixed by adding jhash.h with minimal stuff required
> >>
> >> Can we, instead of copying it over, include jhash.h directly
> >> (just like we do for hash.h)?
> >>
> >>
> > That was the first thing I tried, but then it caused more compilation
> > errors due to nested header dependencies and I ended up taking the
> > only required stuff. Better ideas are welcome.
> 
> I just gave it a quick go and didn't see anything beyond needing to take
> in linux/unaligned/packed_struct.h as well. What sort of errors did you
> hit?
> 

Yes, you are right about just adding the linux/unaligned/packed_struct.h should
work. However I hit the following errors when I did that:


CC       lockdep.o
In file included from ./uinclude/linux/jhash.h:27:0,
                 from ../../../kernel/locking/lockdep.c:49,
                 from lockdep.c:8:
./uinclude/linux/unaligned/packed_struct.h:7:29: error: conflicting types for
‘__packed’
 struct __una_u32 { u32 x; } __packed;
                             ^
./uinclude/linux/unaligned/packed_struct.h:6:29: note: previous declaration of
‘__packed’ was here
 struct __una_u16 { u16 x; } __packed;
                             ^
./uinclude/linux/unaligned/packed_struct.h:8:29: error: conflicting types for
‘__packed’
 struct __una_u64 { u64 x; } __packed;
                             ^
./uinclude/linux/unaligned/packed_struct.h:6:29: note: previous declaration of
‘__packed’ was here
 struct __una_u16 { u16 x; } __packed;
                             ^
which I overlooked and had nothing to do with header dependencies, pardon my
ignorance.

I think gcc on my machine (version 5.3.1 on Fedora 22) throws the above error
which I think can be fixed by adding a define in uinclude/linux/compile.h like
following:

#define __packed       __attribute__((__packed__))

After fixing, I hit following warning:

In file included from ../../../kernel/locking/lockdep.c:49:0,
                 from lockdep.c:8:
./uinclude/linux/jhash.h: In function ‘jhash’:
./uinclude/linux/jhash.h:37:16: warning: implicit declaration of function
‘rol32’ [-Wimplicit-function-declaration]
  a -= c;  a ^= rol32(c, 4);  c += b; \

which can be fixed by adding the inline definition of rol32 from kernel's
biopts.h file to uinclude/linux/bitops.h file (which is empty as of now).

I will rework the patch with the fixes and send again.

Thanks,
Vishal

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-06-14 10:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-09 13:34 [PATCH 0/2] Fixing the compilation errors for liblockdep Vishal Thanki
2016-06-09 13:34 ` [PATCH 1/2] liblockdep: Fix compile errors Vishal Thanki
2016-06-11  3:53   ` Sasha Levin
2016-06-11  8:36     ` Vishal Thanki
2016-06-13 20:38       ` Sasha Levin
2016-06-14 10:26         ` Vishal Thanki
2016-06-09 13:34 ` [PATCH 2/2] liblockdep: Remove -lpthread compiler option Vishal Thanki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).