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 072EFC54EBE for ; Tue, 17 Jan 2023 02:50:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235658AbjAQCub (ORCPT ); Mon, 16 Jan 2023 21:50:31 -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: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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