Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758386AbbDWWYU (ORCPT ); Thu, 23 Apr 2015 18:24:20 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:48986 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbbDWWYS (ORCPT ); Thu, 23 Apr 2015 18:24:18 -0400 X-AuditID: cbfee691-f79ca6d00000456a-bc-553971108512 Date: Thu, 23 Apr 2015 22:24:16 +0000 (GMT) From: Eunbong Song Subject: Re: Re: [PATCH] tools/liblockdep: change current_obj from thread-local storage to non thread-local storage To: Sasha Levin Cc: "linux-kernel@vger.kernel.org" Reply-to: eunb.song@samsung.com MIME-version: 1.0 X-MTR: 20150423222205258@eunb.song Msgkey: 20150423222205258@eunb.song X-EPLocale: ko_KR.euc-kr X-Priority: 3 X-EPWebmail-Msg-Type: personal X-EPWebmail-Reply-Demand: 0 X-EPApproval-Locale: X-EPHeader: ML X-MLAttribute: X-RootMTR: 20150423222205258@eunb.song X-ParentMTR: X-ArchiveUser: X-CPGSPASS: N X-ConfirmMail: N,general Content-type: text/plain; charset=euc-kr MIME-version: 1.0 Message-id: <1956408958.3291429827856252.JavaMail.weblogic@ep2mlwas05c> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKIsWRmVeSWpSXmKPExsVy+t8zbV2BQstQg7UPzC0u75rD5sDo8XmT XABjFJdNSmpOZllqkb5dAlfGo0PX2AoOqFVcO3iFtYFxj2oXIyeHkICKRMv/74wgtoSAicSl +6/YIGwxiQv31gPZXEA1yxglds56yNTFyAFWtPqeOUR8DqPEqYMPmEEaWARUJVa8bgYbxCag LfHjwFWwuLBAscSjjRvZQWwRAS2Jx8vugdUwCzhKPLp8hxniCHmJyacvg9XwCghKnJz5hAXi CCWJBROuMULElSV6rzZCHSohMWv6BVYIm1diRvtTqHo5iWlf1zBD2NIS52dtYIR5ZvH3x1Bx foljt3cwQdgCElPPHISqUZe4d/stl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ZSNqR1SxgZFnFKJpakFxQnJReYaxXnJhbXJqXrpecn7uJEZyKni3ewfj/vPUhRgEORiUe 3o9FFqFCrIllxZW5hxglOJiVRHgX5FqGCvGmJFZWpRblxxeV5qQWH2I0BcbaRGYp0eR8YJrM K4k3NDYwNjS0NDcwNTSyUBLn/X8uN0RIID2xJDU7NbUgtQimj4mDU6qBsf5H09UP9TnZq77y x84STP5r1r7Q0bbnw8LKzOUbDi9SzTu9OlnL3/X6tg+FsXenXYvycrl5Zl7lrE5+z9B9vYz3 vzoeV7gR4rJQ9vnn5v7jminPfh6LiXOJvXEnwiybPWyW22nffQ0Zvi29fvti3jnu2iLwcGWV vknKzQmnPr3NUCh3Mm8sUGIpzkg01GIuKk4EAApuzfpbAwAA DLP-Filter: Pass X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id t3NMOT6l030109 Content-Length: 3629 Lines: 127 > On 04/23/2015 02:55 AM, Eunbong Song wrote: >> current_obj is declared as a thread-local storage. >> This prevent to detect locking problem between multiple threads because >> each thread has it's own current_obj. liblockdep can only detect locking problem in a single >> thread. However, pthread_mutex_xxx, pthread_rwlock_xxx functions are mainly used for synchro >> nization of data between multiple threads. >> This patch changes current_obj to non thread-local storage. and current_obj.pid is getting >> from getpid system call. > um... It always worked with threads: I am sorry for confusing you. I did some mistake with my test. Thanks for your reply. > $ cat tests/ABBA_threads.c > #include > #include "common.h" > pthread_mutex_t a, b; > void *thread_a(void *arg) > { > LOCK_UNLOCK_2(a, b); > return NULL; > } void *thread_b(void *arg) { LOCK_UNLOCK_2(b, a); return NULL; } void main(void) { pthread_t ta, tb; pthread_mutex_init(&a, NULL); pthread_mutex_init(&b, NULL); pthread_create(&ta, NULL, thread_a, NULL); pthread_create(&tb, NULL, thread_b, NULL); pthread_join(ta, NULL); pthread_join(tb, NULL); } $ tests/ABBA_threads ====================================================== [ INFO: possible circular locking dependency detected ] liblockdep 4.0.0 ------------------------------------------------------- ABBA_threads/12101 is trying to acquire lock: (0x10bb700){......}, at: tests/ABBA_threads() [0x401333] but task is already holding lock: (0x10bb680){......}, at: tests/ABBA_threads() [0x401333] which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (0x10bb680){......}: tests/ABBA_threads[0x4019d3] tests/ABBA_threads[0x4036f6] tests/ABBA_threads[0x4039c2] tests/ABBA_threads[0x403fde] tests/ABBA_threads[0x404aa7] tests/ABBA_threads[0x405250] tests/ABBA_threads[0x4053d3] tests/ABBA_threads[0x4055cd] tests/ABBA_threads[0x40135d] tests/ABBA_threads[0x401395] /lib/x86_64-linux-gnu/libpthread.so.0(+0x80a5)[0x7f8e6e1dc0a5] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f8e6df09cfd] -> #0 (0x10bb700){......}: tests/ABBA_threads[0x4019d3] tests/ABBA_threads[0x402f51] tests/ABBA_threads[0x4035c4] tests/ABBA_threads[0x4039c2] tests/ABBA_threads[0x403fde] tests/ABBA_threads[0x404aa7] tests/ABBA_threads[0x405565] tests/ABBA_threads(pthread_mutex_lock+0x51)[0x4063fd] tests/ABBA_threads[0x401333] tests/ABBA_threads[0x4013c6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x80a5)[0x7f8e6e1dc0a5] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f8e6df09cfd] other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(0x10bb680); lock(0x10bb700); lock(0x10bb680); lock(0x10bb700); *** DEADLOCK *** 2 locks held by ABBA_threads/12101: #0: (&b){......}, at: tests/ABBA_threads() [0x4013bc] #1: (0x10bb680){......}, at: tests/ABBA_threads() [0x401333] stack backtrace: tests/ABBA_threads[0x4016dd] tests/ABBA_threads[0x40300b] tests/ABBA_threads[0x4035c4] tests/ABBA_threads[0x4039c2] tests/ABBA_threads[0x403fde] tests/ABBA_threads[0x404aa7] tests/ABBA_threads[0x405565] tests/ABBA_threads(pthread_mutex_lock+0x51)[0x4063fd] tests/ABBA_threads[0x401333] tests/ABBA_threads[0x4013c6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x80a5)[0x7f8e6e1dc0a5] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f8e6df09cfd] Thanks, Sasha????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?