Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1346030pxy; Fri, 23 Apr 2021 06:11:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyavz7cepNURxsUYcm1AXIF0onqSVJCKaHwVQuwoUjZFdV85Ec5qnWkhUOxc+ydUPq1pwDi X-Received: by 2002:a17:902:c3d4:b029:eb:4d0c:7d1f with SMTP id j20-20020a170902c3d4b02900eb4d0c7d1fmr3679528plj.57.1619183466392; Fri, 23 Apr 2021 06:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619183466; cv=none; d=google.com; s=arc-20160816; b=VmgD9ip0yZGUlICUTTuD0iXU4PyKwMdtwwxOZhsVu4rfnzG8dKXPeA2waj7n9e7rY3 +az8YfpfJ5wRvONidOy2iFqU3rsVB4elWMBtlYHnkEqnBDFxSKa5rlb5ZfV1uEy0nUkD iOEXGTXz2uyAUS61jNeo32I5Fs36llJORen9+vhEMjsH5f1Sg2EnHcSVnfDuPGA2CNq7 3xD4JXDhrreghM6xPXZB+/rCvCqWM4+xpoy3aYq6tr0jqTqJVhOAgxrPSTzmUjk+QqNS eguudJARWfMrk/wX3EQqxSnsu6g6/HAbGg+sJFE6gIIhs5GpFkukMZKoRxMzch3v6ZRD M85A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aTA/WZ0fubKgiuLZMkyv2Dw6Jo7MxejhgE42RBMW76E=; b=SHEsA71t9zcrg07yofpqMtcLpmfxwWIZwluIDDrg0iKfCPMbCB8E1xq+ip3ptOX4MT QeZnW1oLAqazXkWzpxpaV+oKAEKF9fMeQrGQWeSzi0j5ytrqArzTZUNm4R5uKXaSZWpu T3qLzxWXPEZqeoHxmwyw4wvM1D8hBvtCVpYcW1VGLyC0EwPV+jTwmt38Qz8MhWRUhUiU eN7tWi9MfNMKH2NHtJ7I1dN2rVw40umd4G04nUAr7ujNiEYLUXnnJORFXTxD2so8Cvqj Sh+9A9h497yRcO6BLKDjHwggBzpigKWMPmXswbysDJyf2MmQsxFk86wSNlK7oKMYVRo4 hrEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aYR0pQZQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 77si7790808pge.100.2021.04.23.06.10.49; Fri, 23 Apr 2021 06:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aYR0pQZQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242652AbhDWNIi (ORCPT + 99 others); Fri, 23 Apr 2021 09:08:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43001 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242625AbhDWNIa (ORCPT ); Fri, 23 Apr 2021 09:08:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619183273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aTA/WZ0fubKgiuLZMkyv2Dw6Jo7MxejhgE42RBMW76E=; b=aYR0pQZQ8nq3gVLG9BGPmc1QKDhRDGJQo5c2oFM5TyCXDhURRMeaQsLYjYZ3+npyR+5MxX O27tUKriOUHWOCwMwagg7aEfq3e1X66ULzI7drNqbe5tr3atwMUGmlayYb4x+bSGStOFOM LEiaqMq+xoW6d2B/Z911X/+GgUq0/J0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-bqmKJPGyPCSURhppUUTeSA-1; Fri, 23 Apr 2021 09:07:49 -0400 X-MC-Unique: bqmKJPGyPCSURhppUUTeSA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 18BA58026AD; Fri, 23 Apr 2021 13:07:48 +0000 (UTC) Received: from horse.redhat.com (ovpn-115-86.rdu2.redhat.com [10.10.115.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 123E95C3E5; Fri, 23 Apr 2021 13:07:38 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 9DC16223D98; Fri, 23 Apr 2021 09:07:37 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, dan.j.williams@intel.com Cc: linux-kernel@vger.kernel.org, virtio-fs@redhat.com, vgoyal@redhat.com, miklos@szeredi.hu, jack@suse.cz, willy@infradead.org, slp@redhat.com, groug@kaod.org Subject: [PATCH v4 1/3] dax: Add an enum for specifying dax wakup mode Date: Fri, 23 Apr 2021 09:07:21 -0400 Message-Id: <20210423130723.1673919-2-vgoyal@redhat.com> In-Reply-To: <20210423130723.1673919-1-vgoyal@redhat.com> References: <20210423130723.1673919-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dan mentioned that he is not very fond of passing around a boolean true/false to specify if only next waiter should be woken up or all waiters should be woken up. He instead prefers that we introduce an enum and make it very explicity at the callsite itself. Easier to read code. This patch should not introduce any change of behavior. Reviewed-by: Greg Kurz Reviewed-by: Jan Kara Suggested-by: Dan Williams Signed-off-by: Vivek Goyal --- fs/dax.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index b3d27fdc6775..4b1918b9ad97 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -144,6 +144,16 @@ struct wait_exceptional_entry_queue { struct exceptional_entry_key key; }; +/** + * enum dax_wake_mode: waitqueue wakeup behaviour + * @WAKE_NEXT: wake only the first waiter in the waitqueue + * @WAKE_ALL: wake all waiters in the waitqueue + */ +enum dax_wake_mode { + WAKE_NEXT, + WAKE_ALL, +}; + static wait_queue_head_t *dax_entry_waitqueue(struct xa_state *xas, void *entry, struct exceptional_entry_key *key) { @@ -182,7 +192,8 @@ static int wake_exceptional_entry_func(wait_queue_entry_t *wait, * The important information it's conveying is whether the entry at * this index used to be a PMD entry. */ -static void dax_wake_entry(struct xa_state *xas, void *entry, bool wake_all) +static void dax_wake_entry(struct xa_state *xas, void *entry, + enum dax_wake_mode mode) { struct exceptional_entry_key key; wait_queue_head_t *wq; @@ -196,7 +207,7 @@ static void dax_wake_entry(struct xa_state *xas, void *entry, bool wake_all) * must be in the waitqueue and the following check will see them. */ if (waitqueue_active(wq)) - __wake_up(wq, TASK_NORMAL, wake_all ? 0 : 1, &key); + __wake_up(wq, TASK_NORMAL, mode == WAKE_ALL ? 0 : 1, &key); } /* @@ -268,7 +279,7 @@ static void put_unlocked_entry(struct xa_state *xas, void *entry) { /* If we were the only waiter woken, wake the next one */ if (entry && !dax_is_conflict(entry)) - dax_wake_entry(xas, entry, false); + dax_wake_entry(xas, entry, WAKE_NEXT); } /* @@ -286,7 +297,7 @@ static void dax_unlock_entry(struct xa_state *xas, void *entry) old = xas_store(xas, entry); xas_unlock_irq(xas); BUG_ON(!dax_is_locked(old)); - dax_wake_entry(xas, entry, false); + dax_wake_entry(xas, entry, WAKE_NEXT); } /* @@ -524,7 +535,7 @@ static void *grab_mapping_entry(struct xa_state *xas, dax_disassociate_entry(entry, mapping, false); xas_store(xas, NULL); /* undo the PMD join */ - dax_wake_entry(xas, entry, true); + dax_wake_entry(xas, entry, WAKE_ALL); mapping->nrexceptional--; entry = NULL; xas_set(xas, index); @@ -937,7 +948,7 @@ static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev, xas_lock_irq(xas); xas_store(xas, entry); xas_clear_mark(xas, PAGECACHE_TAG_DIRTY); - dax_wake_entry(xas, entry, false); + dax_wake_entry(xas, entry, WAKE_NEXT); trace_dax_writeback_one(mapping->host, index, count); return ret; -- 2.25.4