Received: by 10.213.65.68 with SMTP id h4csp795323imn; Thu, 22 Mar 2018 08:43:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELs3XOaH//iwUuVqURG+ddQnBfb4469XwFzF9PAr1bQHquXAk+8B9bTYasQTo5wdPjxoy8mA X-Received: by 10.99.110.6 with SMTP id j6mr17789524pgc.29.1521733428963; Thu, 22 Mar 2018 08:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521733428; cv=none; d=google.com; s=arc-20160816; b=q8lRHQatcyNNDGbGqG9ZAx4TL8NqZQkpA63hxU5eDxjnqEgDmwvZl/5keoRH/lIrQj 9hw60wk8T+NF0LZbpleqeIgCibwjhOsx3OmfUrgirs14I2Dj5A7w/U33fTH10femNXZ/ zepNvfd8VfW2AnBKOo47eFv5Ear9EI7sgj2v9UwyTiGbHpx0IjV6Y7u6A4tu2wyQN4NU 7saW4A/ffS0cZ69KBNkh1bVQqIkU7tO3S7qlHLmb2W+eUZEXPleE/jpXCFA25vZxp3X1 AODA1cqasCypfsGYOsTBVM2J/YP4AfbYSBPPxM1ohXKSKWlgNJjBLn10KVkcPaLhLSQc a1yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=gB8QjihUaDS9eUiePM6W3Ni39eIUfae2mQ5YC9tmZmw=; b=VMU9OOEwR3cKs/0rIisrpkNaX59rs3/NdosnfMV+T5YVutiQr/M6DBLWUvZ9pgfZaN Kr0Uc7sxMFXHK6SUm821/js9bFj7i0YFdblVXJHpQzhThpV9mLX450WpC4ZT9PGK2Xtl xSGe7jdxlJolzi6NTupjUb6jOoLTDXdeH4qIUaR4PNe2oiq3v5t7xkXDdUuaBff0DiGj DFgard7zNWCO9Wr0zDdy1zLApbnXdOj+ujnfAGTrc4CLjQ8j1a7wMB1fELn+G/3untOf tgBV4bhpGxGnlZ1PKfzW7OZa2q0JKiaa2dOKSvUY6o8ANnADGRfYvpLfJHqXimCcSG93 v2tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kZr0TyxI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si4655231pgo.107.2018.03.22.08.43.33; Thu, 22 Mar 2018 08:43:48 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kZr0TyxI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754047AbeCVPRo (ORCPT + 99 others); Thu, 22 Mar 2018 11:17:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36452 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752895AbeCVPRZ (ORCPT ); Thu, 22 Mar 2018 11:17:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gB8QjihUaDS9eUiePM6W3Ni39eIUfae2mQ5YC9tmZmw=; b=kZr0TyxIKEjDLcEuprAv3E49a ZWnKJkrQV3iWw+/vghLGynWWQK8e5r6vX2rVRbFVb+sBAs5yXdUYFkI2Lrr+P9pPGTqP/XlprSojZ WskTkqOdNONC7y1vTw6sSJH1Rh9or3x+GihN8yFEo/gXX/FkH91uxARZg557a4o1fpln4TCxfsaw7 BuiTHi+JwgSYsjWLcyizuO9JOS16xGT3hU4xhJEOLTjPTA3BSgSVlju9LkWd87L2tjjN8epn7Axoq ++SxZhcmnDft1B4PgQa+yUA9QWwUDMn4K/s3HaryF01QSHGcojgtPG5/I1+Ctegir1WKnaPQ/PhqE o7JNa3t1A==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1ez1xv-00053O-Ii; Thu, 22 Mar 2018 15:17:19 +0000 Date: Thu, 22 Mar 2018 08:17:19 -0700 From: Matthew Wilcox To: Aaron Lu Cc: Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Huang Ying , Dave Hansen , Kemi Wang , Tim Chen , Andi Kleen , Michal Hocko , Mel Gorman , David Rientjes Subject: Re: [PATCH v4 2/3] mm/free_pcppages_bulk: do not hold lock when picking pages to free Message-ID: <20180322151719.GA28468@bombadil.infradead.org> References: <20180301062845.26038-1-aaron.lu@intel.com> <20180301062845.26038-3-aaron.lu@intel.com> <9cad642d-9fe5-b2c3-456c-279065c32337@suse.cz> <20180313033453.GB13782@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180313033453.GB13782@intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 11:34:53AM +0800, Aaron Lu wrote: > I wish there is a data structure that has the flexibility of list while > at the same time we can locate the Nth element in the list without the > need to iterate. That's what I'm looking for when developing clustered > allocation for order 0 pages. In the end, I had to use another place to > record where the Nth element is. I hope to send out v2 of that RFC > series soon but I'm still collecting data for it. I would appreciate if > people could take a look then :-) Sorry, I missed this. There is such a data structure -- the IDR, or possibly a bare radix tree, or we can build a better data structure on top of the radix tree (I talked about one called the XQueue a while ago). The IDR will automatically grow to whatever needed size, it stores pointers, you can find out quickly where the last allocated index is, you can remove from the middle of the array. Disadvantage is that it requires memory allocation to store the array of pointers, *but* it can always hold at least one entry. So if you have no memory, you can always return the one element in your IDR to the free pool and allocate from that page.