From patchwork Wed Mar 16 02:26:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 12782106 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CB05C433EF for ; Wed, 16 Mar 2022 02:27:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B8A18D0007; Tue, 15 Mar 2022 22:27:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D23F58D0010; Tue, 15 Mar 2022 22:27:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 902168D000E; Tue, 15 Mar 2022 22:27:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id A5E1B8D000A for ; Tue, 15 Mar 2022 22:27:14 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 7ECAE1208D9 for ; Wed, 16 Mar 2022 02:27:14 +0000 (UTC) X-FDA: 79248662388.15.871BE1D Received: from lgeamrelo11.lge.com (lgeamrelo12.lge.com [156.147.23.52]) by imf09.hostedemail.com (Postfix) with ESMTP id 6001014000B for ; Wed, 16 Mar 2022 02:27:13 +0000 (UTC) Received: from unknown (HELO lgemrelse7q.lge.com) (156.147.1.151) by 156.147.23.52 with ESMTP; 16 Mar 2022 11:27:12 +0900 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO localhost.localdomain) (10.177.244.38) by 156.147.1.151 with ESMTP; 16 Mar 2022 11:27:12 +0900 X-Original-SENDERIP: 10.177.244.38 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: torvalds@linux-foundation.org Cc: damien.lemoal@opensource.wdc.com, linux-ide@vger.kernel.org, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, mingo@redhat.com, linux-kernel@vger.kernel.org, peterz@infradead.org, will@kernel.org, tglx@linutronix.de, rostedt@goodmis.org, joel@joelfernandes.org, sashal@kernel.org, daniel.vetter@ffwll.ch, chris@chris-wilson.co.uk, duyuyang@gmail.com, johannes.berg@intel.com, tj@kernel.org, tytso@mit.edu, willy@infradead.org, david@fromorbit.com, amir73il@gmail.com, bfields@fieldses.org, gregkh@linuxfoundation.org, kernel-team@lge.com, linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@kernel.org, minchan@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com, sj@kernel.org, jglisse@redhat.com, dennis@kernel.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, vbabka@suse.cz, ngupta@vflare.org, linux-block@vger.kernel.org, paolo.valente@linaro.org, josef@toxicpanda.com, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, jack@suse.com, jlayton@kernel.org, dan.j.williams@intel.com, hch@infradead.org, djwong@kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, hamohammed.sa@gmail.com Subject: [PATCH RFC v5 21/21] dept: Don't create dependencies between different depths in any case Date: Wed, 16 Mar 2022 11:26:33 +0900 Message-Id: <1647397593-16747-22-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1647397593-16747-1-git-send-email-byungchul.park@lge.com> References: <1647397593-16747-1-git-send-email-byungchul.park@lge.com> X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 6001014000B Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of byungchul.park@lge.com designates 156.147.23.52 as permitted sender) smtp.mailfrom=byungchul.park@lge.com; dmarc=none X-Rspam-User: X-Stat-Signature: zuf4jkhndkzt3ckrqbn7m1rkns3ni37w X-HE-Tag: 1647397633-842566 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Dept already prevents creating dependencies between different depths of the class indicated by *_lock_nested() when the lock acquisitions happen consecutively. For example: lock A0 with depth lock_nested A1 with depth + 1 ... unlock A1 unlock A0 Dept does not create A0 -> A1 dependency in this case. However, once another class cut in, the code becomes problematic. When Dept tries to create real dependencies, it does not only create real ones but also wrong ones between different depths of the class. For example: lock A0 with depth lock B lock_nested A1 with depth + 1 ... unlock A1 unlock B unlock A0 Even in this case, Dept should not create A0 -> A1 dependency but it does. Let Dept not create wrong dependencies between different depths of the class in any case. Reported-by: 42.hyeyoo@gmail.com Signed-off-by: Byungchul Park --- kernel/dependency/dept.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c index 10801783..a2088685 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1458,14 +1458,7 @@ static void add_wait(struct dept_class *c, unsigned long ip, eh = dt->ecxt_held + i; if (eh->ecxt->class != c || eh->nest == ne) - break; - } - - for (; i >= 0; i--) { - struct dept_ecxt_held *eh; - - eh = dt->ecxt_held + i; - add_dep(eh->ecxt, w); + add_dep(eh->ecxt, w); } if (!wait_consumed(w) && !rich_stack) {