Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp699795iob; Wed, 4 May 2022 06:20:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkXUPs3tQ1uvV4bLjpvsTD2jfRdhEq+iVvzilmLGG6aKy4+tvvBbFkkG/zPBQXcWHdbs1L X-Received: by 2002:a17:902:e806:b0:15e:7f0c:ce2b with SMTP id u6-20020a170902e80600b0015e7f0cce2bmr21167237plg.100.1651670407929; Wed, 04 May 2022 06:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651670407; cv=none; d=google.com; s=arc-20160816; b=a/rqPt+lHIGPhIGyRV0TtL+6PXNqzVdXAFv/kosbhBeAl68Eo+tMfDOJjC2s6rjhHU IXIHumvKSqpgxrvMbVPYs+i1AnPbedn8EB8iiPx6PJmRpGm7hDlWZ/i8jag81LCsDyOA pczLNrwCGNoAOx4CBI9cAJGmAtMDU0xDsaC1+aeUUKASpYUm/ttYToyuxfsCVHpAP/Nn VmU2mTXCl2lzuFXBN9taGluL9KpaE05DdLOpZrfBvgpfHbjQ8RMAEqQsA1DMNaWyTyhP bztxV4qu8Q217tdUmjetauREZAvVgxJjc9/9hzJYbvpg6kgWKr9/wZo+fADKu2AkxpCf uEPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=tVCydFLQ3kTAuwClalI10j8IrwVkBCHevyPj8J1n0yA=; b=txWl15K1y6oLDuuVCf+5DG0WnKo/xdH/cWpjDTwCaNMNX5IhOJRAVO7L4NcRhUaKTB BtSeJAOWqbwf0UWV4vFbZIFvlPKE/cxzvOdRKQaWzBqsJwmhMdqQSPHFLFqLw5tNhfrO WbxROvzhRTyvhefq16fWoLZfechr53jXRe/Sk+qRUXEGKq87Ypd76cD/LsshnfdAyGNZ I9mjNvI8MvBPF69CQcYW2NFwjgo3e1phOD8FLCZNOSQJv37XQa8mZF1DmN0qG/eC9RqD cAJy4rEAM2/PqaQZnaKvEuXyABv+o6hYYFyoNeBWz1tf6KOBTECzSFZ43emACEEILnlu zY8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a056a00244500b004fa3a8e003fsi1681224pfj.246.2022.05.04.06.19.44; Wed, 04 May 2022 06:20:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346785AbiEDIxb (ORCPT + 99 others); Wed, 4 May 2022 04:53:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346684AbiEDIxX (ORCPT ); Wed, 4 May 2022 04:53:23 -0400 Received: from lgeamrelo11.lge.com (lgeamrelo11.lge.com [156.147.23.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AD18A24F22 for ; Wed, 4 May 2022 01:49:22 -0700 (PDT) Received: from unknown (HELO lgeamrelo01.lge.com) (156.147.1.125) by 156.147.23.51 with ESMTP; 4 May 2022 17:19:21 +0900 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO localhost.localdomain) (10.177.244.38) by 156.147.1.125 with ESMTP; 4 May 2022 17:19:21 +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, 42.hyeyoo@gmail.com Subject: [PATCH RFC v6 16/21] dept: Distinguish each work from another Date: Wed, 4 May 2022 17:17:44 +0900 Message-Id: <1651652269-15342-17-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1651652269-15342-1-git-send-email-byungchul.park@lge.com> References: <1651652269-15342-1-git-send-email-byungchul.park@lge.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Workqueue already provides concurrency control. By that, any wait in a work doesn't prevents events in other works with the control enabled. Thus, each work would better be considered a different context. So let Dept assign a different context id to each work. Signed-off-by: Byungchul Park --- include/linux/dept.h | 2 ++ kernel/dependency/dept.c | 10 ++++++++++ kernel/workqueue.c | 3 +++ 3 files changed, 15 insertions(+) diff --git a/include/linux/dept.h b/include/linux/dept.h index c020b17..1a3858c 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -503,6 +503,7 @@ struct dept_task { extern void dept_event_split_map(struct dept_map_each *me, struct dept_map_common *mc, unsigned long ip, const char *e_fn); extern void dept_ask_event_split_map(struct dept_map_each *me, struct dept_map_common *mc); extern void dept_kernel_enter(void); +extern void dept_work_enter(void); static inline void dept_ecxt_enter_nokeep(struct dept_map *m) { @@ -556,6 +557,7 @@ static inline void dept_ecxt_enter_nokeep(struct dept_map *m) #define dept_event_split_map(me, mc, ip, e_fn) do { } while (0) #define dept_ask_event_split_map(me, mc) do { } while (0) #define dept_kernel_enter() do { } while (0) +#define dept_work_enter() do { } while (0) #define dept_ecxt_enter_nokeep(m) do { } while (0) #define dept_key_init(k) do { (void)(k); } while (0) #define dept_key_destroy(k) do { (void)(k); } while (0) diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c index 18e5951..6707313 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1844,6 +1844,16 @@ void dept_enirq_transition(unsigned long ip) dept_exit(flags); } +/* + * Assign a different context id to each work. + */ +void dept_work_enter(void) +{ + struct dept_task *dt = dept_task(); + + dt->cxt_id[DEPT_CXT_PROCESS] += (1UL << DEPT_CXTS_NR); +} + void dept_kernel_enter(void) { struct dept_task *dt = dept_task(); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 0d2514b..334654c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "workqueue_internal.h" @@ -2199,6 +2200,8 @@ static void process_one_work(struct worker *worker, struct work_struct *work) lockdep_copy_map(&lockdep_map, &work->lockdep_map); #endif + dept_work_enter(); + /* ensure we're on the correct CPU */ WARN_ON_ONCE(!(pool->flags & POOL_DISASSOCIATED) && raw_smp_processor_id() != pool->cpu); -- 1.9.1