Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3404220imm; Sun, 17 Jun 2018 19:17:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLC6WNlzPBtjgpgecjo8wSEoXGs0tO//08Osr6rmF78/Y1p3E8MIQukyounYvc9BwA5DW9d X-Received: by 2002:a65:51c9:: with SMTP id i9-v6mr9527043pgq.202.1529288254081; Sun, 17 Jun 2018 19:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529288254; cv=none; d=google.com; s=arc-20160816; b=sSQPUB7zf08uOHJP9SF83cuZzt43gTUXFJXa0ICin+LdKQPtXzt9Yd1hJn30GKVwuf EisVkj+f0mPU29MPCLQ0B5X2yfZJpEJrH+u6/ohYlhByo02YgMfvQsxVHbe8uT3RjUlf vX8cVNxpoU70Kivfa+G8LPckRplrKizG3luD3eqiMzI6dKghZaUcfc1Bti7S1xZFsUM0 6C+Sp/8kZsAYYJ51+/F3icrtSGecl7Xs8IIPAq/VoIuYxbHUrtKTSy2SFYo636pr0sjI A7748CJxHbcA8RPjtmmCQpuSES8PUmL2GuelpZETDqK2M5ODWyGnzs3O55qknwPLog6D W7mQ== 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 :arc-authentication-results; bh=Ecit9nb6KPZ8TPMo/hy8uk0B6qAXCdlCFnYOCb6EUXk=; b=umSrED2c5QZGrjT4TxTOE9yTiNhRC5zQGi+sqNiBv6okX4Jtl3lo2FQ8OZoXVWdnSW C7YikHtMEIhEmVPa7F4ZFVC/MdKY6U8GEGRPxDnSvvsvHXcm9Phwv5KWuLwdqEu7clww 6smQa22xeHnDUDiSgzWMphbnhSeJp0wpbd1q0hSYWkEjrizl2594ATxRSGkMAoV9k3n6 4xylDkjVeIlPb9jJyG9FhVjLscfn58zSjUS7p1j4km1VYbmoUEgkTdH8ucz/2h5M9gBX YpMqQoXMPeT9CaNnEPuW5aNXt2yX9pukyW4zdK7wXROlOMevqZPOeEpj7zKps6DYshsr X8mA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si13626858plb.100.2018.06.17.19.17.09; Sun, 17 Jun 2018 19:17:34 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754507AbeFRCQM (ORCPT + 99 others); Sun, 17 Jun 2018 22:16:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57280 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754387AbeFRCQK (ORCPT ); Sun, 17 Jun 2018 22:16:10 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 74880818A6A2; Mon, 18 Jun 2018 02:16:09 +0000 (UTC) Received: from redhat.com (ovpn-121-19.rdu2.redhat.com [10.10.121.19]) by smtp.corp.redhat.com (Postfix) with SMTP id 43F3B111CB82; Mon, 18 Jun 2018 02:16:02 +0000 (UTC) Date: Mon, 18 Jun 2018 05:16:02 +0300 From: "Michael S. Tsirkin" To: Matthew Wilcox Cc: Wei Wang , virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mhocko@kernel.org, akpm@linux-foundation.org, torvalds@linux-foundation.org, pbonzini@redhat.com, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com, riel@redhat.com, peterx@redhat.com Subject: Re: [PATCH v33 1/4] mm: add a function to get free page blocks Message-ID: <20180618051145-mutt-send-email-mst@kernel.org> References: <1529037793-35521-1-git-send-email-wei.w.wang@intel.com> <1529037793-35521-2-git-send-email-wei.w.wang@intel.com> <20180616045005.GA14936@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180616045005.GA14936@bombadil.infradead.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 18 Jun 2018 02:16:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 18 Jun 2018 02:16:09 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 15, 2018 at 09:50:05PM -0700, Matthew Wilcox wrote: > I wonder if (to address Michael's concern), you shouldn't instead use > the first free chunk of pages to return the addresses of all the pages. > ie something like this: > > __le64 *ret = NULL; > unsigned int max = (PAGE_SIZE << order) / sizeof(__le64); > > for_each_populated_zone(zone) { > spin_lock_irq(&zone->lock); > for (mt = 0; mt < MIGRATE_TYPES; mt++) { > list = &zone->free_area[order].free_list[mt]; > list_for_each_entry_safe(page, list, lru, ...) { > if (index == size) > break; > addr = page_to_pfn(page) << PAGE_SHIFT; > if (!ret) { > list_del(...); > ret = addr; > } > ret[index++] = cpu_to_le64(addr); > } > } > spin_unlock_irq(&zone->lock); > } > > return ret; > } > > You'll need to return the page to the freelist afterwards, but free_pages() > should take care of that. Yes Wei already came up with the idea to stick this data into a MAX_ORDER allocation. Are you sure just taking an entry off the list like that has no bad side effects? I have a vague memory someone complained that everyone most go through get free pages/kmalloc, but I can't find that anymore. -- MST