From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62440C4332F for ; Wed, 16 Nov 2022 11:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239189AbiKPLSA (ORCPT ); Wed, 16 Nov 2022 06:18:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237845AbiKPLRi (ORCPT ); Wed, 16 Nov 2022 06:17:38 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C3D2ED56; Wed, 16 Nov 2022 03:06:05 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 48532336F3; Wed, 16 Nov 2022 11:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1668596764; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XH+WwbRJQ41jjX52JCMwciyjC/IToO3NGdpBZjwirKA=; b=vXxZfM8SzWrMncwtQu8dwsdM7I9+mxNBsUUrabi+G/surBd/JeW/L7cEEE7YQyFsgZcImc D9Isv35LGjeZ9nEkZ23bb+rzhjCi08gAjaFKsjKClxh7+qLiMLopXqJ+CUzkKR7xH7yxLM vQr7sWPY+fAvVO/sESxAAfmG/FBuoPw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1668596764; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XH+WwbRJQ41jjX52JCMwciyjC/IToO3NGdpBZjwirKA=; b=w9T+qm/fU+luAhmRTIv97xTItj/rvZ4ohnv0TQQV5Rj7z2XNhiZDarx17klBvJH8zbwBjS TlsDeswKTpbmc9BA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 39C6313480; Wed, 16 Nov 2022 11:06:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IUYSDhzEdGMvYwAAMHmgww (envelope-from ); Wed, 16 Nov 2022 11:06:04 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id CBC73A0709; Wed, 16 Nov 2022 12:06:03 +0100 (CET) Date: Wed, 16 Nov 2022 12:06:03 +0100 From: Jan Kara To: Gabriel Krisman Bertazi Cc: axboe@kernel.dk, mingo@redhat.com, peterz@infradead.org, jack@suse.cz, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, liusong@linux.alibaba.com, chaitanyak@nvidia.com Subject: Re: [PATCH 2/3] wait: Return number of exclusive waiters awaken Message-ID: <20221116110603.6rndj2eei6mi6k33@quack3> References: <20221115224553.23594-1-krisman@suse.de> <20221115224553.23594-3-krisman@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221115224553.23594-3-krisman@suse.de> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Tue 15-11-22 17:45:52, Gabriel Krisman Bertazi wrote: > Sbitmap code will need to know how many waiters were actually woken for > its batched wakeups implementation. Return the number of woken > exclusive waiters from __wake_up() to facilitate that. > > Suggested-by: Jan Kara > Signed-off-by: Gabriel Krisman Bertazi Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > include/linux/wait.h | 2 +- > kernel/sched/wait.c | 18 +++++++++++------- > 2 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/include/linux/wait.h b/include/linux/wait.h > index 7f5a51aae0a7..a0307b516b09 100644 > --- a/include/linux/wait.h > +++ b/include/linux/wait.h > @@ -209,7 +209,7 @@ __remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq > list_del(&wq_entry->entry); > } > > -void __wake_up(struct wait_queue_head *wq_head, unsigned int mode, int nr, void *key); > +int __wake_up(struct wait_queue_head *wq_head, unsigned int mode, int nr, void *key); > void __wake_up_locked_key(struct wait_queue_head *wq_head, unsigned int mode, void *key); > void __wake_up_locked_key_bookmark(struct wait_queue_head *wq_head, > unsigned int mode, void *key, wait_queue_entry_t *bookmark); > diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c > index 9860bb9a847c..133b74730738 100644 > --- a/kernel/sched/wait.c > +++ b/kernel/sched/wait.c > @@ -121,11 +121,12 @@ static int __wake_up_common(struct wait_queue_head *wq_head, unsigned int mode, > return nr_exclusive; > } > > -static void __wake_up_common_lock(struct wait_queue_head *wq_head, unsigned int mode, > +static int __wake_up_common_lock(struct wait_queue_head *wq_head, unsigned int mode, > int nr_exclusive, int wake_flags, void *key) > { > unsigned long flags; > wait_queue_entry_t bookmark; > + int remaining = nr_exclusive; > > bookmark.flags = 0; > bookmark.private = NULL; > @@ -134,10 +135,12 @@ static void __wake_up_common_lock(struct wait_queue_head *wq_head, unsigned int > > do { > spin_lock_irqsave(&wq_head->lock, flags); > - nr_exclusive = __wake_up_common(wq_head, mode, nr_exclusive, > + remaining = __wake_up_common(wq_head, mode, remaining, > wake_flags, key, &bookmark); > spin_unlock_irqrestore(&wq_head->lock, flags); > } while (bookmark.flags & WQ_FLAG_BOOKMARK); > + > + return nr_exclusive - remaining; > } > > /** > @@ -147,13 +150,14 @@ static void __wake_up_common_lock(struct wait_queue_head *wq_head, unsigned int > * @nr_exclusive: how many wake-one or wake-many threads to wake up > * @key: is directly passed to the wakeup function > * > - * If this function wakes up a task, it executes a full memory barrier before > - * accessing the task state. > + * If this function wakes up a task, it executes a full memory barrier > + * before accessing the task state. Returns the number of exclusive > + * tasks that were awaken. > */ > -void __wake_up(struct wait_queue_head *wq_head, unsigned int mode, > - int nr_exclusive, void *key) > +int __wake_up(struct wait_queue_head *wq_head, unsigned int mode, > + int nr_exclusive, void *key) > { > - __wake_up_common_lock(wq_head, mode, nr_exclusive, 0, key); > + return __wake_up_common_lock(wq_head, mode, nr_exclusive, 0, key); > } > EXPORT_SYMBOL(__wake_up); > > -- > 2.35.3 > -- Jan Kara SUSE Labs, CR