All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sedat Dilek <sedat.dilek@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Jiri Kosina <jikos@kernel.org>, Tejun Heo <tj@kernel.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>,
	Andy Lutomirski <luto@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	USB list <linux-usb@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] usbhid: Fix lockdep unannotated irqs-off warning
Date: Mon, 7 Mar 2016 18:18:09 +0100	[thread overview]
Message-ID: <CA+icZUXMeM8UhtVDfJNZ5iMRxXOb85ui76mAxN=gV0iazGKMZQ@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1603071106030.1611-100000@iolanthe.rowland.org>

On Mon, Mar 7, 2016 at 5:41 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Mon, 7 Mar 2016, Sedat Dilek wrote:
>
>> Hmm, we are there where I was looking at...
>>
>> Please, read the reply of Jiri [1], we did some tweaking.
>> With CONFIG_FTRACE=n and CONFIG_PROVE_LOCKING=n !
>
> Yes, Jiri was looking more or less at the right place but his
> conclusions were wrong.
>
>> *** Part one: ObjectDump of hid-core.o ***
>>
>> $ objdump -D drivers/hid/usbhid/hid-core.o | awk '/<[^>]*>:$/ { p=0; }
>> /<usbhid_close>:/ { p=1; } { if (p) print $0; }' >
>> ../objdump-D_hid-core_o_usbhid_close_$(uname -r).txt
>
> This reveals the problem, at last...
>
>> $ cat ../objdump-D_hid-core_o_usbhid_close_4.4.4-1-iniza-small.txt
>> 00000000000002e0 <usbhid_close>:
>>      2e0:       55                      push   %rbp
>>      2e1:       48 89 e5                mov    %rsp,%rbp
>>      2e4:       41 57                   push   %r15
>>      2e6:       41 56                   push   %r14
>>      2e8:       41 54                   push   %r12
>>      2ea:       53                      push   %rbx
>>      2eb:       49 89 ff                mov    %rdi,%r15
>>      2ee:       4d 8b b7 e8 1e 00 00    mov    0x1ee8(%r15),%r14
>>      2f5:       48 c7 c7 00 00 00 00    mov    $0x0,%rdi
>>      2fc:       31 f6                   xor    %esi,%esi
>>      2fe:       e8 00 00 00 00          callq  303 <usbhid_close+0x23>
>
> mutex_lock(&hid_open_mut);
>
>>      303:       49 8d 9e 88 28 00 00    lea    0x2888(%r14),%rbx
>>      30a:       48 89 df                mov    %rbx,%rdi
>>      30d:       e8 00 00 00 00          callq  312 <usbhid_close+0x32>
>
> spin_lock_irq(&usbhid->lock);
>
>>      312:       41 ff 8f e4 1d 00 00    decl   0x1de4(%r15)
>
> --hid->open
>
>>      319:       9c                      pushfq
>>      31a:       41 5c                   pop    %r12
>>      31c:       48 89 df                mov    %rbx,%rdi
>>      31f:       e8 00 00 00 00          callq  324 <usbhid_close+0x44>
>>      324:       41 54                   push   %r12
>>      326:       9d                      popfq
>
> spin_unlock_irq(&usbhid->lock); while attempting to preserve the Z
> flag.  The problem is that this code sequence will also preserve the
> Interrupt Flag!
>
>>      327:       75 23                   jne    34c <usbhid_close+0x6c>
>
> if (!--hid->open), testing the Z flag from the decl.
>
>>      329:       4c 89 f7                mov    %r14,%rdi
>>      32c:       e8 3f 00 00 00          callq  370 <hid_cancel_delayed_stuff>
>
> But now hid_cancel_delayed_stuff(usbhid) gets called with interrupts
> disabled.
>
> It's hard to call this a compiler bug, but perhaps it is -- I don't
> know how programmers are supposed to tell CLANG that a subroutine
> modifies the Interrupt Flag in a way that the compiler shouldn't mess
> up.
>

So, if Clang is producing wrong X86 code here, is it possible to turn
interrupts on/off manually?
But, hmm that affects other places as well in the Linux sources, so.

- Sedat -

  parent reply	other threads:[~2016-03-07 17:18 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07 15:59 [PATCH] usbhid: Fix lockdep unannotated irqs-off warning Sedat Dilek
2016-03-07 16:28 ` Sedat Dilek
2016-03-07 16:41 ` Alan Stern
2016-03-07 17:03   ` Steven Rostedt
2016-03-07 17:05   ` Jiri Kosina
2016-03-07 17:15     ` Sedat Dilek
2016-03-07 17:27       ` David Laight
2016-03-07 18:07         ` Alan Stern
2016-03-07 18:30           ` Linus Torvalds
2016-06-27 19:50             ` Sedat Dilek
2016-06-27 20:03               ` Sedat Dilek
2016-06-27 20:14               ` Linus Torvalds
2016-06-27 20:27                 ` Sedat Dilek
2016-06-27 20:36                   ` Linus Torvalds
2016-03-07 17:11   ` Steven Rostedt
2016-03-07 17:18   ` Sedat Dilek [this message]
2016-03-07 17:24     ` Jiri Kosina
2016-03-07 17:30       ` Steven Rostedt
2016-03-07 18:04         ` Andy Lutomirski
2016-03-07 19:10           ` Steven Rostedt
  -- strict thread matches above, loose matches on Subject: below --
2015-09-28  8:10 Sedat Dilek
2015-09-28 11:33 ` Jiri Kosina
2015-09-29  8:40   ` Sedat Dilek
2015-09-29  9:27     ` Jiri Kosina
2015-09-29 18:54       ` Sedat Dilek
2015-09-29 19:08         ` Steven Rostedt
2015-09-29 19:32           ` Sedat Dilek
     [not found]       ` <CA+icZUWH2vR_vpYu4hCS578U3ssmoiF0pLYUfM-Xo-57e8uN=g@mail.gmail.com>
2015-09-30  6:41         ` Sedat Dilek
2015-09-30  8:50           ` Steven Rostedt
2015-09-30  7:35         ` Jiri Kosina
2015-09-30  8:56           ` Steven Rostedt
2015-09-30  9:46             ` Sedat Dilek
2015-09-30 10:13               ` Steven Rostedt
2015-09-30 10:39                 ` Sedat Dilek
     [not found]                 ` <CA+icZUXSzScTmMgLZwPQq9RMH9cUsD5_iDxKTVuG0rrGqH-8Cw@mail.gmail.com>
2015-10-01  2:01                   ` Steven Rostedt
2015-10-01  5:34                     ` Sedat Dilek
2015-10-01  6:05                     ` Sedat Dilek
     [not found]                       ` <CA+icZUUyaHqHP2v52juhGhoTNS9xX7LT2YxkOppLz6f9Z+FBEA@mail.gmail.com>
     [not found]                         ` <CA+icZUWagGMVNs5gBPRBhYO0LsY2A1hK3KSLabp9ZpDVOTmtig@mail.gmail.com>
2015-10-13  0:57                           ` Steven Rostedt
2016-03-01 10:05                             ` Sedat Dilek
2016-03-01 15:07                               ` Steven Rostedt
2016-03-01 15:17                                 ` Peter Zijlstra
2016-03-02 15:00                                   ` Sedat Dilek
2016-03-02 15:17                                     ` Peter Zijlstra
2016-03-02 15:34                                       ` Sedat Dilek
2016-03-02 15:53                                       ` Sedat Dilek
2016-03-02 15:56                                         ` Steven Rostedt
2016-03-02 16:08                                           ` Sedat Dilek
2016-03-02 16:11                                             ` Sedat Dilek
2016-03-02 16:21                                               ` Sedat Dilek
2016-03-02 16:24                                         ` Peter Zijlstra
2016-03-02 16:35                                           ` Steven Rostedt
2016-03-02 16:42                                             ` Peter Zijlstra
2016-03-02 16:42                                           ` Sedat Dilek
2016-03-02 16:52                                             ` Sedat Dilek
2016-03-01 15:59                               ` Alan Stern
2016-03-02  6:25                                 ` Sedat Dilek
2016-03-04 16:04                                   ` Alan Stern
2016-03-05 22:30                                     ` Sedat Dilek
2016-03-06  8:51                                       ` Sedat Dilek
2016-03-06 17:23                                       ` Alan Stern
2016-03-02  6:36                                 ` Sedat Dilek
2016-03-02  8:34                                   ` Sedat Dilek
2016-03-02  8:37                                     ` Jiri Kosina
2016-03-02  9:11                                       ` Sedat Dilek
     [not found]     ` <CA+icZUX3tJvRor6CbOZFBecTAUZzyWzjLzJSEdb3c12yKRAT3g@mail.gmail.com>
2015-09-29 13:13       ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+icZUXMeM8UhtVDfJNZ5iMRxXOb85ui76mAxN=gV0iazGKMZQ@mail.gmail.com' \
    --to=sedat.dilek@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiangshanlai@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.