Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2087528ybi; Thu, 18 Jul 2019 03:12:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxb5t0Wfi4kEex2ibyU1gKkPp2oJdK4vQTf89ZEckhMmSRoOlmpKjDbWy1B8oKsblIH7ugE X-Received: by 2002:a63:d415:: with SMTP id a21mr45663605pgh.229.1563444756912; Thu, 18 Jul 2019 03:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563444756; cv=none; d=google.com; s=arc-20160816; b=z7WFu2zDvr5OTTTVSuvlwdKpYWtIgEERMWlcm5MaLnFh6Xs85XbwT1Zeq1N2qTrhro 9yhfYIsiiPaP0qBHBkYKVD+iO5iNYzoi6JzOMOjLxUD/xkqLVd+m2dJpGLX75GxMWfTI DlIrB1lt3aHnCXBSUdZUBdm92ok7IOcE25WH+fcJuTFq7VMfkAAx90HYQ05MihSaoAWh SaJGhzVOsgCPah74GlZDss5Vs5yjPK0mtvhev2bYz3hD49SaNcW1RP+3TMseCqyNob6T WV6B4Lvu4tcGRnG5tQeupbjV0qziHyrk8DGShpjDzGkcBxm7qsz0CxpMrUm1fL9/nUup 1//A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=IPnm+I9Usx31xFunRgPUzQdL2I/DsOB7LdpHa8iXcZk=; b=q7qIunXYr2Sna7e3omB0eq537q67yQ6cmtc3V9dNewKdLjGP+saTIcqQ+rAlIubsEH d8YdqwszsILReKSaYxbgTinP4bgSQcljvQm/NfxtXersJN4e0RV7kzytiqAH1drXSqK4 e/8W4iCEjhgpHIaQHHXr8b8efNj8cot1zvTbhtKu6USISoEi5ceEdeUOp6HObicYZkuP L1CVLmyA9V8DAbAwmHkFmhfG3z/4O092fdQKwled0QeroQwraBUYuqYVb9mJsa5Uv67c XpoLFErJwT2kqkfLVsgA/gZ+kVl8QpP1qirAm5nCJqvZdhE8VbAD4SSVQRaxQwKlZfDE RnLg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si1385733pgg.348.2019.07.18.03.12.20; Thu, 18 Jul 2019 03:12:36 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389899AbfGRKKn (ORCPT + 99 others); Thu, 18 Jul 2019 06:10:43 -0400 Received: from mga14.intel.com ([192.55.52.115]:2216 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbfGRKKn (ORCPT ); Thu, 18 Jul 2019 06:10:43 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2019 03:10:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,276,1559545200"; d="scan'208";a="162031470" Received: from devel-ww.sh.intel.com ([10.239.48.128]) by orsmga008.jf.intel.com with ESMTP; 18 Jul 2019 03:10:39 -0700 From: Wei Wang To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mst@redhat.com, xdeguillard@vmware.com, namit@vmware.com Cc: akpm@linux-foundation.org, pagupta@redhat.com, riel@surriel.com, dave.hansen@intel.com, david@redhat.com, konrad.wilk@oracle.com, yang.zhang.wz@gmail.com, nitesh@redhat.com, lcapitulino@redhat.com, aarcange@redhat.com, pbonzini@redhat.com, alexander.h.duyck@linux.intel.com, dan.j.williams@intel.com Subject: [PATCH v2] mm/balloon_compaction: avoid duplicate page removal Date: Thu, 18 Jul 2019 17:27:20 +0800 Message-Id: <1563442040-13510-1-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces) A #GP is reported in the guest when requesting balloon inflation via virtio-balloon. The reason is that the virtio-balloon driver has removed the page from its internal page list (via balloon_page_pop), but balloon_page_enqueue_one also calls "list_del" to do the removal. This is necessary when it's used from balloon_page_enqueue_list, but not from balloon_page_enqueue_one. So remove the list_del balloon_page_enqueue_one, and update some comments as a reminder. Signed-off-by: Wei Wang --- ChangeLong: v1->v2: updated some comments mm/balloon_compaction.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 83a7b61..8639bfc 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -21,7 +21,6 @@ static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info, * memory corruption is possible and we should stop execution. */ BUG_ON(!trylock_page(page)); - list_del(&page->lru); balloon_page_insert(b_dev_info, page); unlock_page(page); __count_vm_event(BALLOON_INFLATE); @@ -33,7 +32,7 @@ static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info, * @b_dev_info: balloon device descriptor where we will insert a new page to * @pages: pages to enqueue - allocated using balloon_page_alloc. * - * Driver must call it to properly enqueue a balloon pages before definitively + * Driver must call it to properly enqueue balloon pages before definitively * removing it from the guest system. * * Return: number of pages that were enqueued. @@ -47,6 +46,7 @@ size_t balloon_page_list_enqueue(struct balloon_dev_info *b_dev_info, spin_lock_irqsave(&b_dev_info->pages_lock, flags); list_for_each_entry_safe(page, tmp, pages, lru) { + list_del(&page->lru); balloon_page_enqueue_one(b_dev_info, page); n_pages++; } @@ -128,13 +128,19 @@ struct page *balloon_page_alloc(void) EXPORT_SYMBOL_GPL(balloon_page_alloc); /* - * balloon_page_enqueue - allocates a new page and inserts it into the balloon - * page list. + * balloon_page_enqueue - inserts a new page into the balloon page list. + * * @b_dev_info: balloon device descriptor where we will insert a new page to * @page: new page to enqueue - allocated using balloon_page_alloc. * * Driver must call it to properly enqueue a new allocated balloon page * before definitively removing it from the guest system. + * + * Drivers must not call balloon_page_enqueue on pages that have been + * pushed to a list with balloon_page_push before removing them with + * balloon_page_pop. To all pages on a list, use balloon_page_list_enqueue + * instead. + * * This function returns the page address for the recently enqueued page or * NULL in the case we fail to allocate a new page this turn. */ -- 2.7.4