Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp302678pxp; Wed, 16 Mar 2022 06:14:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4TEZk3Z1K9c9jwAEWBj3lg92la+hCHNU/KYrwK2OAUZmB/sKGIPSWJ1boGGqh+fyzMFFx X-Received: by 2002:a63:6a41:0:b0:37c:53a1:b5b6 with SMTP id f62-20020a636a41000000b0037c53a1b5b6mr28375065pgc.245.1647436496652; Wed, 16 Mar 2022 06:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647436496; cv=none; d=google.com; s=arc-20160816; b=mAF22qXals5KuMP4bon5oAmjdL8wkowDb3GsMPC9QTTl6caOf83cbUIRLZz1nQTp8P 95ykOH6aYp94ScTr/bkUPNOKzAtwgrcF00mFwaK64LXR9erh0IrXK+UzWFFeBTqe0bIT UpEbN769OteAMQvNcTZIOJXV6DfnFTT7d9Z0/+YJVHymbzGjmI5BWzQpIRT1GZleGNVC Ge08dMPP03W06kK4Iwxw+j/v6D4b9nHsIzDuwbwtFH2ogH386qMmIfkhniulJB3aLkkt 1MMXy4DOMHMxabTuCa+5z6qlxFgp+32vgTRL5S/Z6bLcysG6deWjTD3Wxgp0CMJK/jF+ N8eQ== 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=ieyugfiOI4t74MFxjtiPT4oODmZhez116AbOzhxo7ms=; b=xH0D+DLvyvUro2KiGM1CgXy6hpMXzhidAdHY5vO35nsf41ZSVt2mFcLgnn93hw3b4E TdqRZ50DLo6KxyWLejraMVucxwGZpCT4kyPvv7euyPvJUE++W06fnMCn5Udg+b6sVWc2 JJjTxB74NuRZ+BTG68YviKuIzvRhtHSdxOLPRMrw64Fw/oYA+guNtymxI8od2bLMYGBu S8YwXKoKVZ3vBTowoA79He8j3nHJK8pbjDXJljsvG3s5yCjSmBYa+EkfEoBR8W1O3gIR Bkc0qjRAK8ipiPRjdFJB7AUKrkcK6QJ5AugON/g7sEu/eKRcB/5MAIkwx+lXnugyoHuI 2BYw== 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 d205-20020a621dd6000000b004f6d2da73a4si1898320pfd.125.2022.03.16.06.14.40; Wed, 16 Mar 2022 06:14:56 -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 S1353226AbiCPC3x (ORCPT + 99 others); Tue, 15 Mar 2022 22:29:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353245AbiCPC3N (ORCPT ); Tue, 15 Mar 2022 22:29:13 -0400 Received: from lgeamrelo11.lge.com (lgeamrelo12.lge.com [156.147.23.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 92C945F250 for ; Tue, 15 Mar 2022 19:27:13 -0700 (PDT) Received: from unknown (HELO lgemrelse7q.lge.com) (156.147.1.151) by 156.147.23.52 with ESMTP; 16 Mar 2022 11:27:11 +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:11 +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 17/21] dept: Distinguish each work from another Date: Wed, 16 Mar 2022 11:26:29 +0900 Message-Id: <1647397593-16747-18-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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 672a762..3d24a52 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -491,6 +491,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) { @@ -535,6 +536,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 8d8d8eb..10801783 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1886,6 +1886,16 @@ void dept_disable_hardirq(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 33f1106..f5d762c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "workqueue_internal.h" @@ -2217,6 +2218,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