Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2233789ybi; Thu, 18 Jul 2019 05:25:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbNE1AIu0KJSp7kh3bUwVeYFbUL3O2wOFKGXXFCxBzDnfJHULuFTkjzdNcvQ3QBiOL252w X-Received: by 2002:a63:f953:: with SMTP id q19mr47193445pgk.367.1563452704513; Thu, 18 Jul 2019 05:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563452704; cv=none; d=google.com; s=arc-20160816; b=lgAamqUl2tJezFFnE235LsrY2djMYNJDDmwTjJ+tQ0AogGdteF7pz9rYmQ5r1l1A4R fUl2oFUJ77I8TOAr6CTpSxMPRwX+1oazbLj9kZrybuZ6C8BPr8m5LcDq68DE71LGoIIv gwQoBVXUz8BKdUcvJEK12lF1sHxYW+NE8MNGM5o/G4IKm93OH8tMtbMxHsEsZNrTRpsk XPN4V1lLNisdknmLrowLWFPxyRqeeTmru+LTxJubz3nQO3tJXme/wHpG0hYugmwPX2QA kQCrx7XHz3fGEF+NXrU4Uw6WoHu/MhEpgcSQ4aFOIy7cVacliSdc431wkgNT4qAGuR7b Oe/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date; bh=H+TymQOnmdcKuZk9ttK0AqeJXUX/JIzSLYz7mBRh16k=; b=0+iG2Hb8/sT6eo6FmJgvSbIMM0lbdlYegXVRMuSYnnT0qIIvlnNffUBRWn/bGNA6// lXHgtglTXICcEWbuiTKUT5aggonWupzTuMm6NuabyL0fOpZ2dunaM31xszdoVOtoPx2f lr4nxPhwV5hO1zNjLfzDtVgr5veSj3xOPMd7f5+vPoc/AH3hZHvhVRrBfAkdUsGMuOrn 8jedLORW7UMlxQe1uQ98P5e3zy9U30joiUaIeq33hBX1SvyU1fpqLkPQJj0Y8D6igKYw CUZmQ31bkCXCufewp4mWY8e+hxOv0LxZHPnlgurDCuiqQkSsPakWJdS86+0f+xgt9wLH ZGMQ== 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 y20si251856plp.335.2019.07.18.05.24.47; Thu, 18 Jul 2019 05:25:04 -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 S2390238AbfGRMYY (ORCPT + 99 others); Thu, 18 Jul 2019 08:24:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38868 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390199AbfGRMYY (ORCPT ); Thu, 18 Jul 2019 08:24:24 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A909309264C; Thu, 18 Jul 2019 12:24:24 +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 8FA4E60A35; Thu, 18 Jul 2019 12:24:19 +0000 (UTC) Date: Thu, 18 Jul 2019 08:24:11 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Wei Wang , Jason Wang , virtualization@lists.linux-foundation.org, linux-mm@kvack.org Subject: [PATCH v3 1/2] mm/balloon_compaction: avoid duplicate page removal Message-ID: <20190718122324.10552-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 18 Jul 2019 12:24:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wei Wang 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. Move list_del to balloon_page_enqueue, and update comments accordingly. Fixes: 418a3ab1e778 (mm/balloon_compaction: List interfaces) Signed-off-by: Wei Wang Signed-off-by: Michael S. Tsirkin --- mm/balloon_compaction.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 83a7b614061f..d25664e1857b 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); @@ -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. */ -- MST