From patchwork Tue Jan 31 08:39:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13122434 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAFE0C636CC for ; Tue, 31 Jan 2023 08:40:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 135A06B0081; Tue, 31 Jan 2023 03:40:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 028996B007D; Tue, 31 Jan 2023 03:40:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7C7A6B007D; Tue, 31 Jan 2023 03:40:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 956AD6B0081 for ; Tue, 31 Jan 2023 03:40:01 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 60243160406 for ; Tue, 31 Jan 2023 08:40:01 +0000 (UTC) X-FDA: 80414446602.29.54E9CC6 Received: from lgeamrelo11.lge.com (lgeamrelo11.lge.com [156.147.23.51]) by imf30.hostedemail.com (Postfix) with ESMTP id 2CB448000A for ; Tue, 31 Jan 2023 08:39:58 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=softfail (imf30.hostedemail.com: 156.147.23.51 is neither permitted nor denied by domain of max.byungchul.park@gmail.com) smtp.mailfrom=max.byungchul.park@gmail.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675154399; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=YWxyCP6k2sR51QC5g5Xns6OAkyCtz4mg3vnZr2yU7HE=; b=B2kpG2YpwIwk0yzUXnLr/a1pumwvfqHEEXK7RVsBj3byiWQyeOqq9aDUA6cSz6V74GEE9v uEOeV1hkcAKf040dZgFzFMi2MOPaxjTFirj+cnQ8Df47TBz7hSNyfD6HQGlfzUa8Xp6u+q 6z7vdcvS1yXe6IcRjr9d+nsc0P7U5c0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=softfail (imf30.hostedemail.com: 156.147.23.51 is neither permitted nor denied by domain of max.byungchul.park@gmail.com) smtp.mailfrom=max.byungchul.park@gmail.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675154399; a=rsa-sha256; cv=none; b=S+fGopE6XKniJonknWLjPglcHwSZJY73wIdoBE8JvSVkeXwQHL7wUpmqyqIECHT2sDxAxD UA1WnKqSH31jN4Owv5CxBwPP5BnkIHgUcb22HDtsOeuyUCwdJZbJ0F0ii/yk+Kc74sjbwG 7piKuKwPNV+qzUpUJvZCjj1xJWkyyOQ= Received: from unknown (HELO lgeamrelo04.lge.com) (156.147.1.127) by 156.147.23.51 with ESMTP; 31 Jan 2023 17:39:57 +0900 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: max.byungchul.park@gmail.com Received: from unknown (HELO localhost.localdomain) (10.177.244.38) by 156.147.1.127 with ESMTP; 31 Jan 2023 17:39:57 +0900 X-Original-SENDERIP: 10.177.244.38 X-Original-MAILFROM: max.byungchul.park@gmail.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, max.byungchul.park@gmail.com, boqun.feng@gmail.com, longman@redhat.com, hdanton@sina.com Subject: [PATCH v9 07/25] dept: Apply sdt_might_sleep_{start,end}() to wait_for_completion()/complete() Date: Tue, 31 Jan 2023 17:39:36 +0900 Message-Id: <1675154394-25598-8-git-send-email-max.byungchul.park@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1675154394-25598-1-git-send-email-max.byungchul.park@gmail.com> References: <1675154394-25598-1-git-send-email-max.byungchul.park@gmail.com> X-Stat-Signature: n1j1q1axgsrezmhib7der9fehc5chfhb X-Rspam-User: X-Rspamd-Queue-Id: 2CB448000A X-Rspamd-Server: rspam06 X-HE-Tag: 1675154398-659447 X-HE-Meta: U2FsdGVkX19dOm5CAzoQ4z3toGIRG4QqS8u64VTkJ1FA6VV+huFtnZeh8cu08L7GF/F2n4UEPu3k1O5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GFcrCJSoA46D+5LDClhlYX1ykLmyVhd46CARRe5jWQYn6fNCPwRJd/5q+aep/c5cbJpDXIV4MzF3pPIV255lcNO2Utzwb76fzUejphwlhw4z7V1VfdritnzqZcafayTkr7YQJfgNoMx+I3E7Pxrk+WJ/wperclGtqfBOTa4SbrGKoE/oiQKziqUnQzTtbL31q9WAf7oawk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Makes Dept able to track dependencies by wait_for_completion()/complete(). Signed-off-by: Byungchul Park --- include/linux/completion.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/include/linux/completion.h b/include/linux/completion.h index 62b32b1..32d535a 100644 --- a/include/linux/completion.h +++ b/include/linux/completion.h @@ -10,6 +10,7 @@ */ #include +#include /* * struct completion - structure used to maintain state for a "completion" @@ -26,14 +27,33 @@ struct completion { unsigned int done; struct swait_queue_head wait; + struct dept_map dmap; }; +#define init_completion(x) \ +do { \ + sdt_map_init(&(x)->dmap); \ + __init_completion(x); \ +} while (0) + +/* + * XXX: No use cases for now. Fill the body when needed. + */ #define init_completion_map(x, m) init_completion(x) -static inline void complete_acquire(struct completion *x) {} -static inline void complete_release(struct completion *x) {} + +static inline void complete_acquire(struct completion *x) +{ + sdt_might_sleep_start(&x->dmap); +} + +static inline void complete_release(struct completion *x) +{ + sdt_might_sleep_end(); +} #define COMPLETION_INITIALIZER(work) \ - { 0, __SWAIT_QUEUE_HEAD_INITIALIZER((work).wait) } + { 0, __SWAIT_QUEUE_HEAD_INITIALIZER((work).wait), \ + .dmap = DEPT_MAP_INITIALIZER(work, NULL), } #define COMPLETION_INITIALIZER_ONSTACK_MAP(work, map) \ (*({ init_completion_map(&(work), &(map)); &(work); })) @@ -75,13 +95,13 @@ static inline void complete_release(struct completion *x) {} #endif /** - * init_completion - Initialize a dynamically allocated completion + * __init_completion - Initialize a dynamically allocated completion * @x: pointer to completion structure that is to be initialized * * This inline function will initialize a dynamically created completion * structure. */ -static inline void init_completion(struct completion *x) +static inline void __init_completion(struct completion *x) { x->done = 0; init_swait_queue_head(&x->wait);