Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3227132ybl; Sun, 11 Aug 2019 18:39:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsxBrPIk9e3NkMBHJz+HEEHGzTnHXxH0rAIeWn5otHW5JqFD284OzRCJPK/wytOOVjkduU X-Received: by 2002:a17:902:567:: with SMTP id 94mr20886101plf.228.1565573974824; Sun, 11 Aug 2019 18:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565573974; cv=none; d=google.com; s=arc-20160816; b=b3qdshPza4KUXRbhPUqY+6zZasO37kJ0t8f0Knyxh/Oiu21SdbFcZvN7X/0cUAchXc vRWZvC/6i2wGg4EsTKeEE7qbsVTbu8lfPVxEECi6IZq6pTyyviqekolesu/sZpNyTqwg bwq+6QFP2Op9KmJr6k1ZfFbXUFcr2BvTvSiQDjm+1OfMMpTW+KUg3TvQjs+DlrfdIl0i WshP5j8CpLdlsjr8pIrOdOGfva0Do8w2xV6aGZLARph+DMuBpyWP2QrclNMjeceZcTKI x28oA6o8zOVdi1OW8iVuShXvFp3BioMza5v8KXBZ/ldr2+XxMp1gKBHuJrqVKkkUhdrZ xT3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2LvnTipJZhZIUoRbWH0WQTQrByqAr4V2iqODb0EELto=; b=t7DtNBVCPKsnIsqi+FHVFHMBRAqY37PU/142BR1/DMZ1mMGuIW1AaYRrgnYO1E08Tr uDZqIdJrd2COeunHAdc1r4o7EZSVNBVM/tgtqIJ8DyrITpfJA5MVLbaW3Zz9dFIEziGz PsmwSKrV7yTXO98wSNIZavZLhjcR5qcFy5q18b9kwRCEmVeBsUQCXC591u3QiTlwnyUx 8fMDmYXJK3i7WUgMiFbf5jtnz3F6qq6M8OGdgPkQ41QKUsPBbrFMiHwyCPwswHFYia3P Y3bQJrveniFl7RCB4ozh3ah8bOYki22KRqT+h5Gt/VM033/ykqZNYLcyp2jQ1nvXQy4p c5Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SZiO6DEO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si61711792pgr.514.2019.08.11.18.39.17; Sun, 11 Aug 2019 18:39:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SZiO6DEO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbfHLBho (ORCPT + 99 others); Sun, 11 Aug 2019 21:37:44 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:32899 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbfHLBhn (ORCPT ); Sun, 11 Aug 2019 21:37:43 -0400 Received: by mail-vs1-f68.google.com with SMTP id i7so2534210vsp.0 for ; Sun, 11 Aug 2019 18:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2LvnTipJZhZIUoRbWH0WQTQrByqAr4V2iqODb0EELto=; b=SZiO6DEOIuyIhDHVG+GnlEin+uNFqKBQipgtk36IXhXF1wSZzH4nnCKhrLWOSlpIRO q5pzayzwz5vRvu90mtASG4006WIp47vBQvOex/05Py76sArBAEfJbX+E9g/k7pEJttu7 NbNu3WpFyjx9+q3+IUMCoU/wL+Qjl4VAcRsj9TSpD1+lghCVx+59zJkpF6mSMskDjRk9 XOgSue0Fh84YKh7QuLx46d+rHY+y7byVzs5sdi6/Lg5yYhoPRX9p6r2rokgieZslHFvY 57vbYtPb7tkEuXOS9YcJbostJENVMDO2mt/cBcJuiUuVDanqsAFr8mQ2C4kY2A0NE21x 6/Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2LvnTipJZhZIUoRbWH0WQTQrByqAr4V2iqODb0EELto=; b=Gnfrvojf09FPbNGjF9DdNPggBIXlqTdA155ee34Ocxyv9M7zHnw3DlOPHWhkOK/ZHF 9xJubkU6TaiTmvNtqPO9F/z/4RAJ6Pe2gEmp/+fwgvWGgjtkl/aIRmNhcFMA5yvKAIdE xxGk7vhmTEwAghh2uYCSlkgcfa2qGROWohQRLQil54o4zkZ6wEb6n3mA853knRelzpCp KBnY2Kt1ys8jPurMtNSsyNUiMNfIZCoxbmwK3gwKcWaoO1JYgXSTHM1H/AEDE47F++8X E2z4U3ATS+FkCqu2Q8V9QeM/KEPZUNDgrWeG/8Z/Dn9RLigAyeB25o/HDbmFX3m0SoNT ciUw== X-Gm-Message-State: APjAAAUe2Uzi9Z/rXlFLPtgKiIL0U/I1BKfEjEUPI3ATtkccmEAPihtm 2JxqGmjKkKo8YuF2bC/2kttmNTE40A1NJ4XofokULg== X-Received: by 2002:a67:3251:: with SMTP id y78mr11021809vsy.39.1565573862229; Sun, 11 Aug 2019 18:37:42 -0700 (PDT) MIME-Version: 1.0 References: <20190811184613.20463-1-urezki@gmail.com> <20190811184613.20463-2-urezki@gmail.com> In-Reply-To: <20190811184613.20463-2-urezki@gmail.com> From: Michel Lespinasse Date: Sun, 11 Aug 2019 18:37:30 -0700 Message-ID: Subject: Re: [PATCH 1/2] augmented rbtree: use max3() in the *_compute_max() function To: "Uladzislau Rezki (Sony)" Cc: Andrew Morton , linux-mm , LKML , Peter Zijlstra , Roman Gushchin , Hillf Danton , Michal Hocko , Matthew Wilcox , Oleksiy Avramchenko , Steven Rostedt Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 11, 2019 at 11:46 AM Uladzislau Rezki (Sony) wrote: > > Recently there was introduced RB_DECLARE_CALLBACKS_MAX template. > One of the callback, to be more specific *_compute_max(), calculates > a maximum scalar value of node against its left/right sub-tree. > > To simplify the code and improve readability we can switch and > make use of max3() macro that makes the code more transparent. > > Signed-off-by: Uladzislau Rezki (Sony) Thanks. The change is correct but I think I prefer it the "before" version. My reasons are: - I don't have a strong style preference either way - it's the same amount of code either way, admittedly more modular in your proposal, but also with more indirection (compute_max refers to get_max and max3). The indirection doesn't hinder readability but IMO it makes it harder to be confident that the compiler will generate quality code, compared to the "before" approach which just lays down all the pieces in a linear way. - A quick check shows that the proposed change generates larger code for mm/interval_tree.o: 2757 0 0 2757 ac5 mm/interval_tree.o 2533 0 0 2533 9e5 mm/interval_tree.o.orig This does not happen for every RB_DECLARE_CALLBACKS_MAX use, lib/interval_tree.o in particular seems to be fine. But it does go towards my gut feeling that the change trusts the compiler/optimizer more than I want to. - Slight loss of generality. The "before" code only assumes that the RBAUGMENTED field can be compared using "<" ; the "after" code also assumes that the minimum value is 0. While this covers the current uses, I would prefer not to have that limitation.