Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3845244pxy; Mon, 26 Apr 2021 11:05:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpleRin7kIOeOQklOBO8/L+7D1u+2tIjE7s+RsR4sQMKPEOcUcHyUScyGI3VRPdjE/oTHm X-Received: by 2002:a50:e702:: with SMTP id a2mr23060767edn.3.1619460342576; Mon, 26 Apr 2021 11:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619460342; cv=none; d=google.com; s=arc-20160816; b=ZWbGZKsH6SQUoJ7b9voYdsV0fXddDhUEIaRUU4qWpI0jSbqWGNpGVnx/yvsCdeTeVE 8zDghf6neV2tEYKvsPUX6a4HVRUnKe78s82C1FUlWlyymj2xBvA/upYY/FdZLTOoY8kP HhOvwEijk6ACm1kyRuvPpRql3bHfGH75SirRDVj0gFM/sW+zGNz3a7NeFwYG1VzFLxow B5vk5BFuVr8SEw7iiiH5++awq3NHcmY5th3AzTTXCqcrRvwWXJBFt8FtpJ6Jq25D2yW9 twuGimtpHYq8Kmri64hzKuaOXxUHuYtM91XrfMF4r5GflSKcMSP9hG9TuowFZF5OqXnw zR1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PWkah+fwPe33ZZcVqLDlcUWqo58D207f7qzlEj7nZwY=; b=R9vV7DKfeQ1kSTzrJU1ZMlBor0T5uV3xquXDPiygfGIdmxCZ7MwCi1iQTexm1bNEMU 7YwYn5Az73rxzUdsYgqlpyBtHco8fR3q3zg5TVP0u0GKxyyK80mtBigapfUUDaX/LX+8 d0LybE7N39NjAlBz2NcC/4TrR86A7Ew6Ve6+2H0HsijgQ/GJuwOobCaAjYNulRikL+ke eP/bGGXmDflcoVwFEbz7XPcLdNXFFg8oIiJI92Oku2N3+CKtSFafahV1XOybJ8Aq/StA m1An+dJKBhjh5kKcOwITa/Y5EteSg4kZzs++XAjo3+AlJXdPLkWhBVtr3ZhDqRwpJSlI UsgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="GCyXjZT/"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si425469edj.328.2021.04.26.11.05.18; Mon, 26 Apr 2021 11:05:42 -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=@infradead.org header.s=casper.20170209 header.b="GCyXjZT/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234108AbhDZSDG (ORCPT + 99 others); Mon, 26 Apr 2021 14:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233919AbhDZSDF (ORCPT ); Mon, 26 Apr 2021 14:03:05 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0152AC061574; Mon, 26 Apr 2021 11:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PWkah+fwPe33ZZcVqLDlcUWqo58D207f7qzlEj7nZwY=; b=GCyXjZT/CpYO/4ULivAxhOfL2e t0+fXiuhp77Toc2bpsmMyGA5pKlvXqdOCQ6BY6f9QcP7f02vrnAGfLg/qTL3PqwbxefsOH5XwkviN NGsMJi1ldPNllb+6J6c3TQhT0VsyOM8pqoJ6n4WgGNpxLiF05zsb2N7BNR5LSpzTiwLzL4L+2XP8j szX8OM40R/GksXzf/AZUIdGzO6iVgiyvWY+IEYZpWbUVY8OmfA+xG7HSQof2Yn3OokpD+UCJpUbei eOAVq+Twf6Xf8U2cVBFX3h4rvP1hzJixGETipmVcMHFX16aMbfe3yMQgr5SHicD71ImR99HvawHwx 2YsP+Oag==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lb5Yh-005wFT-Uj; Mon, 26 Apr 2021 18:02:15 +0000 Date: Mon, 26 Apr 2021 19:02:11 +0100 From: Matthew Wilcox To: Vivek Goyal Cc: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, dan.j.williams@intel.com, linux-kernel@vger.kernel.org, virtio-fs@redhat.com, miklos@szeredi.hu, jack@suse.cz, slp@redhat.com, groug@kaod.org Subject: Re: [PATCH v4 1/3] dax: Add an enum for specifying dax wakup mode Message-ID: <20210426180211.GP235567@casper.infradead.org> References: <20210423130723.1673919-1-vgoyal@redhat.com> <20210423130723.1673919-2-vgoyal@redhat.com> <20210426134632.GM235567@casper.infradead.org> <20210426175217.GD1741690@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210426175217.GD1741690@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 26, 2021 at 01:52:17PM -0400, Vivek Goyal wrote: > On Mon, Apr 26, 2021 at 02:46:32PM +0100, Matthew Wilcox wrote: > > On Fri, Apr 23, 2021 at 09:07:21AM -0400, Vivek Goyal wrote: > > > +enum dax_wake_mode { > > > + WAKE_NEXT, > > > + WAKE_ALL, > > > +}; > > > > Why define them in this order when ... > > > > > @@ -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); > > > > ... they're used like this? This is almost as bad as > > > > enum bool { > > true, > > false, > > }; > > Hi Matthew, > > So you prefer that I should switch order of WAKE_NEXT and WAKE_ALL? > > enum dax_wake_mode { > WAKE_ALL, > WAKE_NEXT, > }; That, yes. > And then do following to wake task. > > if (waitqueue_active(wq)) > __wake_up(wq, TASK_NORMAL, mode, &key); No, the third argument to __wake_up() is a count, not an enum. It just so happens that '0' means 'all' and we only ever wake up 1 and not, say, 5. So the logical way to define the enum is ALL, NEXT which _just happens to match_ the usage of __wake_up().