Received: by 10.223.185.116 with SMTP id b49csp2025422wrg; Sun, 4 Mar 2018 16:18:45 -0800 (PST) X-Google-Smtp-Source: AG47ELsiiVNvtdsj1vLURbvDgJk1GsGAOwg6W/EzDYhx29MuJnbuQZ5+OP4TValJThAKKRBoD+eN X-Received: by 2002:a17:902:5ac1:: with SMTP id g1-v6mr11030089plm.255.1520209125425; Sun, 04 Mar 2018 16:18:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520209125; cv=none; d=google.com; s=arc-20160816; b=L3UFumIm0HBGVxdeN1SZlkE9hnt3jXtc+L33SMhH9GknH3YplTE+YUtqL+6JntyRLQ zkbvzAw3+l3xbaC/w2c1Q4wUVdRMHG2i6FjW+0lwiyICt/ZwwT1ksD0d6uDBPPZN0hqA 21+ffjPi45QHnoY4ZynAFSEEpaN5aMzyFWhJcFwnApJT5dIZCllFUzjmTv1kSEvl0w5a bbH2OZ9Sm9MoeLtyIp71lUct/IIMLKJ7CPt3A2fldY1bXL03IrBRtg9do0DWrp2F/AQq 5/W40JREA3w1nW1FrNYKjbn5/2dPINhKcyxE2YPuE7k+MHsjRKNSVExVsP0eIQAXfAvU Z34w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Apqn7A8Tq4hqVH1oFmCNbrrZ0ZogJ3lLgW8S05fYFbw=; b=quncuVN7+Oz0MtNvVfLyvCU1mQQcfhu2DtpuTQh53SHT8ep1S8ZJZsxqsLThxWIj+C OYbxeVeq95H4WMCnCm3uG8619MFY5B4HjQEepjFLkizpvKCRLNYdQVHbGL25EZsW2UrY OZuTVZ8kyS9hLwg/CI77Lf82aqR6RaeRakdujAAKyKvlQ0Nv0GTYNYXlf1LyxIEXKLS8 IdOiv1F5RvH4Lm0woTOjU3MVtVuz/hFERceqzeya1P7fM67Sig4w2v/FlLKnjXrVbFxK Aw2PU/GDePvZCC/IXyBPPGZLcarr5T/ENwMWDQEG1f/jxgT8nVoM+bvqX2TMBhVOwgKj geUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LOTHfUxg; 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 y184si7632861pgd.291.2018.03.04.16.17.55; Sun, 04 Mar 2018 16:18:45 -0800 (PST) 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=LOTHfUxg; 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 S932475AbeCEAPj (ORCPT + 99 others); Sun, 4 Mar 2018 19:15:39 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:38637 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932350AbeCEAPg (ORCPT ); Sun, 4 Mar 2018 19:15:36 -0500 Received: by mail-pl0-f66.google.com with SMTP id m22-v6so5184333pls.5; Sun, 04 Mar 2018 16:15:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Apqn7A8Tq4hqVH1oFmCNbrrZ0ZogJ3lLgW8S05fYFbw=; b=LOTHfUxgoCBgP1vIWaXNXvoOpeQNC5HN45d/xYqirRyTN4P2zFhu/XUDRtOzwjGoiR 6Y9MzCS1i/hP2AqN6M6ASyhRCFQFtQZjqsjkMt3YY1yRmcaUAk3EWGRQhmWBkOJZT13A K3iUBOyQ/IufFRYGwJxhF+15mHTepQSaQaYCqwXYgMFA9iGLJgJJtgWhYzSV/aS79Ier Cc7V2uz0Qnb9ND2ht2E62q/5cAezIoRC0URc9b1Ndhz3KrueJBtm+y7dRZbsQ8+Oyv6h oh5QrTRADjnt1YfB9CbiKsYT/CuAiFbaUSR+dU3W3dx7n/ckPDQzjZZUbrjlrZxzDB/h jFhw== 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; bh=Apqn7A8Tq4hqVH1oFmCNbrrZ0ZogJ3lLgW8S05fYFbw=; b=HHY80poFMH01zR9Q0NZTylPxEhZca5x8EBlS06RA44BtLWjeIrZzxC2TppCkW6wGDs dL2sSwmNW+Ft6PaKUILIiUnC9MDezBB7NtxWTedi1irCWtZJWczL2nHXeMY8R6I3e8oQ bkGrJdBt0CnFPVSFXiN1XXi1BRnZvslmcSJq/qcFrFDYIivKIhoHGtTMUahd1uYYfHcL vET4nKPHlNB0eihBdUtk8dqscKU7/CLzLuv+IV5PghTHGgUlIN+pc75TfcO/AtxDaRR0 xYnHQuLwiAdDIOGtN7pAoSQeX4Tv2k9RYSReCnc9FYdZOuiwp+XLsZeI2Wa+JdS87rem AJ+A== X-Gm-Message-State: APf1xPAfDhv78fzBCo5AILCTu7UkctateFEcjpZAwOyFJCJHX8WbMWfJ MvebufmOycNAv00bcNj0K7FYMw== X-Received: by 2002:a17:902:167:: with SMTP id 94-v6mr11489950plb.294.1520208935992; Sun, 04 Mar 2018 16:15:35 -0800 (PST) Received: from localhost.localdomain (c-73-93-215-6.hsd1.ca.comcast.net. [73.93.215.6]) by smtp.gmail.com with ESMTPSA id c7sm23113891pfg.36.2018.03.04.16.15.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Mar 2018 16:15:35 -0800 (PST) From: frowand.list@gmail.com To: Rob Herring , cpandya@codeaurora.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 0/3] of: cache phandle nodes to reduce cost of of_find_node_by_phandle() Date: Sun, 4 Mar 2018 16:14:46 -0800 Message-Id: <1520208889-3908-1-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frank Rowand Create a cache of the nodes that contain a phandle property. Use this cache to find the node for a given phandle value instead of scanning the devicetree to find the node. If the phandle value is not found in the cache, of_find_node_by_phandle() will fall back to the tree scan algorithm. Size and performance data is in patch 1/3 comments Changes since v4: - Add patch 2/3 "memblock: add memblock_free() alloc when CONFIG_HAVE_MEMBLOCK is not set" - patch 3/3 (previously 2/2): add checks for zero returned by memblock_virt_alloc() Changes since v3: - of_populate_phandle_cache(): add check for failed memory allocation - add patch 2/2 into series instead of as a standalone patch that was dependent on patch 1/2 of this series Changes since v2: - add mask to calculation of phandle cache entry - which results in better overhead reduction for devicetrees with phandle properties not allocated in the monotonically increasing range of 1..n - due to mask, number of entries in cache potentially increased to next power of two - minor fixes as suggested by reviewers - no longer using live_tree_max_phandle() so do not move it from drivers/of/resolver.c to drivers/of/base.c Changes since v1: - change short description from of: cache phandle nodes to reduce cost of of_find_node_by_phandle() - rebase on v4.16-rc1 - reorder new functions in base.c to avoid forward declaration - add locking around kfree(phandle_cache) for memory ordering - add explicit check for non-null of phandle_cache in of_find_node_by_phandle(). There is already a check for !handle, which prevents accessing a null phandle_cache, but that dependency is not obvious, so this check makes it more apparent. - do not free phandle_cache if modules are enabled, so that cached phandles will be available when modules are loaded Frank Rowand (3): of: cache phandle nodes to reduce cost of of_find_node_by_phandle() memblock: add memblock_free() alloc when CONFIG_HAVE_MEMBLOCK is not set of: add early boot allocation of of_find_node_by_phandle() cache drivers/of/base.c | 124 +++++++++++++++++++++++++++++++++++++++++++++-- drivers/of/fdt.c | 2 + drivers/of/of_private.h | 5 ++ drivers/of/resolver.c | 3 -- include/linux/memblock.h | 4 ++ 5 files changed, 131 insertions(+), 7 deletions(-) -- Frank Rowand