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 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 738A6C433ED for ; Fri, 14 May 2021 15:32:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC111613C4 for ; Fri, 14 May 2021 15:32:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC111613C4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 514016B0036; Fri, 14 May 2021 11:32:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EB376B006E; Fri, 14 May 2021 11:32:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B3BF6B0070; Fri, 14 May 2021 11:32:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 025B06B0036 for ; Fri, 14 May 2021 11:32:43 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 95B6B18017812 for ; Fri, 14 May 2021 15:32:43 +0000 (UTC) X-FDA: 78140229006.01.A034D7A Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf02.hostedemail.com (Postfix) with ESMTP id C8D6F40002FE for ; Fri, 14 May 2021 15:32:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=Ujz0E1kl/lI1r0fDUys7Yf4Hsl5e6CIz72CabqA7X6A=; b=WmNrbMeq/NOUTX6gnAk9Rvek3L N8/hfwN6Ngr6oHr83EF45M5aI1J0tGrdW5gU5i9ic5sUr8jerIEPeBm4Wc+9CHH9ICKBMzVSN+tRv Y0ZLgSWU+vbKouSEd0fpFtzJ8U9zR7YCkpa15KIcUzX+p8r2Lhe2utZmw1nscX5C9FjvDj1iU1nW8 f6hjyLc0/r/U3LHRgG42yLSq2Toj/SldMMCPeLrA7C4k1dfP48hXJ+1N5QDbt0T7fBp/Jj9tG+uSq J22V1tAR0jZz8Cgl38vsL5f5Al+MQz3tfG+R1Zvz9ddO6BeB1OIdK+hTgSzdI3ruzUsHlwEtk03BB 3mBxpLcg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lhZnX-008PGY-0s; Fri, 14 May 2021 15:32:19 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D3C5E30001C; Fri, 14 May 2021 17:32:15 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BB0A520298BDE; Fri, 14 May 2021 17:32:15 +0200 (CEST) Date: Fri, 14 May 2021 17:32:15 +0200 From: Peter Zijlstra To: Liam Howlett Cc: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , Song Liu , Davidlohr Bueso , "Paul E . McKenney" , Matthew Wilcox , Laurent Dufour , David Rientjes , Axel Rasmussen , Suren Baghdasaryan , Vlastimil Babka , Rik van Riel , Michel Lespinasse Subject: Re: [PATCH 26/94] Maple Tree: Add new data structure Message-ID: References: <20210428153542.2814175-1-Liam.Howlett@Oracle.com> <20210428153542.2814175-27-Liam.Howlett@Oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210428153542.2814175-27-Liam.Howlett@Oracle.com> Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=WmNrbMeq; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C8D6F40002FE X-Stat-Signature: m9cixubqqagi5jk67hws3hscrcpdaknh X-HE-Tag: 1621006361-194079 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Apr 28, 2021 at 03:36:02PM +0000, Liam Howlett wrote: > +enum maple_type { > + maple_dense, > + maple_leaf_64, > + maple_range_64, > + maple_arange_64, > +}; > +static inline unsigned long *ma_pivots(struct maple_node *node, > + enum maple_type type) > +{ > + switch (type) { > + case maple_arange_64: > + return node->ma64.pivot; > + case maple_range_64: > + case maple_leaf_64: > + return node->mr64.pivot; > + case maple_dense: > + default: > + return NULL; > + } > +} > +static inline unsigned long *ma_gaps(struct maple_node *node, > + enum maple_type type) > +{ > + switch (type) { > + case maple_arange_64: > + return node->ma64.gap; > + case maple_range_64: > + case maple_leaf_64: > + case maple_dense: > + default: > + return NULL; > + } > +} > +static inline unsigned long mte_pivot(const struct maple_enode *mn, > + unsigned char piv) > +{ > + struct maple_node *node = mte_to_node(mn); > + > + switch (mte_node_type(mn)) { > + case maple_arange_64: > + return node->ma64.pivot[piv]; > + case maple_range_64: > + case maple_leaf_64: > + return node->mr64.pivot[piv]; > + case maple_dense: > + default: > + return 0; > + } > +} I would suggest removing the default: case. Without it the cases are complete and the compiler should not complain. Then if you extend the enum and forget to add a case, the switch is no longer complete and will trigger a warning, forcing you to update it (hopefully correct). If you have the default, you'll not get a warning and it'll do whatever.