Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2939137ybl; Sun, 11 Aug 2019 11:47:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCemIZBpAdsqpAZR72Y98YXQdZ+4PbwC8FsWgppow0cHzyKTVbCZmGPYlybXUQkRPDXJL8 X-Received: by 2002:a17:90a:c70e:: with SMTP id o14mr15579734pjt.56.1565549260778; Sun, 11 Aug 2019 11:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565549260; cv=none; d=google.com; s=arc-20160816; b=xaAb4YTJg6suTcDahaouL3Yf89BXk1nb6w92yM0YtP+WeYpa7gMoFf0j4vuAn6S4v5 jqz3bmCsecZx7T8tjsAzmiYFEcpz6cyMpWhozjhjGNrzl+QyFKcZDGex/fEqs2TXzXEc xU5GtkEUAE+YgJo5LyEAWb9QfWcXJ11LwcF63WZqggyuJaLH2vojvmcseawb8NRD9NP0 p7v3KIO7yHXdhGp7l7KyWlkB0xsPj+mskuBYKQRUyoxahg4aCF5E2gpfOHCY7tqisGVh OhJaZ2nY/vq1a/1laitaWGFytoC35SzY0lF4ATIedHgyZIi4fNilWDwv2rdfijcaQQEM egVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=sHzzzA2xQ402RWvU0Hu0IKz3pQGvFb+F2/QvqTcdhf8=; b=0za+kGWr8fduG6IF9X02CswOhy6mT4v35PZGVRqukjZ25753f1LcDO4X7mkD3hm/oK ZSPDFqOIlNxdRXCZc2j+2BPmi5xFDcuMPAJimwpVmPBIuH2xThN9iRL/jjsK2tKR/ldU vdO9zWyxwVXfXndngJC6not7nFu872HKhrSrRdgF9VvvWWnecY2V4w/pafc4psxLx2HG UN2l7Uu6ez4rwRrJdO8zWq/bna+xg4X7YaYtmSQsgjcf33wUiuEbCjvvViCjOhq+JQwU yMWpcakNtvys8pyMzV1m6FvNUmanVGXgVkFv9gGTJUA2fFl7BvhDV/ShChCl/fCl3S6Z ffhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OS4OCsP8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15si63946390pfb.28.2019.08.11.11.47.25; Sun, 11 Aug 2019 11:47:40 -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=@gmail.com header.s=20161025 header.b=OS4OCsP8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726477AbfHKSqb (ORCPT + 99 others); Sun, 11 Aug 2019 14:46:31 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:45634 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbfHKSqa (ORCPT ); Sun, 11 Aug 2019 14:46:30 -0400 Received: by mail-lj1-f195.google.com with SMTP id t3so7903989ljj.12 for ; Sun, 11 Aug 2019 11:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sHzzzA2xQ402RWvU0Hu0IKz3pQGvFb+F2/QvqTcdhf8=; b=OS4OCsP8BenhY51p8Ak6rLYx4nCshsn6TVflf7rjLCbw1BgGGoFNcGyLh2d1XIwIv3 CqpNm2hBHMWtealt8suXi5VqYKlCHgoBK3yIWBcTQ6d1Bxx9+U/B8WITXCMCVwauWKgv M1jUOKF46HqhGVZuPcW+n5HesWClcxctftF/m4cU+uusN1I5uyeOPgH/l2Bvea0mbZmb xZwTCqBcTbL5PwVPiSZksFX56bxzIg02REWywzbZWohvsfAs1N2/yAYi0HbTEjVtH2Zu IU/cJK3SEA2GPlbZa0WPk3svaJ+z6tVRWVjuktLxxIeB5fOaBkj+Np+rll68+9+uxmyn xKSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sHzzzA2xQ402RWvU0Hu0IKz3pQGvFb+F2/QvqTcdhf8=; b=AGkLtlYZzVOon9Jd5a1v/OVPN5gR1+JoCwpzX3N5QguQlkgTB3LT0OlHfMpkKiaBjR Ba5FYvme6JnNjEw1/RwAEwJoek0/8yqjaqP3l0UUmowhb68gtJzrk9KdQB3xEOJVKSbg YMOul2eMDKZqBhp++6QrSytEzU2sw4vSVj0+SKpY7YGxA0Tr4voG8wAq1jmnFYZC2aVg OWy00npY4wzCNHtM9YI9izUKgajeWUq00HojgmMQbKFFDMLumv+ojOjrbgO/iVkeCL0N rUCbtWJN5AjdqhG2FQjunRbQ5FSQsmH8TGOz5G2ErkxzDPZWt8nK5YGR+mDNRkeImcuq vvRQ== X-Gm-Message-State: APjAAAVTREQWolCidQPfpkMOmfAqFL1MlF5/fEKlmlD5KSyonYe4Ud2g FXjzpCo677TdFSevPKDfiOM= X-Received: by 2002:a2e:9d8a:: with SMTP id c10mr16554929ljj.147.1565549188182; Sun, 11 Aug 2019 11:46:28 -0700 (PDT) Received: from localhost.localdomain ([37.212.199.11]) by smtp.gmail.com with ESMTPSA id t66sm1536425lje.66.2019.08.11.11.46.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Aug 2019 11:46:27 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton , Michel Lespinasse Cc: linux-mm@kvack.org, LKML , Peter Zijlstra , Roman Gushchin , Uladzislau Rezki , Hillf Danton , Michal Hocko , Matthew Wilcox , Oleksiy Avramchenko , Steven Rostedt Subject: [PATCH 2/2] mm/vmalloc: use generated callback to populate subtree_max_size Date: Sun, 11 Aug 2019 20:46:13 +0200 Message-Id: <20190811184613.20463-3-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190811184613.20463-1-urezki@gmail.com> References: <20190811184613.20463-1-urezki@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RB_DECLARE_CALLBACKS_MAX defines its own callback to update the augmented subtree information after a node is modified. It makes sense to use it instead of our own propagate implementation. Apart of that, in case of using generated callback we can eliminate compute_subtree_max_size() function and get rid of duplication. Signed-off-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index b8101030f79e..e03444598ae1 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -385,17 +385,6 @@ get_subtree_max_size(struct rb_node *node) return va ? va->subtree_max_size : 0; } -/* - * Gets called when remove the node and rotate. - */ -static __always_inline unsigned long -compute_subtree_max_size(struct vmap_area *va) -{ - return max3(va_size(va), - get_subtree_max_size(va->rb_node.rb_left), - get_subtree_max_size(va->rb_node.rb_right)); -} - RB_DECLARE_CALLBACKS_MAX(static, free_vmap_area_rb_augment_cb, struct vmap_area, rb_node, unsigned long, subtree_max_size, va_size) @@ -623,25 +612,7 @@ augment_tree_propagate_check(struct rb_node *n) static __always_inline void augment_tree_propagate_from(struct vmap_area *va) { - struct rb_node *node = &va->rb_node; - unsigned long new_va_sub_max_size; - - while (node) { - va = rb_entry(node, struct vmap_area, rb_node); - new_va_sub_max_size = compute_subtree_max_size(va); - - /* - * If the newly calculated maximum available size of the - * subtree is equal to the current one, then it means that - * the tree is propagated correctly. So we have to stop at - * this point to save cycles. - */ - if (va->subtree_max_size == new_va_sub_max_size) - break; - - va->subtree_max_size = new_va_sub_max_size; - node = rb_parent(&va->rb_node); - } + free_vmap_area_rb_augment_cb_propagate(&va->rb_node, NULL); #if DEBUG_AUGMENT_PROPAGATE_CHECK augment_tree_propagate_check(free_vmap_area_root.rb_node); -- 2.11.0