Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp1201730rdb; Sun, 20 Aug 2023 23:31:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENGgRA68+D0YXs6R01jIAN5yJR7y5KBg429lVKDw+xLrf6kW1jMP2+dZRdaH/1S3tsQ1YH X-Received: by 2002:a05:6808:3ae:b0:3a7:71fd:57cc with SMTP id n14-20020a05680803ae00b003a771fd57ccmr7929165oie.12.1692599461159; Sun, 20 Aug 2023 23:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692599461; cv=none; d=google.com; s=arc-20160816; b=b83IG058EBhhQmVHHX57QahE0jbg3gnlP/sS+z+jcQXLA1sK2aFoHeZsn/NBnaQ+9o O5Sx27LGPR3QqzIpAIQamK2JVbdMnF2WLjx1vJftVgGZfpYTPmK71uwL9bDE6SUC5uWO WBK+PkMVT7K0zauz9umMHgxaOD2XmIah/XVRMvlkbeAYEtbQhatnIq0ScOC8/vt4M9vw oR7e9DQfBZ0tO15s5Wt4E/TzZH/7qo8M9ayNg/UxW4U1YLvy2jRF54tKH8tSqgyg9Fwr FUgDmgjRhrn3eNqW+EYxcxmjLopFtX3eJ06HizEpwvV5GIi3HUzjvuV91GDwsgr9yEut GLhw== 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=3eye6OD1X+HoXy1nXbL8uijgw0gPjqU66lxZMfKwMZU=; fh=kGnzKYSn064RMSZptPjPd5hgMSRJ2vTyckfMzEu7c/w=; b=tHjnRPE9y9qQC326ai3f0yzTgJfpogDd6nX8NU7So+bGgZ24JBDXcaXpMNcMyE4TMc nO8cZ6U+sesDWlCuZfQ/ik9CVRbaKpKqBFM3GMO51dlZ/0REibkLxLGJzMSZj2kdG9gO QsNkHJ6cwWUAXs590qpde27OHeeiuhs/BKSBW/grkxXVQ+Thh/hOwMJEMEqgU7fj3GXZ Yum0tN8iV26lZiHMKNh/jU33mzzyP2PZdiqTePSaknxvODBMoMY420pFJiELlAq3AKFT rG3K7AnSNLZKFyuGSiovROr9/bw/qk89BLsYhWb1YPunQ5gchQbWnck4Tgyv/8PSkHgR kvLw== 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 q24-20020a637518000000b0056a873802c7si3284092pgc.505.2023.08.20.23.30.48; Sun, 20 Aug 2023 23:31:01 -0700 (PDT) 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 S232878AbjHUEI1 (ORCPT + 99 others); Mon, 21 Aug 2023 00:08:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232747AbjHUEIN (ORCPT ); Mon, 21 Aug 2023 00:08:13 -0400 Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 73A0419B; Sun, 20 Aug 2023 21:07:31 -0700 (PDT) X-AuditID: a67dfc5b-d6dff70000001748-bb-64e2ded5b546 From: Byungchul Park To: linux-kernel@vger.kernel.org Cc: kernel_team@skhynix.com, 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, 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, max.byungchul.park@gmail.com, boqun.feng@gmail.com, longman@redhat.com, hdanton@sina.com, her0gyugyu@gmail.com Subject: [RESEND PATCH v10 13/25] dept: Distinguish each work from another Date: Mon, 21 Aug 2023 12:46:25 +0900 Message-Id: <20230821034637.34630-14-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230821034637.34630-1-byungchul@sk.com> References: <20230821034637.34630-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSbUxTZxTHfZ77VirdrkXdHWyZa6oY3RCMmpPhFvaJGze3Je7D4jRa7XVU gWpBFCIbCDIQS4AM2ISYUknXQDfwFhRBCC8KAhMqVEQDlXZG5J3BWuVFthbjl5Nfzv9/fp+O hJDXUYESTWy8oItVRStoKSmd9C/9uN/hUofWZrKQdykU3P9mklBSaaHB9mcFAkt1KobRO5Hw 0DOBYPFeDwFFBTYEpc4hAqrbHAgazOdp6Hv6Ftjd0zR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8TyGhoMJCQ9utcgSW6kQMA482Q9fIIILxZ60E 5OW2IShy9hBQ3diLwFZ6ioaOvllg9wzR0JSbTkPStQoa2j9NYOi+kIOhXNoCzVnFGOpGP5CQ N0DD5bwkPDk+Yhg1lzFgTlgErtJLDEw4g6Cp10FBw5UmCmyvlsHFq900WG1NJDTWuDB03C2g odfyh4LmxicktGVnUnDzSzENn0bMBJg9Qww8ryvEUJk8aTsz/JuCx5l1GM6U3MZgf3kPQW3K WwySxUFDg2cQQ5WUS8DYjUcIXOc+M3A6Y5SBy4nnEKSfvkBC66/HFCR3q2D8ZwG9fo3QMDhE CMlVxwXbSCEpPC3mhTuXehghufYVIxRKx4Sq0qXCNesAFoq+eShBKkulBelbDiOkfbZj4UtL CyM8yR8nhT57Ht42f69srUaM1MWKhpWhETJthcVOHHX7mLqq5yYgiUtD3izPBfNPK8fJKaa5 xfyLF6PEFPtyC/mqzPdUGpKxBHd2Bl/qfkZPBT5cGP/wwfPpB5JbxLcmjqEplnOreKe7Df+T LuDLK+umRd6Te+ne3ekbBafivzrfkVlIVoi8ypCvTh8bpdZFqlYYj2jj9DrTioPRURKa7Iw5 fiK7Bn3v2FyPOBYpZ8oj5rs0Ckoda4yLqkc8Syh95f4/nBqFXKOOOyEaovcbjkWKxnrkz5JK P3nYbjFCwR1Sx4hHRPGoaPifYtZ7XgKK35lqDNMWXY2pcERbw1XNczaEttSaAiXbrhv3vbT+ S2T5+1rbf3RaV38I7T+ZsjLg/MbtQ1alaZbjys5l1316Vg8fTMqKCdrb9zp6q3xsj76hxBTu Ffx2x57+JeschpAD5l3DmeaS2Tl+8Y1vfoW48zdZeg6nn2IH3B7DclET4n9TSRq16qClhMGo /gv9mtivLwMAAA== X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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-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 f62c7b6f42c6..d9ca9dd50219 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -515,6 +515,7 @@ extern void dept_ecxt_exit(struct dept_map *m, unsigned long e_f, unsigned long 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) { @@ -567,6 +568,7 @@ struct dept_task { }; #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 4165cacf4ebb..6cf17f206b78 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1977,6 +1977,16 @@ void dept_hardirqs_off_ip(unsigned long ip) } EXPORT_SYMBOL_GPL(dept_hardirqs_off_ip); +/* + * 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 c913e333cce8..fa23d876a8b5 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -52,6 +52,7 @@ #include #include #include +#include #include "workqueue_internal.h" @@ -2318,6 +2319,8 @@ __acquires(&pool->lock) 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); -- 2.17.1