Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2258670rdb; Wed, 21 Feb 2024 01:54:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUwhrz16q1MPFI8wM5Cdgo8TElsT3/Gey1T1qqb4Gv5ODJczfKlFMnBsPzQlGjl1NjC0MOz9yH0HXfoh2pyztmIq8n+jGi/c0tN6B397w== X-Google-Smtp-Source: AGHT+IEx6oU9tnedS3Yq6AFcD3ygZxP20pgjzQt6FbNnV4z7AkLRUplmbJKtAHUnWF/Pt3SAA/jr X-Received: by 2002:a05:620a:889:b0:787:2ba3:a93e with SMTP id b9-20020a05620a088900b007872ba3a93emr18574423qka.39.1708509251054; Wed, 21 Feb 2024 01:54:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708509251; cv=pass; d=google.com; s=arc-20160816; b=lASl+9SS+6urMtJLBD/V9eSjMyf7uYAkV7OEuD7WcZOOkojimPN+lSkGWVmjbmLNRD TXo+BClubcjBCdNXzL7bsKsEaCl+Tr9JqgxTmnP7TJ0/3nbZrBFmwAKGzTkDgVtyFYua YSdPGUXwnHd8WgbgQuU65bfcfa6ZirKMfhvB6DOwpIZebqmHGm3drj9PJIdMQtDuYDfh 6oD6ioT2Ss2Dr7/yoJNGz29fUzdfx8r5Mu0jhZCLqrNuRXHcBgBsbCUl4TXnyJTiyFwU smhNaZEPA3z2s4ty4TBY0eoMrsIAEjnQ9lbNgC4IC+pIhrft3upYWU6Ln9wku6heg6U6 vEQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from; bh=dR3Pzjy2Jj23hEAEpr6NYX9tDj+7L5au6v0rSi3RxIY=; fh=QMm8m/ZWm+A1EqjKAllYKUqNg+o2tkLujHELlI5tZV0=; b=IxvKgzayfrI5Wzx8CIc2i0SVkntHfFSeqewRzMS5546/v2Zgga3UHf8YcFrcUfi0M6 xhaAt+r6WaoN0gOgF4mzD2DyrsIzBg4759kXBSuwjjgULVynuo0AdAZQgq6N+mHAy4Us 9dVECbB5iRfOolBPF0XV3eC3uqBqInGwWHBXiKadAG0vRymDTTNm5ApYWXxFRFgb3WhF AOFHBsnWxlhDdJWPIZ4MSM8Ev1rKPmHMOoBWk2uvrxTxdvGdVB8iUFXIIdoqU7Ll+egO T1J7tZJhaaNgIOYnYPKxNzOYIjfnUuRZULWtjeNyLB0TCSUA/GJ4S/Hdu+aPPjNUEnQ4 oMpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-74450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74450-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id qr6-20020a05620a390600b007878ae78a8dsi582845qkn.359.2024.02.21.01.54.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 01:54:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-74450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74450-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BBA1D1C231B0 for ; Wed, 21 Feb 2024 09:54:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56BC14CE19; Wed, 21 Feb 2024 09:50:04 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D869440BFA; Wed, 21 Feb 2024 09:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708509003; cv=none; b=uqzA5H8KmuBNmyOBUrLa+GnOLoLlNsTb/OZGKMRUU5gusN0fUgyzXEtEKTRLJd2YFUW2mAMyJJQGWM+kTw7VsLRqRKjrk3QmHipTHCh0QQZ8Q/RYnoLAQokPKbdiV1/4bsYfFPddo7bjTal2iEfBFubtGzKkDTz/Jr92kDrZ2Tw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708509003; c=relaxed/simple; bh=7Na745h6mqt6szPtcPf56L4nwkzcVctpfLScpiam1ys=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=td8pYmZqjS1UfmX9zIJJCZngNJfo0P8nYUGFxtRdndA5QGFcrT2rNMV/UTd41UwGql8rZLQ+MBisC7YXX4jcdL7Cf92cLO8sekicAOx/TWaQq4YbOiqeIcSogA27eilQBWzTca/Pqe1Xqu6yNpwKHfjzZGYcRvcOdNwMrFtirrc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d85ff70000001748-48-65d5c739e041 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: [PATCH v12 12/27] dept: Distinguish each work from another Date: Wed, 21 Feb 2024 18:49:18 +0900 Message-Id: <20240221094933.36348-13-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240221094933.36348-1-byungchul@sk.com> References: <20240221094933.36348-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSW0yTZxjHfd/v2I6az4L6TWM0TZxRAuoA84xsi4eLvbtYYmK8GRejjk+p cpCiHEwWUaqyIgxYEAfEcFhqgTqwRQWkWDGCqIV2VDkjoE47wBLWdquwQ6v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ence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 4e359f76ac3c..319a5b43df89 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -509,6 +509,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) { @@ -559,6 +560,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 9aba9eb22760..a8e693fd590f 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1933,6 +1933,16 @@ void noinstr dept_hardirqs_off(void) dept_task()->hardirqs_enabled = false; } +/* + * 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 noinstr dept_kernel_enter(void) { struct dept_task *dt = dept_task(); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 2989b57e154a..4452864b918b 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -53,6 +53,7 @@ #include #include #include +#include #include "workqueue_internal.h" @@ -2549,6 +2550,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