From patchwork Fri Mar 4 07:06:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 12768615 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECA3AC433EF for ; Fri, 4 Mar 2022 07:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238782AbiCDHJG (ORCPT ); Fri, 4 Mar 2022 02:09:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238785AbiCDHIw (ORCPT ); Fri, 4 Mar 2022 02:08:52 -0500 Received: from lgeamrelo11.lge.com (lgeamrelo11.lge.com [156.147.23.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 025D0192CB2 for ; Thu, 3 Mar 2022 23:07:14 -0800 (PST) Received: from unknown (HELO lgemrelse6q.lge.com) (156.147.1.121) by 156.147.23.51 with ESMTP; 4 Mar 2022 16:07:09 +0900 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO localhost.localdomain) (10.177.244.38) by 156.147.1.121 with ESMTP; 4 Mar 2022 16:07:09 +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 v4 24/24] dept: Disable Dept on that map once it's been handled until next turn Date: Fri, 4 Mar 2022 16:06:43 +0900 Message-Id: <1646377603-19730-25-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1646377603-19730-1-git-send-email-byungchul.park@lge.com> References: <1646377603-19730-1-git-send-email-byungchul.park@lge.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Dept works with waits preceeding an event, that might lead a deadlock. Once the event has been handled, it's hard to ensure further waits actually contibute to deadlock until next turn, which will start when a sleep associated with that map happens. So let Dept start tracking dependency when a sleep happens and stop tracking dependency once the event e.i. wake up, has been handled. Signed-off-by: Byungchul Park --- kernel/dependency/dept.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c index cc1b3a3..1c91db8 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -2325,6 +2325,12 @@ void dept_event(struct dept_map *m, unsigned long e_f, unsigned long ip, do_event((void *)m, c, READ_ONCE(m->wgen), ip); pop_ecxt((void *)m); } + + /* + * Keep the map diabled until the next sleep. + */ + WRITE_ONCE(m->wgen, 0); + dept_exit(flags); } EXPORT_SYMBOL_GPL(dept_event); @@ -2447,6 +2453,11 @@ void dept_event_split_map(struct dept_map_each *me, pop_ecxt((void *)me); } + /* + * Keep the map diabled until the next sleep. + */ + WRITE_ONCE(me->wgen, 0); + dept_exit(flags); } EXPORT_SYMBOL_GPL(dept_event_split_map);