Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1889287ybi; Wed, 17 Jul 2019 23:49:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCKPQcAZxFDYTkB8e+3HnKPo52+2zoBdADykueGiaHsdbm1m211i9y3QeFHP3DsRLnAAAh X-Received: by 2002:a17:90a:208d:: with SMTP id f13mr47781517pjg.68.1563432547137; Wed, 17 Jul 2019 23:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563432547; cv=none; d=google.com; s=arc-20160816; b=PHghbdzslo0oM0SJFjuqU0W2B3hQC/PcRPZ7r+p0X+QcZxlDianrvnNFLi8KdtRBR7 HwG7j6W+zEsq4moKIpI5SOflsecBGDXsEMC9l2xiLvHy8n3qf9r+P08x00LzKoGqf/ZL ETHNZt0ns5QJJKFHkkzKuyNpKgJ0ba7K7H/p+cD3dIUNeifE1zCYloAByVsuig0YJysh 2KD9zOO6ZQB/eJ772HVJMsBpZSjpjIOZ7G5CWHxpl64XzcRA2G80iwVc9qfkPMqne3Hh xFKurMGVqP0eCfroibMfLjfNA5ZrPRo8wY2p66AyyPxDj97kENqmFAUxEpKRXCUPuVhP r91g== 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=zDCoXD/nkDhoP9AXJVuyUjGLHCg5Dqk8JG+BiorhxGc=; b=moDqKiwAa5AlTAh8nXv6UDo+kWWK7jzw/aZHSqorRLFA2/ESBZK+sISjeiBAUa9Dtb 7qWgX2i1O8sP80p7YGnW0GgRjUtLT5pKRETmBkvXCs+oF8LMu/ROzsJXPc9oatihrYrj NkdgpGfrYafG0v21Pn9pzR8DsKHhr6TS7D0/W4zKQUQL7RY8nrId9672mhtP0KZDLR71 8zJh8h7uBs3KeJLLHKJFNfLyI+NkvzwxNyEtO0voMdOtatESumcbR72dn86/VTZl5KIi t6qIY+pY7AHphsRoOYhwUfQHCqHw9dbEwLReIFZZghmIW7XjElw4I8IH7Q9Of+pJ83jB 6wUg== 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 l68si24712532plb.416.2019.07.17.23.48.50; Wed, 17 Jul 2019 23:49:07 -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 S1727802AbfGRGsE (ORCPT + 99 others); Thu, 18 Jul 2019 02:48:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56072 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfGRGsE (ORCPT ); Thu, 18 Jul 2019 02:48:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9342D30BC590; Thu, 18 Jul 2019 06:48:03 +0000 (UTC) Received: from redhat.com (ovpn-120-147.rdu2.redhat.com [10.10.120.147]) by smtp.corp.redhat.com (Postfix) with SMTP id 5B13B19C65; Thu, 18 Jul 2019 06:47:53 +0000 (UTC) Date: Thu, 18 Jul 2019 02:47:52 -0400 From: "Michael S. Tsirkin" To: Wei Wang Cc: Alexander Duyck , Nitesh Narayan Lal , kvm list , David Hildenbrand , "Hansen, Dave" , LKML , linux-mm , Andrew Morton , Yang Zhang , "pagupta@redhat.com" , Rik van Riel , Konrad Rzeszutek Wilk , "lcapitulino@redhat.com" , Andrea Arcangeli , Paolo Bonzini , "Williams, Dan J" , Alexander Duyck Subject: Re: use of shrinker in virtio balloon free page hinting Message-ID: <20190718024408-mutt-send-email-mst@kernel.org> References: <20190717071332-mutt-send-email-mst@kernel.org> <286AC319A985734F985F78AFA26841F73E16D4B2@shsmsx102.ccr.corp.intel.com> <20190718000434-mutt-send-email-mst@kernel.org> <5D300A32.4090300@intel.com> <20190718015319-mutt-send-email-mst@kernel.org> <5D3011E9.4040908@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5D3011E9.4040908@intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 18 Jul 2019 06:48:03 +0000 (UTC) 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 02:30:01PM +0800, Wei Wang wrote: > On 07/18/2019 01:58 PM, Michael S. Tsirkin wrote: > > > > what if it does not fail? > > > > > > > Shrinker is called on system memory pressure. On memory pressure > > > get_free_page_and_send will fail memory allocation, so it stops allocating > > > more. > > Memory pressure could be triggered by an unrelated allocation > > e.g. from another driver. > > As memory pressure is system-wide (no matter who triggers it), free page > hinting > will fail on memory pressure, same as other drivers. That would be good. Except instead of failing it can hit a race condition where it will reallocate memory freed by shrinker. Not good. Yes lots of drivers do that but they do not drink up memory quite as aggressively as page hinting. > As long as the page allocation succeeds, we could just think the system is > not in > the memory pressure situation, then thing could go on normally. Given we have a shrinker callback we can't pretend we don't know or care. > Also, the VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG includes NORETRY and > NOMEMALLOC, > which makes it easier than most other drivers to fail allocation first. > > Best, > Wei It's a classic race condition and I don't see why do arguments about probability matter. With a big fleet of machines it is guaranteed to happen on some. -- MST