Received: by 10.223.185.116 with SMTP id b49csp6499291wrg; Wed, 28 Feb 2018 10:24:18 -0800 (PST) X-Google-Smtp-Source: AH8x227jNSHtwb9aiImehaO63wZf/dnVEcHJ7ZHWJ3SUgOZsrsqDOAMRax8+vOUsmd78aHEcZIkp X-Received: by 2002:a17:902:aa0b:: with SMTP id be11-v6mr18766024plb.250.1519842258350; Wed, 28 Feb 2018 10:24:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519842258; cv=none; d=google.com; s=arc-20160816; b=AI5M5SEiQWhrxdWdn2W26q6JCjbgIutcBQGr32ZygkKiKNHt5x+OgxGgWDuiMUO9DZ bVGGnETw4ngBcYLnj+8dkSLREcayuihC9saqw089Cf7YILEeZaSL2l6VfPZl1PyhxWtK 3kSbdx2SoaGc3KkYBaW5wUoyJxlLnEpt9OYIxtOGiVx0rEXlfeEv3Ol/8j7WGeQEi02S yEkLWYBpkEFh9wu+q+IBl6zemVwNgNJ3vot6JuXciX3cyhr4QNrqu9SJJS/IUUxHZVZU lnYmSHniIEsKRbKhouEccsgvQ1RzSfmKrpZVcriCDaEP0HbD/Oe1F9xScB2vE6XRRtBG aX5w== 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=NXDqe0POiiQCMlTDW06AUe0XEybmL+ETaI2qqlHK2qo=; b=lKxWAs8J6yIzjsoEMSzctpy7xQMuzfSvzKLBSUtHNAoiXAbJiTMoXgMddheaT+KVmr IHWu5bPGQ8E5RYF7rqKVrnQDYoSazoYwMTrfF6mFYVUSw2JaAsQKIK2vqMG548GIwGZB 738ocK6U65OGLMqXp6IXmThkfT/DLPyHyhp1ZkycSz6DwFAlQtnwbiwjzwnAgcQpxyvd 3SFH3Bz7eLc2xJx6V1pLi7yZnbinevSIrsSJ5GRspUUXe1xmXlWESQcrkYv1B5x1kPF4 /gIVZg62QzGvSDsC5ZPeHSDZ93GRjVaY4JbQobaB4/CTZpQt1SlRGquQ+uclt8TVk6Fl HjAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AOYel706; 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 m2-v6si1655178pll.93.2018.02.28.10.24.03; Wed, 28 Feb 2018 10:24:18 -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=AOYel706; 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 S932679AbeB1SWo (ORCPT + 99 others); Wed, 28 Feb 2018 13:22:44 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:32869 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932126AbeB1SWm (ORCPT ); Wed, 28 Feb 2018 13:22:42 -0500 Received: by mail-pl0-f65.google.com with SMTP id c11-v6so2015888plo.0; Wed, 28 Feb 2018 10:22:42 -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=NXDqe0POiiQCMlTDW06AUe0XEybmL+ETaI2qqlHK2qo=; b=AOYel706bzp/YlUB5EycS0hQ5Nk18t68rxoHxvmqbCFqdcQkiQD8bf87Z5tyHRBRvZ nVF6+7aeMQ1nxOzCxj2isDMktdocjWH2lroOXbjDC8+LgiMpORHJZjO2gx6/LOz1K7KI K3BEcJKRoB8ZkXFUK4BwrBxttSQZauscY2v5GkFKKwaGP/FWjCfKy8SDjr99pdlyBMHT UraozInjQmNOeA0Uf0VKQb2PAiuxpCtnH5MpXi/nHbsus7JhgyflaR1F6q38vUcP1Cuq AlX8jxx+Nb3rs61ERfgAkwcQOD3omJu00jik/NANZ38TgppqYrZ1YJwZdP5X1qYw/RHH mxkQ== 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=NXDqe0POiiQCMlTDW06AUe0XEybmL+ETaI2qqlHK2qo=; b=jyFVta9qIfr+tgiJ/PIUAlHRDlkHBP3pAhREe5Bot/DIRcjZ4UJ10GRp61qJZnv3Z7 2dIaQuOpn7Ntr1OeO6IUId+8Vw0gqbLa/rtK+i+MKFDHtRf5aOxGMgc/vsNgaEucvGyC 1zN/ZieCj+DACEpnx5TLq8Fqy4JXAcQOePyBmNiR4vb2GAZCaoCjGKUyzY+aLYH7UYTW aRpQTcTfvL0ki4tttveYu/sFwXc0s5CvWEu5tzf5PFaYeyu7IMUJRwOnyv5wIHPABSts KU7tJH/TjPB92E6jjAvO5s3HnIpa7rruZckCmS7NtQVxv48FF/5oSh1VKn4Ws3Perosv QlfQ== X-Gm-Message-State: APf1xPCMR/MccJZnQRyJF05Jkxxbxkb09LZIY3H5r2AFLOQfg/Ozqhik /2aWdB37B7iw3WvyNwVZooI= X-Received: by 2002:a17:902:bd41:: with SMTP id b1-v6mr11886252plx.147.1519842162122; Wed, 28 Feb 2018 10:22:42 -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 p128sm3766751pga.45.2018.02.28.10.22.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 10:22:41 -0800 (PST) Subject: Re: [PATCH v3] of: cache phandle nodes to reduce cost of of_find_node_by_phandle() To: Chintan Pandya , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <1518655979-10910-1-git-send-email-frowand.list@gmail.com> From: Frank Rowand Message-ID: <22ed033d-fd35-7f06-39e3-075c500492b4@gmail.com> Date: Wed, 28 Feb 2018 10:22:39 -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: 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 02/28/18 05:27, Chintan Pandya wrote: > > > On 2/15/2018 6:22 AM, frowand.list@gmail.com wrote: > >> +static void of_populate_phandle_cache(void) >> +{ >> +    unsigned long flags; >> +    u32 cache_entries; >> +    struct device_node *np; >> +    u32 phandles = 0; >> + >> +    raw_spin_lock_irqsave(&devtree_lock, flags); >> + >> +    kfree(phandle_cache); >> +    phandle_cache = NULL; >> + >> +    for_each_of_allnodes(np) >> +        if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) >> +            phandles++; >> + >> +    cache_entries = roundup_pow_of_two(phandles); >> +    phandle_cache_mask = cache_entries - 1; >> + >> +    phandle_cache = kcalloc(cache_entries, sizeof(*phandle_cache), >> +                GFP_ATOMIC); >> + > > NULL check of phandle_cache would be good to have. Thanks for catching that. >> +    for_each_of_allnodes(np) >> +        if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) >> +            phandle_cache[np->phandle & phandle_cache_mask] = np; >> + >> +    raw_spin_unlock_irqrestore(&devtree_lock, flags); >> +} > > > Chintan