Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2773006ybi; Thu, 18 Jul 2019 14:09:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgOeEpLp/y7xvsFu3iJg728O/RajltTZZaC8pljnYRyn2+v+i6k54mHZdYjowI0Nr8E/IE X-Received: by 2002:a63:2364:: with SMTP id u36mr48313808pgm.449.1563484198518; Thu, 18 Jul 2019 14:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563484198; cv=none; d=google.com; s=arc-20160816; b=N1kaWy9Ng/hC27JoVU4xAlE9UKnz0z+4ewnS7ARDGpD5wNYdvwo3beOtg7+OU4lL9Z TrXWoPRxvuz0M9w2gv7uqEL0p0KLk6r8rW73LOR/0vKGSNjLc0xWAaAJ1ZwnkS3Fh7wx ZKiFrldsiGPYHq+9NF87zq0r1MVHCfCIgeOFkWy2z1QphNlhGJx3e4PoQC01iGIZyTdC W7ydldxrgyBn1YWCuLiyxushoVrMyije+hG4Pw9zcFNOxMs/Zn0kuhLe837XpXnc7dSB UrKYDqld8ZMExJ3Oy/kk3IvdMRI7eXSpaIDgLF8lrBLrw+9cUKxII6thv1AezE7/SBC7 j5wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Dyup3V+7x6vR5f0mEdgXHm4ad/gxVODy2UYvXjZtm38=; b=Cstb+jr+YL1Cv7N0mCiOkYoyPIy9dgYAI4zlzXo2sfx4zfjWXd52zpwVPbwDY55DqR C9KY6RbDss/NvioLT95hG8Fx+ft8v1hjfZyA7UB1vUX8AuaZW0Fzd+H3vskBUSQSEwIK sAvCrInmlhA8bUmhvCAM5Oqc1RdXA0cEDXb4L+pKmECgu4QgHB1hIQNHrNyt1TFWSaSB Yf/NIaoTJWwa4CWPPso5PDyqLTv6mmn3f0sclCidOmU1Rcc4FFKJO9QO6qSd685HHjEG T2H6R7XJyW3b3Mls+4TXW6XOzx4el5trS+GAvDkTf1uJF5PuZ+FxVUeuTWVUJ/eGmflD hDIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="g/A6ZSXF"; 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 l143si1252219pfd.162.2019.07.18.14.09.42; Thu, 18 Jul 2019 14:09:58 -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=pass header.i=@gmail.com header.s=20161025 header.b="g/A6ZSXF"; 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 S1728075AbfGRVJX (ORCPT + 99 others); Thu, 18 Jul 2019 17:09:23 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:37193 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727687AbfGRVJW (ORCPT ); Thu, 18 Jul 2019 17:09:22 -0400 Received: by mail-qt1-f194.google.com with SMTP id y26so28761525qto.4; Thu, 18 Jul 2019 14:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Dyup3V+7x6vR5f0mEdgXHm4ad/gxVODy2UYvXjZtm38=; b=g/A6ZSXFBVZwZkYYxAc6/240ZOw/nl+fyU7BjnEptzhSBtU1aTXriTXck/+BG1DVOY EV7nAttQx1wz7J9GFiiRlu0+0fpCDFuK708Veu0VrtQUKch3fKT7QXOYuBgA8ioW/L8g 2yZ0VeWPfE0VAB52AKfusR8k1B+mH6sY1xsE/zS6Lw2e7m1ItUaud6iua3qpHdSKDx8W +J+F5QDBMqMYtZmLIUaPCxV6mlxG/HcVbe7ITBXceI3phQoSF7h/u01JzOVR0mj3Kh2y H9GcUErP1w0nbrRy6K7wnuPkIyOSttzXPL1P2OKYyjOOPeZvocpNWmgMp6FzpqRmFiHN SOfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Dyup3V+7x6vR5f0mEdgXHm4ad/gxVODy2UYvXjZtm38=; b=NGHzAZu8riSRlZtN2VE8iL/AYp3oMgBD6wMr6OoatI8aSeApYuCcgM3+6nSTy0Fcv9 cbda8P5jLWwDHNhwpdIkf21ybWnd/tYiFwMohmSiM3GgPvU+hFVhgF1+2dUzqBwAIfVi ktjOXLGEmEFADG7rQfkm3bLaKUXvKDbG/rJetveAak67x7itc7amn97Es0wX1S7xfd6z N30791N4g/k8lCPR1cw/8NTnVgmxw/mWf72tJ4J87Zx5uSzA2yz67COuoDQZjOJ1jCpT dBW+jmcMUixl7jMiv9lwEFR8iM695XToDDUXUhdDMHwzcB7/wm8d4ftIf2wUskJPyvlV Lpaw== X-Gm-Message-State: APjAAAXcvfMFP7FTvP0p/taVZ/zfO9hX1oL7SbHteVz/pvKlKf0PIhw/ aSLWHFTFsSO7zIcFI1EfKJw5dTA48wo0IWoX9Mc= X-Received: by 2002:a0c:b095:: with SMTP id o21mr35480609qvc.73.1563484161439; Thu, 18 Jul 2019 14:09:21 -0700 (PDT) MIME-Version: 1.0 References: <20190716115535-mutt-send-email-mst@kernel.org> <20190716125845-mutt-send-email-mst@kernel.org> <20190717055804-mutt-send-email-mst@kernel.org> <20190718003211-mutt-send-email-mst@kernel.org> <20190718162040-mutt-send-email-mst@kernel.org> <20190718164656-mutt-send-email-mst@kernel.org> In-Reply-To: <20190718164656-mutt-send-email-mst@kernel.org> From: Alexander Duyck Date: Thu, 18 Jul 2019 14:09:10 -0700 Message-ID: Subject: Re: [PATCH v1 6/6] virtio-balloon: Add support for aerating memory via hinting To: "Michael S. Tsirkin" Cc: Nitesh Narayan Lal , kvm list , David Hildenbrand , Dave Hansen , LKML , linux-mm , Andrew Morton , Yang Zhang , pagupta@redhat.com, Rik van Riel , Konrad Rzeszutek Wilk , lcapitulino@redhat.com, wei.w.wang@intel.com, Andrea Arcangeli , Paolo Bonzini , dan.j.williams@intel.com, Alexander Duyck Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 18, 2019 at 1:49 PM Michael S. Tsirkin wrote: > > On Thu, Jul 18, 2019 at 01:34:03PM -0700, Alexander Duyck wrote: > > On Thu, Jul 18, 2019 at 1:24 PM Michael S. Tsirkin wrote: > > > > > > On Thu, Jul 18, 2019 at 08:34:37AM -0700, Alexander Duyck wrote: > > > > > > > For example we allocate pages until shrinker kicks in. > > > > > > > Fair enough but in fact many it would be better to > > > > > > > do the reverse: trigger shrinker and then send as many > > > > > > > free pages as we can to host. > > > > > > > > > > > > I'm not sure I understand this last part. > > > > > > > > > > Oh basically what I am saying is this: one of the reasons to use page > > > > > hinting is when host is short on memory. In that case, why don't we use > > > > > shrinker to ask kernel drivers to free up memory? Any memory freed could > > > > > then be reported to host. > > > > > > > > Didn't the balloon driver already have a feature like that where it > > > > could start shrinking memory if the host was under memory pressure? If > > > > so how would adding another one add much value. > > > > > > Well fundamentally the basic balloon inflate kind of does this, yes :) > > > > > > The difference with what I am suggesting is that balloon inflate tries > > > to aggressively achieve a specific goal of freed memory. We could have a > > > weaker "free as much as you can" that is still stronger than free page > > > hint which as you point out below does not try to free at all, just > > > hints what is already free. > > > > Yes, but why wait until the host is low on memory? > > It can come about for a variety of reasons, such as > other VMs being aggressive, or ours aggressively caching > stuff in memory. > > > With my > > implementation we can perform the hints in the background for a low > > cost already. So why should we wait to free up memory when we could do > > it immediately. Why let things get to the state where the host is > > under memory pressure when the guests can be proactively freeing up > > the pages and improving performance as a result be reducing swap > > usage? > > You are talking about sending free memory to host. > Fair enough but if you have drivers that aggressively > allocate memory then there won't be that much free guest > memory without invoking a shrinker. So then what we really need is a way for the host to trigger the shrinker via a call to drop_slab() on the guest don't we? Then we could automatically hint the free pages to the host.