Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5136955ybl; Tue, 4 Feb 2020 08:21:23 -0800 (PST) X-Google-Smtp-Source: APXvYqx/i78fjWEdg5jShIaSAT1PleH2V8/Z+5FXtejZmK8jfGQyjlJUr0HVLAtBjNjJbcevQUc/ X-Received: by 2002:aca:fc0c:: with SMTP id a12mr3815564oii.118.1580833283544; Tue, 04 Feb 2020 08:21:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580833283; cv=none; d=google.com; s=arc-20160816; b=ZuKA8q8QSSNo24RWDvz3eKpc8pcqD2g/cO521k9CQPnXQmUNPk5660LHMfkVP6pKfP Fjmw5/GEU4H935Z1nemgpdNWzKG/lZQ5CZJYnSfUSjqRxh6fSYLDqqKr9h89HkTTfioI STM0CXSkbALSu6P/N7wL8FEyP3sbZ2++0yasAibJOsmrQq6OZzTch4GP60cloewoLx58 2ShxNO4R0lD6yEvwVE8K42UN5D8LyM2hAMhEQ//lz9oR4QnE5YuxT/13KAwW8s62/N2o QrntykoKLVu5TUjxcb3EtvVjoqs4QfIdWv7IU1wWQv6CNdUGXvycG5CXmg39G9l2IFF4 QcRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=PT7vPWarEHDsIUc2odV/J4yWLWhlmm5spUk2ZPWObf8=; b=PgrUb/FtKK4FNGulkWKyBqfLu9P16oPPVxQfGkv35VP1flqvsLUwGp08zH6LXjIsGi xeiSWgc2lim4xMFNNCjikDkcb7Kfq5TJaZ2df4j/9IZ6h59YYqWqTkqyNdvgf1OHVDuH mJHPTLoxoLEIcTr5iEFxbzTCT+DgrgQyEYGqAQ6BVaudHahuOMzR/mXbgd+5pSzXD4LF 40x63Prlf/EDM8Gvx6yg2DUvoQ/+70HPFbM5/XsX5tTTp9KrSLvhoWUWgWCZBlj5PY1S 66qkT7qpqzlWDtE4Dxbstn4ADPhwhMB3ayUOP7Y53TlII0bztXcc5IMeoVF4lD3p36vG flsg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11si10721303otp.285.2020.02.04.08.21.10; Tue, 04 Feb 2020 08:21:23 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727394AbgBDQTQ (ORCPT + 99 others); Tue, 4 Feb 2020 11:19:16 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:3773 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbgBDQTQ (ORCPT ); Tue, 4 Feb 2020 11:19:16 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 014GBUUq070878; Tue, 4 Feb 2020 11:19:08 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xxm9e3xc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Feb 2020 11:19:08 -0500 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 014GJ7wb117859; Tue, 4 Feb 2020 11:19:07 -0500 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xxm9e3xax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Feb 2020 11:19:07 -0500 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 014GI0ml015994; Tue, 4 Feb 2020 16:19:05 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma05wdc.us.ibm.com with ESMTP id 2xw0y6tse9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Feb 2020 16:19:05 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 014GJ4aP13173466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Feb 2020 16:19:04 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA97828058; Tue, 4 Feb 2020 16:19:04 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF8E82805E; Tue, 4 Feb 2020 16:19:04 +0000 (GMT) Received: from localhost (unknown [9.41.179.32]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 4 Feb 2020 16:19:04 +0000 (GMT) Date: Tue, 4 Feb 2020 10:19:04 -0600 From: Scott Cheloha To: Nathan Lynch Cc: Nathan Fontenont , Rick Lindsley , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Michael Ellerman Subject: Re: [PATCH] powerpc/drmem: cache LMBs in xarray to accelerate lookup Message-ID: <20200204161904.62gpevnygu2pzdnk@rascal.austin.ibm.com> References: <20200128221113.17158-1-cheloha@linux.ibm.com> <87pnf3i188.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pnf3i188.fsf@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-04_05:2020-02-04,2020-02-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=1 adultscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 spamscore=0 phishscore=0 clxscore=1015 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2002040108 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 28, 2020 at 05:56:55PM -0600, Nathan Lynch wrote: > Scott Cheloha writes: > > LMB lookup is currently an O(n) linear search. This scales poorly when > > there are many LMBs. > > > > If we cache each LMB by both its base address and its DRC index > > in an xarray we can cut lookups to O(log n), greatly accelerating > > drmem initialization and memory hotplug. > > > > This patch introduces two xarrays of of LMBs and fills them during > > drmem initialization. The patch also adds two interfaces for LMB > > lookup. > > Good but can you replace the array of LMBs altogether > (drmem_info->lmbs)? xarray allows iteration over the members if needed. I would like to try to "solve one problem at a time". We can fix the linear search performance scaling problems without removing the array of LMBs. As I've shown in my diff, we can do it with minimal change to the existing code. If it turns out that the PAPR guarantees the ordering of the memory DRCs then in a subsequent patch (series) we can replace the LMB array (__drmem_info.lmbs) with an xarray indexed by DRC and use e.g. xa_for_each() in the hotplug code.