From: Boqun Feng <boqun.feng@gmail.com>
To: Sasha Levin <sashal@kernel.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Chris Wilson <chris@chris-wilson.co.uk>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH AUTOSEL 5.9 13/21] lockdep: Avoid to modify chain keys in validate_chain()
Date: Wed, 18 Nov 2020 09:26:34 +0800 [thread overview]
Message-ID: <20201118012634.GF286534@boqun-archlinux> (raw)
In-Reply-To: <20201117125652.599614-13-sashal@kernel.org>
Hi Sasha,
I don't think this commit should be picked by stable, since the problem
it fixes is caused by commit f611e8cf98ec ("lockdep: Take read/write
status in consideration when generate chainkey"), which just got merged
in the merge window of 5.10. So 5.9 and 5.4 don't have the problem.
Regards,
Boqun
On Tue, Nov 17, 2020 at 07:56:44AM -0500, Sasha Levin wrote:
> From: Boqun Feng <boqun.feng@gmail.com>
>
> [ Upstream commit d61fc96a37603384cd531622c1e89de1096b5123 ]
>
> Chris Wilson reported a problem spotted by check_chain_key(): a chain
> key got changed in validate_chain() because we modify the ->read in
> validate_chain() to skip checks for dependency adding, and ->read is
> taken into calculation for chain key since commit f611e8cf98ec
> ("lockdep: Take read/write status in consideration when generate
> chainkey").
>
> Fix this by avoiding to modify ->read in validate_chain() based on two
> facts: a) since we now support recursive read lock detection, there is
> no need to skip checks for dependency adding for recursive readers, b)
> since we have a), there is only one case left (nest_lock) where we want
> to skip checks in validate_chain(), we simply remove the modification
> for ->read and rely on the return value of check_deadlock() to skip the
> dependency adding.
>
> Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Link: https://lkml.kernel.org/r/20201102053743.450459-1-boqun.feng@gmail.com
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> kernel/locking/lockdep.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 3eb35ad1b5241..f3a4302a1251f 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -2421,7 +2421,9 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
> * (Note that this has to be done separately, because the graph cannot
> * detect such classes of deadlocks.)
> *
> - * Returns: 0 on deadlock detected, 1 on OK, 2 on recursive read
> + * Returns: 0 on deadlock detected, 1 on OK, 2 if another lock with the same
> + * lock class is held but nest_lock is also held, i.e. we rely on the
> + * nest_lock to avoid the deadlock.
> */
> static int
> check_deadlock(struct task_struct *curr, struct held_lock *next)
> @@ -2444,7 +2446,7 @@ check_deadlock(struct task_struct *curr, struct held_lock *next)
> * lock class (i.e. read_lock(lock)+read_lock(lock)):
> */
> if ((next->read == 2) && prev->read)
> - return 2;
> + continue;
>
> /*
> * We're holding the nest_lock, which serializes this lock's
> @@ -3227,16 +3229,13 @@ static int validate_chain(struct task_struct *curr,
>
> if (!ret)
> return 0;
> - /*
> - * Mark recursive read, as we jump over it when
> - * building dependencies (just like we jump over
> - * trylock entries):
> - */
> - if (ret == 2)
> - hlock->read = 2;
> /*
> * Add dependency only if this lock is not the head
> - * of the chain, and if it's not a secondary read-lock:
> + * of the chain, and if the new lock introduces no more
> + * lock dependency (because we already hold a lock with the
> + * same lock class) nor deadlock (because the nest_lock
> + * serializes nesting locks), see the comments for
> + * check_deadlock().
> */
> if (!chain_head && ret != 2) {
> if (!check_prevs_add(curr, hlock))
> --
> 2.27.0
>
next prev parent reply other threads:[~2020-11-18 1:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-17 12:56 [PATCH AUTOSEL 5.9 01/21] Revert "Revert "gpio: omap: Fix lost edge wake-up interrupts"" Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 02/21] tools, bpftool: Avoid array index warnings Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 03/21] habanalabs/gaudi: mask WDT error in QMAN Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 04/21] pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 05/21] scsi: ufs: Fix unbalanced scsi_block_reqs_cnt caused by ufshcd_hold() Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 06/21] scsi: ufs: Try to save power mode change and UIC cmd completion timeout Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 07/21] pinctrl: mcp23s08: Print error message when regmap init fails Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 08/21] selftests: kvm: Fix the segment descriptor layout to match the actual layout Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 09/21] ACPI: button: Add DMI quirk for Medion Akoya E2228T Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 10/21] arm64: errata: Fix handling of 1418040 with late CPU onlining Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 11/21] arm64: psci: Avoid printing in cpu_psci_cpu_die() Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 12/21] arm64: smp: Tell RCU about CPUs that fail to come online Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 13/21] lockdep: Avoid to modify chain keys in validate_chain() Sasha Levin
2020-11-18 1:26 ` Boqun Feng [this message]
2020-11-19 1:22 ` Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 14/21] um: Call pgtable_pmd_page_dtor() in __pmd_free_tlb() Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 15/21] vfs: remove lockdep bogosity in __sb_start_write Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 16/21] gfs2: fix possible reference leak in gfs2_check_blk_type Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 17/21] hwmon: (pwm-fan) Fix RPM calculation Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 18/21] gfs2: Fix case in which ail writes are done to jdata holes Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 19/21] arm64: Add MIDR value for KRYO2XX gold/silver CPU cores Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 20/21] arm64: kpti: Add KRYO2XX gold/silver CPU cores to kpti safelist Sasha Levin
2020-11-17 12:56 ` [PATCH AUTOSEL 5.9 21/21] arm64: cpu_errata: Apply Erratum 845719 to KRYO2XX Silver Sasha Levin
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=20201118012634.GF286534@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=chris@chris-wilson.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=sashal@kernel.org \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox