Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6830279imm; Wed, 27 Jun 2018 14:17:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpep0pvPKL0LgyC0ZJabdIlqQkaPFG/H1ib6VC9tSAxvDuQiP/eHep/lOKhz5R4E1L/bqFKa X-Received: by 2002:a62:6502:: with SMTP id z2-v6mr7431467pfb.76.1530134243246; Wed, 27 Jun 2018 14:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530134243; cv=none; d=google.com; s=arc-20160816; b=LBBdKwR9i++UNeE1t1HQOiC1ZdjMMk0hTKGoTANzs30829xgWWZrKmjbZWRduy/xg2 UY4Xc9E+cBwQWARIuza7GEsy68vmvf5vCCT0YP0xUzDFB3WmIV6kLc4OJjIQm6AwCeip 6nM5KnaannsN1Qz21+NP8MRE1bIlQ4Pow0QF4eatiCQVkFR1UNQjUw2gpnFOsvZKziTv HbOsg74qFe8JCUncL+Oec4v6k4Sr7EfPICHiYRgoXX9jIULWTvaLMCRC7sExLlaYtPUc HOpkJUO9spkJv9KS51iG204Phmpsk3vc7F9MM4pRs4MC70n+T1XrVgCbm260hQit9rl1 xvAg== 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=n02HbZ5GdX4Zg6sF8woUAQ/QFmFDK054C8kGwAgQ4dQ=; b=N9ZB9DftJBYRYVw9kdp0qhK1ULWqg2UABTuztpPBJycsqpoGE833CrcM8ThpKA4+DU VBhwrZZmALtD6dwmmfMJe4Yx3Ognw2Ezib8Nn1vlHQDZhivQAR5l94oIfaf1zOz1lgZx JGDKeD+usKF9AjI/GH55f6JoNBq8lHtDpNhsnE+jlVkrfEUH3kWy2jIMWaRJq646lfch g6JXUiVQHzN6ra2yloxBr0d39cIPprmslpyqSbchZ5UQtxZLcyCH4WMkut3If8IG82cv sb333Vd9NLIiiVHa9ivh0QceRmpyGP3Et9TWupZy+hL0P3JThXzHb/o2LPhAR1iiAFZw VJPg== 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 y40-v6si4844344pla.470.2018.06.27.14.17.08; Wed, 27 Jun 2018 14:17:23 -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 S966186AbeF0THM (ORCPT + 99 others); Wed, 27 Jun 2018 15:07:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42634 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966048AbeF0THI (ORCPT ); Wed, 27 Jun 2018 15:07:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E9FE8D751; Wed, 27 Jun 2018 19:07:07 +0000 (UTC) Received: from redhat.com (ovpn-122-22.rdu2.redhat.com [10.10.122.22]) by smtp.corp.redhat.com (Postfix) with SMTP id 44D152156880; Wed, 27 Jun 2018 19:07:05 +0000 (UTC) Date: Wed, 27 Jun 2018 22:07:02 +0300 From: "Michael S. Tsirkin" To: Linus Torvalds Cc: wei.w.wang@intel.com, virtio-dev@lists.oasis-open.org, Linux Kernel Mailing List , virtualization , KVM list , linux-mm , Michal Hocko , Andrew Morton , Paolo Bonzini , liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com, Rik van Riel , peterx@redhat.com Subject: Re: [PATCH v33 1/4] mm: add a function to get free page blocks Message-ID: <20180627220402-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> <20180626045118-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 27 Jun 2018 19:07:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 27 Jun 2018 19:07:07 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 Wed, Jun 27, 2018 at 09:05:39AM -0700, Linus Torvalds wrote: > [ Sorry for slow reply, my travels have made a mess of my inbox ] > > On Mon, Jun 25, 2018 at 6:55 PM Michael S. Tsirkin wrote: > > > > Linus, do you think it would be ok to have get_from_free_page_list > > actually pop entries from the free list and use them as the buffer > > to store PAs? > > Honestly, what I think the best option would be is to get rid of this > interface *entirely*, and just have the balloon code do > > #define GFP_MINFLAGS (__GFP_NORETRY | __GFP_NOWARN | > __GFP_THISNODE | __GFP_NOMEMALLOC) > > struct page *page = alloc_pages(GFP_MINFLAGS, MAX_ORDER-1); > > which is not a new interface, and simply removes the max-order page > from the list if at all possible. > > The above has the advantage of "just working", and not having any races. > > Now, because you don't want to necessarily *entirely* deplete the max > order, I'd suggest that the *one* new interface you add is just a "how > many max-order pages are there" interface. So then you can query > (either before or after getting the max-order page) just how many of > them there were and whether you want to give that page back. > > Notice? No need for any page lists or physical addresses. No races. No > complex new functions. > > The physical address you can just get from the "struct page" you got. > > And if you run out of memory because of getting a page, you get all > the usual "hey, we ran out of memory" responses.. > > Wouldn't the above be sufficient? > > Linus I think so, thanks! Wei, to put it in balloon terms, I think there's one thing we missed: if you do manage to allocate a page, and you don't have a use for it, then hey, you can just give it to the host because you know it's free - you are going to return it to the free list. -- MST