Received: by 10.223.176.5 with SMTP id f5csp2475276wra; Thu, 1 Feb 2018 00:59:42 -0800 (PST) X-Google-Smtp-Source: AH8x227CwsfjTVkk2sDIGzWpu0g2AoIqaIoLaO02W850NaiZpiBsZMt8yVP0aUg4NBoUQPO9kKh8 X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr2640124plb.235.1517475581960; Thu, 01 Feb 2018 00:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517475581; cv=none; d=google.com; s=arc-20160816; b=tdkC50x4yufMYzpxmIbkNmm11huBkogLhS6LQwcsUg7+an0NA0RT6JZRSXeAx7f0kA NQoj1WIYmDK3O1i2LuAcJFWaHDRKxcifqDnWCDaKHP+RXgk22H1VBBa21oDqv0L6O4rT JCbUJlgboYh5Jno03JnFVNJJm0LKjrfdFR85SzlpFU1414I8l3w839+sjMmCOq6vIXDq u0F4lluVrn03L3yHkzvqpO/aO4B/0wf6O5hp3p+xnUl53cE1n0KRhKJwpsO0OTGwBTNF i3egrE8nGlTTeoQMe18OFXQTUMwTZoZWDvRYiwMzu4KXFHnlyjqKozdLEGQljdmZuXXi gjnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=r0wPtLKd9vTYGqEtwqReHZBDoY6XCbsUBsAV0UTu7Os=; b=sQjQNGfUpYiv1PcLrZgPOHzFWN5gThNV37dbhQCuUhUhDtv1twffpcfVbFegLLw4T0 KuxChzWeFjysnXhymEQjOzHLndPZFWM9kQBH1M7wy9gHpFG8ZMLxqDInZB28ojyx3ISx 73c3i6k9HMgfIRb7rKLXU+JP8OLc95a7IKzMUI4DR6RSyGW2/7yUdjFYGZzxeMcJ2aw3 mD0/mVc4m6ig/f66W2jN0AkO/RBC05sxygsxtOFvv4SarvVenk4qmxyOiC0RvVIpnr9l 3ti6da064QScMZlDsoL0VPXqxQip6NLQE7HaJT7ysCY7qz788QpTI+mP0QDilg5SORMp luhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nHNMmNsH; 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=NONE 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 l36-v6si1759461plg.7.2018.02.01.00.59.27; Thu, 01 Feb 2018 00:59:41 -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=nHNMmNsH; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752013AbeBAI7H (ORCPT + 99 others); Thu, 1 Feb 2018 03:59:07 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:40979 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751520AbeBAI7E (ORCPT ); Thu, 1 Feb 2018 03:59:04 -0500 Received: by mail-io0-f193.google.com with SMTP id f4so18378208ioh.8; Thu, 01 Feb 2018 00:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=r0wPtLKd9vTYGqEtwqReHZBDoY6XCbsUBsAV0UTu7Os=; b=nHNMmNsHj1CVezquKnjO39YJb0+hK0D+1km64Fql0hHmiGELDbbDXD2UB2z4bxaey/ 6gB2xXUvbWVw2aYhZY+aFVHQXvkF2PeWtCdJGXrqZn8IlAMEy+DF+Q1Z97zuFYaGSKsI GylYhydOTz1q1QJubtpcgi1EjSkIzCOIBNrSruVL8Tf0l+iAGMVqXcnIKisK0A49VxPG ZMorIKOJjiBuf5tFCyVpUuT6ezDSQzXAk32u2CymZyoppVOoI8uGOrf1hg+5voUjChlq dAGNxh8LUSm9aBDvnchi9ApwgojKqMKoTSk/MSD09XWvaofttjoKUW4U/oESkNATSwh4 afxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=r0wPtLKd9vTYGqEtwqReHZBDoY6XCbsUBsAV0UTu7Os=; b=WhRXMYyyIDtVltPOWs1yCmAlHO0uJbMWeaDULx4g6e7ob+HeEHss+3uTALE3mcHNip 6pq1ZMMMh4f8L0pKA4UThtpCnEOJBQUBp9spWiJqaZOCvP9HHdsSbxn73HYvspFrHVY3 xzLtv/zsvmZDqGm04K3YgH0FP8IPpIB2EEwr2zQOYzKI9Rav0mnGaQePgQ9Uib4/upo3 dE5LnM2VX5X0YWcb8cePhlrBDHJtdS8O7L2yzyM+rnhkFMfKJ1hB0vIM5XBof6qOSxd0 PGSOUOYpZp8x17harYuZxbD2ARW5bTpOi75hKocm+cQ21cFITas5bF2KoQZHSrTQANAn +Gkw== X-Gm-Message-State: AKwxytc4RVKuzbfO60/h6+DY3MWQTMoMr/aP3IzHFG9GUrpranS1gJK9 vvt1WnUVX9opakh3158osrE= X-Received: by 10.107.36.20 with SMTP id k20mr36664646iok.143.1517475544157; Thu, 01 Feb 2018 00:59:04 -0800 (PST) Received: from [192.168.1.70] (c-73-93-215-6.hsd1.ca.comcast.net. [73.93.215.6]) by smtp.gmail.com with ESMTPSA id v190sm1390738itb.3.2018.02.01.00.59.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 00:59:03 -0800 (PST) Subject: Re: [PATCH] of: cache phandle nodes to decrease cost of of_find_node_by_phandle() To: Chintan Pandya , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <1517429142-25727-1-git-send-email-frowand.list@gmail.com> <5b84a166-c71b-3a41-9e7f-a7624a8441f6@codeaurora.org> From: Frank Rowand Message-ID: <38cdcae5-ec0f-d1be-b024-1990d4387731@gmail.com> Date: Thu, 1 Feb 2018 00:59:02 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <5b84a166-c71b-3a41-9e7f-a7624a8441f6@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/31/18 22:45, Chintan Pandya wrote: > > > On 2/1/2018 1:35 AM, frowand.list@gmail.com wrote: >> From: Frank Rowand > >> + >> +static void of_populate_phandle_cache(void) >> +{ >> +    unsigned long flags; >> +    phandle max_phandle; >> +    u32 nodes = 0; >> +    struct device_node *np; >> + >> +    if (phandle_cache) >> +        return; >> + >> +    max_phandle = live_tree_max_phandle(); >> + >> +    raw_spin_lock_irqsave(&devtree_lock, flags); >> + >> +    for_each_of_allnodes(np) >> +        nodes++; >> + >> +    /* sanity cap for malformed tree */ >> +    if (max_phandle > nodes) >> +        max_phandle = nodes; > Shouldn't we speak up about this in kernel log ? May be WARN_ON() ? Probably not. If we care enough about a hand coded phandle property value we should add a check to checkpatch and/or dtc instead of adding the warning here. >> + >> +    phandle_cache = kzalloc((max_phandle + 1) * sizeof(*phandle_cache), >> +                GFP_KERNEL); > kzalloc (might_sleep) in critical context will break. Yes, thanks. I also need to ensure memory ordering in of_free_phandle_cache() to ensure that max_phandle_cache is zero before the cache memory is freed. > Anyways, will fix this locally and share test results. Thanks, I look forward to the results. > Thanks, > Chintan >