Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1694435pxm; Fri, 4 Mar 2022 01:26:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJweOTiQX9dWu3AsgoExj2XwdtQQUF0wzLl+5OC/yD0LEqNoQI2a16pjAGZevgvGB91U+MpE X-Received: by 2002:a17:90a:8582:b0:1b9:b0da:9ca9 with SMTP id m2-20020a17090a858200b001b9b0da9ca9mr9581372pjn.146.1646385968448; Fri, 04 Mar 2022 01:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646385968; cv=none; d=google.com; s=arc-20160816; b=xAr1zJuxP/h+RCjZd1hXHGO916qOLU/Kf/ZskF3XIxKW4jSSAWETKu/OBLLw0cDQw1 OtgDOlU4MShBklCV5UKBJQnc6Coh+es8NJXS5n8pvgWxAY/b1+Cym29U9DU71cL5Bfrd lbOGWyePfPHVY+/jN81qcl9T2c+4RWj+qlnH/1uaGqATL/DQt46WMPZt85X4Z7y6HvwY 1E2gzlG67xdI2TIjj0fZREyTifbFaStUOBL0xdjRECtOfXMGEMLYfRgKWS5GkO8CizcC 3bzV9Mr/r2Nedh0fpXZBxBqpYIgHSFfcGHg9uoeFX84xkwJkZIcMiWU2meTQoFSW5Ggq xEww== 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=XFUVE6+/MuFyBmQbOAzjUBsoWTWSr8KVd+MKQQxitEM=; b=mH+7B60h9YKJbr9zTYzUnKZRlf4hQZnLPdHeA3F7vlevQySn/L0m7TtC+sqevQ0aYD 0y4cQO3gVt8H8m2Y7Dsmp1ViBUw5Kr1nMm+hNU5T2eFSwdPKPj5qpnuiq4tfW8+LL7Ue N4cXI++6us0GCkSE3McLRTe7uuRv8AVeMkx6uLnFAn8yLREc50YPsPVIDoSQpdRHyAk9 VIo/RleRLmhP7UZW9fkADxmS+JngB1+s+drrVdcbmP9gqJOIAbwG5dbITHupATzEv7nQ iY/gTJ3dAphsVH1F4wA03WdyuBr0qCCmgMiUYt5rse7uR0Ae8qVdEzdAAQrowXhrHG1C +O9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 e1-20020a6558c1000000b00372b10aea27si4434553pgu.134.2022.03.04.01.25.52; Fri, 04 Mar 2022 01:26:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238737AbiCDHJR (ORCPT + 99 others); Fri, 4 Mar 2022 02:09:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238757AbiCDHIv (ORCPT ); Fri, 4 Mar 2022 02:08:51 -0500 Received: from lgeamrelo11.lge.com (lgeamrelo13.lge.com [156.147.23.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F127A19140A for ; Thu, 3 Mar 2022 23:07:09 -0800 (PST) Received: from unknown (HELO lgemrelse6q.lge.com) (156.147.1.121) by 156.147.23.53 with ESMTP; 4 Mar 2022 16:07:08 +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:08 +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 18/24] dept: Distinguish each work from another Date: Fri, 4 Mar 2022 16:06:37 +0900 Message-Id: <1646377603-19730-19-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> 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=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-kernel@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 1a1c307..55c5ed5 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -486,6 +486,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); /* * for users who want to manage external keys @@ -527,6 +528,7 @@ struct dept_task { #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_key_init(k) do { (void)(k); } while (0) #define dept_key_destroy(k) do { (void)(k); } while (0) #endif diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c index 8f962ae..5d4efc3 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1873,6 +1873,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