All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang <wei.w.wang@intel.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: aarcange@redhat.com, virtio-dev@lists.oasis-open.org,
	kvm@vger.kernel.org, mawilcox@microsoft.com,
	qemu-devel@nongnu.org, amit.shah@redhat.com,
	liliang.opensource@gmail.com, linux-kernel@vger.kernel.org,
	willy@infradead.org, virtualization@lists.linux-foundation.org,
	linux-mm@kvack.org, yang.zhang.wz@gmail.com,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	quan.xu@aliyun.com, cornelia.huck@de.ibm.com,
	pbonzini@redhat.com, akpm@linux-foundation.org,
	mhocko@kernel.org, mgorman@techsingularity.net
Subject: Re: [PATCH v16 3/5] virtio-balloon: VIRTIO_BALLOON_F_SG
Date: Tue, 10 Oct 2017 15:28:58 +0800	[thread overview]
Message-ID: <59DC76BA.7070202__42327.4546199993$1507620463$gmane$org@intel.com> (raw)
In-Reply-To: <20171009181612-mutt-send-email-mst@kernel.org>

On 10/09/2017 11:20 PM, Michael S. Tsirkin wrote:
> On Sat, Sep 30, 2017 at 12:05:52PM +0800, Wei Wang wrote:
>> +static inline void xb_set_page(struct virtio_balloon *vb,
>> +			       struct page *page,
>> +			       unsigned long *pfn_min,
>> +			       unsigned long *pfn_max)
>> +{
>> +	unsigned long pfn = page_to_pfn(page);
>> +
>> +	*pfn_min = min(pfn, *pfn_min);
>> +	*pfn_max = max(pfn, *pfn_max);
>> +	xb_preload(GFP_KERNEL);
>> +	xb_set_bit(&vb->page_xb, pfn);
>> +	xb_preload_end();
>> +}
>> +
> So, this will allocate memory
>
> ...
>
>> @@ -198,9 +327,12 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num)
>>   	struct page *page;
>>   	struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info;
>>   	LIST_HEAD(pages);
>> +	bool use_sg = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_SG);
>> +	unsigned long pfn_max = 0, pfn_min = ULONG_MAX;
>>   
>> -	/* We can only do one array worth at a time. */
>> -	num = min(num, ARRAY_SIZE(vb->pfns));
>> +	/* Traditionally, we can only do one array worth at a time. */
>> +	if (!use_sg)
>> +		num = min(num, ARRAY_SIZE(vb->pfns));
>>   
>>   	mutex_lock(&vb->balloon_lock);
>>   	/* We can't release more pages than taken */
> And is sometimes called on OOM.
>
>
> I suspect we need to
>
> 1. keep around some memory for leak on oom
>
> 2. for non oom allocate outside locks
>
>

I think maybe we can optimize the existing balloon logic, which could 
remove the big balloon lock:

It would not be necessary to have the inflating and deflating run at the 
same time.
For example, 1st request to inflate 7G RAM, when 1GB has been given to 
the host (so 6G left), the
2nd request to deflate 5G is received. Instead of waiting for the 1st 
request to inflate 6G and then
continuing with the 2nd request to deflate 5G, we can do a diff (6G to 
inflate - 5G to deflate) immediately,
and got 1G to inflate. In this way, all that driver will do is to simply 
inflate another 1G.

Same for the OOM case: when OOM asks for 1G, while inflating 5G is in 
progress, then the driver can
deduct 1G from the amount that needs to inflate, and as a result, it 
will inflate 4G.

In this case, we will never have the inflating and deflating task run at 
the same time, so I think it is
possible to remove the lock, and therefore, we will not have that 
deadlock issue.

What would you guys think?

Best,
Wei

  reply	other threads:[~2017-10-10  7:28 UTC|newest]

Thread overview: 146+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-30  4:05 [PATCH v16 0/5] Virtio-balloon Enhancement Wei Wang
2017-09-30  4:05 ` [virtio-dev] " Wei Wang
2017-09-30  4:05 ` [Qemu-devel] " Wei Wang
2017-09-30  4:05 ` Wei Wang
2017-09-30  4:05 ` [PATCH v16 1/5] lib/xbitmap: Introduce xbitmap Wei Wang
2017-09-30  4:05   ` [virtio-dev] " Wei Wang
2017-09-30  4:05   ` [Qemu-devel] " Wei Wang
2017-09-30  4:05   ` Wei Wang
2017-09-30  4:05   ` Wei Wang
2017-10-09 11:30   ` Tetsuo Handa
2017-10-09 11:30     ` [Qemu-devel] " Tetsuo Handa
2017-10-09 11:30     ` Tetsuo Handa
2017-09-30  4:05 ` Wei Wang
2017-09-30  4:05 ` [PATCH v16 2/5] radix tree test suite: add tests for xbitmap Wei Wang
2017-09-30  4:05 ` Wei Wang
2017-09-30  4:05   ` [virtio-dev] " Wei Wang
2017-09-30  4:05   ` [Qemu-devel] " Wei Wang
2017-09-30  4:05   ` Wei Wang
2017-09-30  4:05 ` [PATCH v16 3/5] virtio-balloon: VIRTIO_BALLOON_F_SG Wei Wang
2017-09-30  4:05 ` Wei Wang
2017-09-30  4:05   ` [virtio-dev] " Wei Wang
2017-09-30  4:05   ` [Qemu-devel] " Wei Wang
2017-09-30  4:05   ` Wei Wang
2017-10-02  4:30   ` Michael S. Tsirkin
2017-10-02  4:30   ` Michael S. Tsirkin
2017-10-02  4:30     ` [Qemu-devel] " Michael S. Tsirkin
2017-10-02  4:30     ` Michael S. Tsirkin
2017-10-02 12:39     ` Wang, Wei W
2017-10-02 12:39     ` Wang, Wei W
2017-10-02 12:39       ` [Qemu-devel] " Wang, Wei W
2017-10-02 12:39       ` Wang, Wei W
2017-10-02 12:39       ` Wang, Wei W
2017-10-02 13:44       ` Michael S. Tsirkin
2017-10-02 13:44       ` Michael S. Tsirkin
2017-10-02 13:44         ` [Qemu-devel] " Michael S. Tsirkin
2017-10-02 13:44         ` Michael S. Tsirkin
2017-10-02 13:44         ` Michael S. Tsirkin
2017-10-09 15:20   ` Michael S. Tsirkin
2017-10-09 15:20     ` [virtio-dev] " Michael S. Tsirkin
2017-10-09 15:20     ` [Qemu-devel] " Michael S. Tsirkin
2017-10-09 15:20     ` Michael S. Tsirkin
2017-10-10  7:28     ` Wei Wang [this message]
2017-10-10  7:28     ` Wei Wang
2017-10-10  7:28       ` [virtio-dev] " Wei Wang
2017-10-10  7:28       ` [Qemu-devel] " Wei Wang
2017-10-10  7:28       ` Wei Wang
2017-10-10 11:08       ` Tetsuo Handa
2017-10-10 11:08         ` [Qemu-devel] " Tetsuo Handa
2017-10-10 11:08         ` Tetsuo Handa
2017-10-10 12:32         ` Wei Wang
2017-10-10 12:32           ` [virtio-dev] " Wei Wang
2017-10-10 12:32           ` [Qemu-devel] " Wei Wang
2017-10-10 12:32           ` Wei Wang
2017-10-10 13:09           ` Tetsuo Handa
2017-10-10 13:09             ` [Qemu-devel] " Tetsuo Handa
2017-10-10 13:09             ` Tetsuo Handa
2017-10-11  1:51             ` Wei Wang
2017-10-11  1:51             ` Wei Wang
2017-10-11  1:51               ` [virtio-dev] " Wei Wang
2017-10-11  1:51               ` [Qemu-devel] " Wei Wang
2017-10-11  1:51               ` Wei Wang
2017-10-11  2:26               ` Tetsuo Handa
2017-10-11  2:26                 ` [Qemu-devel] " Tetsuo Handa
2017-10-11  3:16                 ` Wei Wang
2017-10-11  3:16                   ` [virtio-dev] " Wei Wang
2017-10-11  3:16                   ` [Qemu-devel] " Wei Wang
2017-10-11  3:16                   ` Wei Wang
2017-10-11  3:16                 ` Wei Wang
2017-10-10 12:32         ` Wei Wang
2017-10-09 15:20   ` Michael S. Tsirkin
2017-09-30  4:05 ` [PATCH v16 4/5] mm: support reporting free page blocks Wei Wang
2017-09-30  4:05 ` Wei Wang
2017-09-30  4:05   ` [virtio-dev] " Wei Wang
2017-09-30  4:05   ` [Qemu-devel] " Wei Wang
2017-09-30  4:05   ` Wei Wang
2017-10-03 14:50   ` Michal Hocko
2017-10-03 14:50     ` [Qemu-devel] " Michal Hocko
2017-10-03 14:50     ` Michal Hocko
2017-10-03 14:50   ` Michal Hocko
2017-09-30  4:05 ` [PATCH v16 5/5] virtio-balloon: VIRTIO_BALLOON_F_CTRL_VQ Wei Wang
2017-09-30  4:05   ` [virtio-dev] " Wei Wang
2017-09-30  4:05   ` [Qemu-devel] " Wei Wang
2017-09-30  4:05   ` Wei Wang
2017-10-01  3:18   ` Michael S. Tsirkin
2017-10-01  3:18     ` [virtio-dev] " Michael S. Tsirkin
2017-10-01  3:18     ` [Qemu-devel] " Michael S. Tsirkin
2017-10-01  3:18     ` Michael S. Tsirkin
2017-10-02 16:38     ` Wang, Wei W
2017-10-02 16:38     ` Wang, Wei W
2017-10-02 16:38       ` [virtio-dev] " Wang, Wei W
2017-10-02 16:38       ` [Qemu-devel] " Wang, Wei W
2017-10-02 16:38       ` Wang, Wei W
2017-10-02 16:38       ` Wang, Wei W
2017-10-10 15:15       ` Michael S. Tsirkin
2017-10-10 15:15         ` [virtio-dev] " Michael S. Tsirkin
2017-10-10 15:15         ` [Qemu-devel] " Michael S. Tsirkin
2017-10-10 15:15         ` Michael S. Tsirkin
2017-10-10 15:15         ` Michael S. Tsirkin
2017-10-11  6:03         ` Wei Wang
2017-10-11  6:03         ` Wei Wang
2017-10-11  6:03           ` [virtio-dev] " Wei Wang
2017-10-11  6:03           ` [Qemu-devel] " Wei Wang
2017-10-11  6:03           ` Wei Wang
2017-10-11  6:03           ` Wei Wang
2017-10-11 13:49           ` Michael S. Tsirkin
2017-10-11 13:49           ` Michael S. Tsirkin
2017-10-11 13:49             ` [virtio-dev] " Michael S. Tsirkin
2017-10-11 13:49             ` [Qemu-devel] " Michael S. Tsirkin
2017-10-11 13:49             ` Michael S. Tsirkin
2017-10-11 13:49             ` Michael S. Tsirkin
2017-10-12  3:54             ` Wei Wang
2017-10-12  3:54               ` [virtio-dev] " Wei Wang
2017-10-12  3:54               ` [Qemu-devel] " Wei Wang
2017-10-12  3:54               ` Wei Wang
2017-10-12  3:54               ` Wei Wang
2017-10-13 13:38               ` Michael S. Tsirkin
2017-10-13 13:38                 ` [virtio-dev] " Michael S. Tsirkin
2017-10-13 13:38                 ` [Qemu-devel] " Michael S. Tsirkin
2017-10-13 13:38                 ` Michael S. Tsirkin
2017-10-13 13:38                 ` Michael S. Tsirkin
2017-10-19  8:07                 ` Wei Wang
2017-10-19  8:07                 ` Wei Wang
2017-10-19  8:07                   ` [virtio-dev] " Wei Wang
2017-10-19  8:07                   ` [Qemu-devel] " Wei Wang
2017-10-19  8:07                   ` Wei Wang
2017-10-19  8:07                   ` Wei Wang
2017-10-13 13:38               ` Michael S. Tsirkin
2017-10-12  3:54             ` Wei Wang
2017-10-10 15:15       ` Michael S. Tsirkin
2017-10-01  3:18   ` Michael S. Tsirkin
2017-09-30  4:05 ` Wei Wang
2017-10-01 13:16 ` [PATCH v16 0/5] Virtio-balloon Enhancement Damian Tometzki
2017-10-01 13:16 ` Damian Tometzki
2017-10-01 13:16   ` [Qemu-devel] " Damian Tometzki
2017-10-01 13:16   ` Damian Tometzki
2017-10-01 13:16   ` Damian Tometzki
2017-10-01 13:25 ` Damian Tometzki
2017-10-01 13:25   ` [Qemu-devel] " Damian Tometzki
2017-10-01 13:25   ` Damian Tometzki
2017-10-01 13:25   ` Damian Tometzki
2017-10-09  9:39   ` Wei Wang
2017-10-09  9:39     ` [virtio-dev] " Wei Wang
2017-10-09  9:39     ` [Qemu-devel] " Wei Wang
2017-10-09  9:39     ` Wei Wang
2017-10-09  9:39   ` Wei Wang
2017-10-01 13:25 ` Damian Tometzki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='59DC76BA.7070202__42327.4546199993$1507620463$gmane$org@intel.com' \
    --to=wei.w.wang@intel.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=amit.shah@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=liliang.opensource@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawilcox@microsoft.com \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=quan.xu@aliyun.com \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=willy@infradead.org \
    --cc=yang.zhang.wz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.