Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1570841

Re: Q: lockdep_assert_held_read() after downgrade_write()

From "J. R. Okajima" <hooanon05g@gmail.com>
Newsgroups linux.kernel
Subject Re: Q: lockdep_assert_held_read() after downgrade_write()
Date 2017-01-31 16:50 +0100
Message-ID <t5IQW-2qi-23@gated-at.bofh.it> (permalink)
References <t5rGq-Ac-35@gated-at.bofh.it> <t5EtZ-8qc-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Jens Axboe:
> I don't think you understand how it works. downgrade_write() turns a write
> lock into read held. To make that last sequence valid, you'd need:
>
> 	down_write(&rw);
> 	downgrade_write(&rw);
> 	lockdep_assert_held_read(&rw)
> 	up_read(&rw);
>
> or just not drop up_write() from the last section.

Arg...
It is my bonehead mistake that I inserted up_write() before
downgrade_write(). Sorry about that.
Fortunately Peter Zijlstra reviewed downgrade_write() and sent a
patch. Thank you, it passed my first test.

Now allow me going on the second test (based upon Peter's patch)

- two rwsem, rwA and rwB.
- the locking order is rwA first, and then rwB.
- good case
  down_read(rwA)
  down_read(rwB)
  up_read(rwB)
  up_read(rwA)

  down_write(rwA)
  down_write(rwB)
  up_write(rwB)
  up_write(rwA)

- questionable case
  down_write(rwA)
  down_write(rwB)
  downgrade_write(rwA)
  downgrade_write(rwB)
  up_read(rwB)
  up_read(rwA)

These two downgrade_write() have their strict order? If so, what is
that?
Do the added two lines
+	rwsem_release(&sem->dep_map, 1, _RET_IP_);
+	rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_);
produce a traditional AB-BA deadlock warning, don't they?


J. R. Okajima

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Q: lockdep_assert_held_read() after downgrade_write() "J. R. Okajima" <hooanon05g@gmail.com> - 2017-01-30 22:30 +0100
  Re: Q: lockdep_assert_held_read() after downgrade_write() Peter Zijlstra <peterz@infradead.org> - 2017-01-31 12:10 +0100
    Re: Q: lockdep_assert_held_read() after downgrade_write() Peter Zijlstra <peterz@infradead.org> - 2017-01-31 15:00 +0100
      Re: Q: lockdep_assert_held_read() after downgrade_write() Waiman Long <longman@redhat.com> - 2017-01-31 15:30 +0100
        Re: Q: lockdep_assert_held_read() after downgrade_write() Peter Zijlstra <peterz@infradead.org> - 2017-01-31 15:30 +0100
  Re: Q: lockdep_assert_held_read() after downgrade_write() "J. R. Okajima" <hooanon05g@gmail.com> - 2017-01-31 16:50 +0100
    Re: Q: lockdep_assert_held_read() after downgrade_write() Peter Zijlstra <peterz@infradead.org> - 2017-01-31 18:00 +0100
      Re: Q: lockdep_assert_held_read() after downgrade_write() "J. R. Okajima" <hooanon05g@gmail.com> - 2017-02-02 17:40 +0100
      [PATCH 1/3] lockdep: consolidate by new find_held_lock() "J. R. Okajima" <hooanon05g@gmail.com> - 2017-02-02 17:50 +0100
        [PATCH 3/3] lockdep: new annotation lock_downgrade() "J. R. Okajima" <hooanon05g@gmail.com> - 2017-02-02 17:50 +0100
          Re: [PATCH 3/3] lockdep: new annotation lock_downgrade() kbuild test robot <lkp@intel.com> - 2017-02-02 19:10 +0100
            Re: [PATCH 3/3] lockdep: new annotation lock_downgrade() Peter Zijlstra <peterz@infradead.org> - 2017-02-02 19:50 +0100
              Re: [PATCH 3/3] lockdep: new annotation lock_downgrade() "J. R. Okajima" <hooanon05g@gmail.com> - 2017-02-02 22:10 +0100
        [PATCH 2/3] lockdep: consolidate by new validate_held_lock() "J. R. Okajima" <hooanon05g@gmail.com> - 2017-02-02 17:50 +0100

csiph-web