Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4140774rwb; Mon, 16 Jan 2023 18:57:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXsZoUAVeMM+eK1D/9cMIbVUa75gTW/sMBV7Gl32+9/Qv+pnuMMziLddMg0CP9yM2UK5AAhS X-Received: by 2002:a17:906:7c3:b0:870:95b6:94a4 with SMTP id m3-20020a17090607c300b0087095b694a4mr1193842ejc.48.1673924233363; Mon, 16 Jan 2023 18:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673924233; cv=none; d=google.com; s=arc-20160816; b=Jyx78iyDU344VZoyPE5YgC9ptXu8xtS58a63U1WDrwi0eumNXn9GVICd8yM1fGuaDF f761a1H76SqDbWZI6HmiqIhFNW+LblinkJVsiR8oh2rPhUgbq8yviiuxdriquvX0Vvvy 9mXYZ759ZZZAzrWWYr1jgzFxVy/NOR91U8efCl59HS+l2w1Y0RrNWQZwF3zTD7wqcWyW f1l4BQYnchCRKr1LRLGgASyokm4PuKB/yI+S2lzsj4xpMwKIZFDoLOWQbQnN2tkAMrPW kubk5Y2jpnMm8NLjv98X/UZ42FB6vWL5P9aaKFeKbFCHdpGyQAQRiNuZ9TfYBQdu9PFD Bxow== 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=000a9m2DoIoKjXK7sVIo2/A2GFC81Al6i8o61eGFBME=; b=vJk2W0/A/9NTuN/IP4fcmQe45vlHAEYcXlIR8vZnWYYUgwBRwbIsvHX3RC7vVi+QN8 nbIvU4WW4O83eLuq0pU4rVHoELq8b0JM8PcbzccpsQPWUyKY+JzdHkMjxVmqA9EVNQLO E/v4RCWToFht7nBPwpu5aLPAlOttXkSrROZdlobCJE7MQyF3NDnzgA6NJ2P7KIF/m88c YrRGmK+TOJZQurvNsjCZCR/c125a9dgX0PGXPH0iEs5R5XDNjKLcK3/PJDL6AI2EGA8E 4oWBrDuC+x8s2op3XvreCSS/5oRiNlgfahQI/WSUX1HuZjLdUA22pWodv/MX2t4c0IHV 4WFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Ulmd1P+p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb33-20020a1709071ca100b00871a4e8d7c1si3421037ejc.775.2023.01.16.18.57.01; Mon, 16 Jan 2023 18:57:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Ulmd1P+p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235722AbjAQCuc (ORCPT + 49 others); Mon, 16 Jan 2023 21:50:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235721AbjAQCsc (ORCPT ); Mon, 16 Jan 2023 21:48:32 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6CFC31E27; Mon, 16 Jan 2023 18:42:02 -0800 (PST) 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=000a9m2DoIoKjXK7sVIo2/A2GFC81Al6i8o61eGFBME=; b=Ulmd1P+pFnTGzsE0Veaz8CDJrb l2SeOPiAAlZVK73sfMGTnBnttA+ugjnHs9dmERQAnAsqMFnsATPmMtjWyygDbe+kPAG4fL+V15gE8 jP3KN9CNjU/Btl32PE9hrj4fzQAHzd8VYMLhhXxRo2QySc9BtIkLKR7PkACGf+MfAJ59IBFzN/gtU /c4DeepTwNHezJqzu0TTjbQ2/OlAsgeKaw0F7gS2OydtWq4eGVxCpOvFxkha8V+nwo/ytwtl/o0iY HeIOcWhrziUWzn8ekaYrGIl+h/CEfImbS8DeNx7R/QSzzoyZ5HvYwIURZpLwcQeM71CvloLBr+GOR pX0BNMQw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHbur-009Ia4-Fu; Tue, 17 Jan 2023 02:41:37 +0000 Date: Tue, 17 Jan 2023 02:41:37 +0000 From: Matthew Wilcox To: Amy Parker Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dax: use switch statement over chained ifs Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 16, 2023 at 06:11:00PM -0800, Amy Parker wrote: > This patch uses a switch statement for pe_order, which improves > readability and on some platforms may minorly improve performance. It > also, to improve readability, recognizes that `PAGE_SHIFT - PAGE_SHIFT' is > a constant, and uses 0 in its place instead. > > Signed-off-by: Amy Parker Hi Amy, Thanks for the patch! Two problems. First, your mailer seems to have mangled the patch; in my tree these are tab indents, and the patch has arrived with four-space indents, so it can't be applied. The second problem is that this function should simply not exist. I forget how we ended up with enum page_entry_size, but elsewhere we simply pass 'order' around. So what I'd really like to see is a patch series that eliminates page_entry_size everywhere. I can outline a way to do that in individual patches if that would be helpful. > fs/dax.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/fs/dax.c b/fs/dax.c > index c48a3a93ab29..e8beed601384 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -32,13 +32,16 @@ > > static inline unsigned int pe_order(enum page_entry_size pe_size) > { > - if (pe_size == PE_SIZE_PTE) > - return PAGE_SHIFT - PAGE_SHIFT; > - if (pe_size == PE_SIZE_PMD) > + switch (pe_size) { > + case PE_SIZE_PTE: > + return 0; > + case PE_SIZE_PMD: > return PMD_SHIFT - PAGE_SHIFT; > - if (pe_size == PE_SIZE_PUD) > + case PE_SIZE_PUD: > return PUD_SHIFT - PAGE_SHIFT; > - return ~0; > + default: > + return ~0; > + } > } > > /* We choose 4096 entries - same as per-zone page wait tables */ > -- > 2.39.0