Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5660317rwl; Sun, 8 Jan 2023 20:07:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXtZxJbFDeX66NVUSsfRToEVuOeX5oWSVF8P3EFmlct/rBC20NpU2eAKHKPG7OBmgWebja X-Received: by 2002:a17:902:a514:b0:192:f500:e822 with SMTP id s20-20020a170902a51400b00192f500e822mr16021066plq.37.1673237250267; Sun, 08 Jan 2023 20:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673237250; cv=none; d=google.com; s=arc-20160816; b=AIXEC/Ctt8vQvpzzNDA5AcpmuLtN1gzgUFfQ/DRTVrw8fpZKnADbWKHRGBJYtDNhva KkBcuWDSmYdNV8VTvW9eM9XAp2gSiSh8DIkqK0b2kVigusspzN895vDuo34BPRWsUHlu P9y3e+Hy9ryRyKGf/6KFU+qSDDtyHd+yhDzPRDNNyVIthP0u2q63jIasvAefYC+YBXbr 1jSA2O1XFbmKtKkt/yttYkVCUhvHikd2b3WskIphnAWYeK5P/SiRaAsXDSJTdxE7bpyR xk0kKwI8Rkav9uh/MEexL6g7WEL9ciwSmOedVczWSQyu/hW5n2OfcY2JQ4YVM9qx02XB RvHA== 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=L3ppAkq5rLruG+8SPhkPAnZpB7FRHrfSMFk57i7jnGM=; b=SxmpwRc6QyWJZjMxNq0yxaGHbvQ2dlPI3ivsvXeBoD92puhVXa7A2d4jCmJdsRT6DX bf0I5xIhSBF5XjkpuZaX24v3rX6r2dld9D7xpIBSfy9C22pxaLkL0zQN6lJfVAZ1mbph X653g4s11GNUrJy5rAEQ1r/O5/Wf+hzzGs+a5z2HwkYMJxk0+3hft/m1q1L5qu0CYiFy zv9N95rHiIoNQK/ibb5OruwO9Lxc95xZstnNfFRH+UyD5xy3Zh1KfmRIuxfEl3DmHvWr DqEI1+Oz2OgN6sUR8jkdMJdhaeiD8bPkk0RlBT8MPECVQnD4xVfDUokIU7ibBt4UM+S2 /SrQ== 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 s12-20020a170902ea0c00b001926d641de9si8633050plg.553.2023.01.08.20.07.16; Sun, 08 Jan 2023 20:07:30 -0800 (PST) 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 S236527AbjAIEFE (ORCPT + 99 others); Sun, 8 Jan 2023 23:05:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236573AbjAIEEV (ORCPT ); Sun, 8 Jan 2023 23:04:21 -0500 Received: from lgeamrelo11.lge.com (lgeamrelo11.lge.com [156.147.23.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 17D8E1180E for ; Sun, 8 Jan 2023 20:03:53 -0800 (PST) Received: from unknown (HELO lgemrelse6q.lge.com) (156.147.1.121) by 156.147.23.51 with ESMTP; 9 Jan 2023 12:33:53 +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; 9 Jan 2023 12:33:53 +0900 X-Original-SENDERIP: 10.177.244.38 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: linux-kernel@vger.kernel.org Cc: torvalds@linux-foundation.org, damien.lemoal@opensource.wdc.com, linux-ide@vger.kernel.org, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, will@kernel.org, tglx@linutronix.de, rostedt@goodmis.org, joel@joelfernandes.org, sashal@kernel.org, daniel.vetter@ffwll.ch, duyuyang@gmail.com, johannes.berg@intel.com, tj@kernel.org, tytso@mit.edu, willy@infradead.org, david@fromorbit.com, amir73il@gmail.com, 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, jlayton@kernel.org, dan.j.williams@intel.com, hch@infradead.org, djwong@kernel.org, dri-devel@lists.freedesktop.org, rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, hamohammed.sa@gmail.com, 42.hyeyoo@gmail.com, chris.p.wilson@intel.com, gwan-gyeong.mun@intel.com Subject: [PATCH RFC v7 13/23] dept: Distinguish each work from another Date: Mon, 9 Jan 2023 12:33:41 +0900 Message-Id: <1673235231-30302-14-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1673235231-30302-1-git-send-email-byungchul.park@lge.com> References: <1673235231-30302-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_NONE autolearn=unavailable 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 777c837..625c645 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -515,6 +515,7 @@ struct dept_task { extern void dept_sched_enter(void); extern void dept_sched_exit(void); extern void dept_kernel_enter(void); +extern void dept_work_enter(void); static inline void dept_ecxt_enter_nokeep(struct dept_map *m) { @@ -565,6 +566,7 @@ static inline void dept_ecxt_enter_nokeep(struct dept_map *m) #define dept_sched_enter() do { } while (0) #define dept_sched_exit() 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 e98617b..2f215c2 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1954,6 +1954,16 @@ void dept_hardirqs_off(unsigned long ip) } EXPORT_SYMBOL_GPL(dept_hardirqs_off); +/* + * 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 07895de..69c4f46 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