Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4913178rdb; Tue, 12 Dec 2023 12:58:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnLork9Tg7pyW0BWaiNDHV9l7LN55QizOaIC0+YGC1fs3na4dw/jaSla6uvoBbx5WWYwMa X-Received: by 2002:a17:90a:ca8e:b0:286:ccc1:486 with SMTP id y14-20020a17090aca8e00b00286ccc10486mr3313665pjt.27.1702414692387; Tue, 12 Dec 2023 12:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702414692; cv=none; d=google.com; s=arc-20160816; b=nFIF3N9cQ8y0CmnRDvuGOWbu8urBBOwal8W9RE+dMLheIm12PYRJLvBR26pIam1RRb dLhoJuVGLdqL3AVdGtmKBj4aBTIg6Am0FaSjAt8ZS+xP/0oQAV/fLqw/Ik1NOZTYGgFy YheO8Fi4ylVA4W/kSXrrC9u8r3DL7x9/BDx+dPEoYfrsY0RTNWRW3CLw7En6OXQKZyYg GeMTptqepeSlErA9UD0xOgdJl3/qEgSoV/QGR97cdQ/lCw0gf7cvD2sKgomYz7hmc+FB Wq0OvApI8VsPLyOkwde2/XJuv2MWs1flyyg85K0PQ9etaG7YtcOLv1CqZYgIvLvOpleT 5QHg== 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=uITo0Guj0fvGl1HiaxKOp67qOA6E5V8qn2kdwMvT6sI=; fh=j5a7YrPiEvLsw+IiFYzpF0Y/bQqW/RXK5emyzeLUDHc=; b=UNAVvjBmeg3WOj8vt5+ArMdpzFQTvYFNveb0VpE7t8o/DEc06pT/4SzR5ZLKHUMBKr lfzspsUeVUcSpmz/9xAYxgwUJ/3H0BWepn4G5otfp3le7ikmthRQNR7G50ziQA1uQWha uxz+EZ5nyW7LL9HGPpH5jL7jvpiIoNUIUWFq+KO2rGUnN3jl+2uym+yWGCZvRs5NDuA7 ilaVnK7FeQKyVALYUyIWJygRW6xA/VoeKGOEFBkKteL59nfsLC4pbnOYXnxdGOTZE7h/ b8aLo55W3aUoef+tXppx2qGd8dnVjhFneuUA+MQLKsXOxW2XNuPb0+eifyerpPiQMEyZ x5rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JCJxZjqq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id d90-20020a17090a6f6300b0028ac926cd0fsi1052074pjk.141.2023.12.12.12.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 12:58:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JCJxZjqq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id F18EB8025422; Tue, 12 Dec 2023 12:58:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377394AbjLLU54 (ORCPT + 99 others); Tue, 12 Dec 2023 15:57:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235145AbjLLU5v (ORCPT ); Tue, 12 Dec 2023 15:57:51 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265B9D66 for ; Tue, 12 Dec 2023 12:57:54 -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=uITo0Guj0fvGl1HiaxKOp67qOA6E5V8qn2kdwMvT6sI=; b=JCJxZjqqjUowDP4pNyoBpmBOIu ECYAvUk8kQTATukZso13qhi/8JOSGmjS5263QfDm47xDoR8+6LXRDgQz3kFVVh+YiGHCAfbLje9JY rNp0AE1M6F0GfSYqxtQTxOofQhn4XNw8AvV8JGV0bBko4bNyRNAQK9VBBOGJ9BFZp+nsOizGm608f 1xi5KupnhwRLgwKKSGqJsM3mVamf3OTQWtdtbt8Rm3n87urVek7fuPLFbDXZ2BLqv+n406P4XmOz1 t65/177xyXmgwjnF3wkOdOK/ba/g2oMP7HwzDLdy0p3dhJmx0gaHKUIlja6YLej+S8jFgFM4xa5C/ bxON2U3w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rD9p6-00BBis-OI; Tue, 12 Dec 2023 20:57:48 +0000 Date: Tue, 12 Dec 2023 20:57:48 +0000 From: Matthew Wilcox To: Sidhartha Kumar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org, akpm@linux-foundation.org, liam.howlett@oracle.com, zhangpeng.00@bytedance.com Subject: Re: [PATCH] maple_tree: do not preallocate nodes for slot stores Message-ID: References: <20231212194640.217966-1-sidhartha.kumar@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212194640.217966-1-sidhartha.kumar@oracle.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Dec 2023 12:58:10 -0800 (PST) On Tue, Dec 12, 2023 at 11:46:40AM -0800, Sidhartha Kumar wrote: > + /* Slot store, does not require additional nodes */ > + if ((node_size == mas->end) && ((!mt_in_rcu(mas->tree)) > + || (wr_mas.offset_end - mas->offset == 1))) > + return 0; Should we refactor this into a mas_is_slot_store() predicate? A few coding-style problems with it as it's currently written: 1. The indentation on the second line is wrong. It makes the continuation of the condition look like part of the statement. Use extra whitespace to indent. eg: if ((node_size == mas->end) && ((!mt_in_rcu(mas->tree)) || (wr_mas.offset_end - mas->offset == 1))) return 0; 2. The operator goes last on the line, not at the beginning of the continuation line. ie: if ((node_size == mas->end) && ((!mt_in_rcu(mas->tree)) || (wr_mas.offset_end - mas->offset == 1))) return 0; 3. You don't need parens around the !mt_in_rcu(mas->tree). There's no ambiguity to solve here: if ((node_size == mas->end) && (!mt_in_rcu(mas->tree) || (wr_mas.offset_end - mas->offset == 1))) return 0; But I'd write it as: if ((node_size == mas->end) && (!mt_in_rcu(mas->tree) || (wr_mas.offset_end - mas->offset == 1))) return 0; because then the whitespace matches how you're supposed to parse the condition, and so the next person to read this code will have an easier time of it.