Received: by 10.223.148.5 with SMTP id 5csp7572405wrq; Thu, 18 Jan 2018 07:01:18 -0800 (PST) X-Google-Smtp-Source: ACJfBovNvGzuZNmp43pRnse5zVIHSS2EpuVk3/jlX281u8oEynUkuLob4KbQWEhNjffXHQDWuIHa X-Received: by 10.99.114.90 with SMTP id c26mr26433640pgn.114.1516287678335; Thu, 18 Jan 2018 07:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516287678; cv=none; d=google.com; s=arc-20160816; b=a6wcy4+EsHasDqh2rbCVCencO+3R71WqikSi/6FZPXtz/yM9MfSXRQYEyTL7DuCkk7 Ik6+6iO2VRxMNTcs/+Sb9aqd1pfP7FAfrjGXoyyMjScjWU98zrox5cJaR3qX5SyrNPy5 pqmazN/KpyMLYz1iHvYJjDMLTCS4eXhY34ecbP86cVS+tnPXFuwoFl6dslka6kRvrSOq Px0A4XUFDnkzLfY6VHTkBIMKJkMzXIUYSKyTUh0hWL8k3gIf+dqkCJPuknkeH5rAYcK4 /tHYbhyDSnHlwtpK0DORRcTCnSTyKrhsDkcXN1XB1ZBZcqnoDTGQROB8V53BWshiA0b9 pXxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=77FvemU4YuxXJGRZPGJBK8aMH3DP7Ep6WNnBmiWi0Ug=; b=VIxOxY2VPpzotjMwgPym7ckR+t2Ym+PUbfi8c1947xLAXiKPfpml6W/Rq1uafZw61q 0VldIYmuUKc2EeDHbtIgdV7uYOKnu3IgC5eCsiNNncI/99VncbG4ppeKwGY/qMzgJNaE wyogIH/1wvfuJ7pMdA85nzQqQpRyKu58I54cwQTWyfHiY+Br/t1sruhajw83qjQkj9s3 KJNGCBfOIQwdbdS4X10vRnCTTyeHwFq+X7OBPUJgJ6A0Wljaxj//31tsCAn7XXt8IwK+ UxT162yasNn4foiZbmEPuPpBr8+OML//Sv0la9k7+zmhZTKYIh7Bc5ZPx2U9lD5PdQwG SydQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si6344490pgn.209.2018.01.18.07.01.02; Thu, 18 Jan 2018 07:01:18 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756231AbeARNcp (ORCPT + 99 others); Thu, 18 Jan 2018 08:32:45 -0500 Received: from www262.sakura.ne.jp ([202.181.97.72]:31683 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755690AbeARNco (ORCPT ); Thu, 18 Jan 2018 08:32:44 -0500 Received: from fsav101.sakura.ne.jp (fsav101.sakura.ne.jp [27.133.134.228]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w0IDUQ5J018194; Thu, 18 Jan 2018 22:30:26 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav101.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav101.sakura.ne.jp); Thu, 18 Jan 2018 22:30:26 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav101.sakura.ne.jp) Received: from [192.168.1.8] (softbank126074156036.bbtec.net [126.74.156.36]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w0IDUKL5018158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 18 Jan 2018 22:30:25 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Subject: Re: [PATCH v22 2/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ To: "Michael S. Tsirkin" , Wei Wang Cc: 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, pbonzini@redhat.com, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com, riel@redhat.com References: <1516165812-3995-1-git-send-email-wei.w.wang@intel.com> <1516165812-3995-3-git-send-email-wei.w.wang@intel.com> <20180117180337-mutt-send-email-mst@kernel.org> From: Tetsuo Handa Message-ID: <2bb0e3d9-1679-9ad3-b402-f0781f6cf094@I-love.SAKURA.ne.jp> Date: Thu, 18 Jan 2018 22:30:18 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180117180337-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/01/18 1:44, Michael S. Tsirkin wrote: >> +static void add_one_sg(struct virtqueue *vq, unsigned long pfn, uint32_t len) >> +{ >> + struct scatterlist sg; >> + unsigned int unused; >> + int err; >> + >> + sg_init_table(&sg, 1); >> + sg_set_page(&sg, pfn_to_page(pfn), len, 0); >> + >> + /* Detach all the used buffers from the vq */ >> + while (virtqueue_get_buf(vq, &unused)) >> + ; >> + >> + /* >> + * Since this is an optimization feature, losing a couple of free >> + * pages to report isn't important. >> We simply resturn > > return > >> without adding >> + * the page if the vq is full. We are adding one entry each time, >> + * which essentially results in no memory allocation, so the >> + * GFP_KERNEL flag below can be ignored. >> + */ >> + if (vq->num_free) { >> + err = virtqueue_add_inbuf(vq, &sg, 1, vq, GFP_KERNEL); > > Should we kick here? At least when ring is close to > being full. Kick at half way full? > Otherwise it's unlikely ring will > ever be cleaned until we finish the scan. Since this add_one_sg() is called between spin_lock_irqsave(&zone->lock, flags) and spin_unlock_irqrestore(&zone->lock, flags), it is not permitted to sleep. And walk_free_mem_block() is not ready to handle resume. By the way, specifying GFP_KERNEL here is confusing even though it is never used. walk_free_mem_block() says: * The callback itself must not sleep or perform any operations which would * require any memory allocations directly (not even GFP_NOWAIT/GFP_ATOMIC) * or via any lock dependency. > >> + /* >> + * This is expected to never fail, because there is always an >> + * entry available on the vq. >> + */ >> + BUG_ON(err); >> + } >> +}