From: Roger Pau Monne <roger.pau@citrix.com>
To: <linux-kernel@vger.kernel.org>
Cc: Juergen Gross <jgross@suse.com>,
Stefano Stabellini <sstabellini@kernel.org>,
stable@vger.kernel.org, xen-devel@lists.xenproject.org,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v2 1/4] xen/balloon: fix accounting in alloc_xenballooned_pages error path
Date: Fri, 24 Jul 2020 14:42:38 +0200 [thread overview]
Message-ID: <20200724124241.48208-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20200724124241.48208-1-roger.pau@citrix.com>
target_unpopulated is incremented with nr_pages at the start of the
function, but the call to free_xenballooned_pages will only subtract
pgno number of pages, and thus the rest need to be subtracted before
returning or else accounting will be skewed.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: stable@vger.kernel.org
---
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org
---
drivers/xen/balloon.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 77c57568e5d7..3cb10ed32557 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -630,6 +630,12 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
out_undo:
mutex_unlock(&balloon_mutex);
free_xenballooned_pages(pgno, pages);
+ /*
+ * NB: free_xenballooned_pages will only subtract pgno pages, but since
+ * target_unpopulated is incremented with nr_pages at the start we need
+ * to remove the remaining ones also, or accounting will be screwed.
+ */
+ balloon_stats.target_unpopulated -= nr_pages - pgno;
return ret;
}
EXPORT_SYMBOL(alloc_xenballooned_pages);
--
2.27.0
next prev parent reply other threads:[~2020-07-24 12:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 12:42 [PATCH v2 0/4] xen/balloon: fixes for memory hotplug Roger Pau Monne
2020-07-24 12:42 ` Roger Pau Monne [this message]
2020-07-24 13:11 ` [PATCH v2 1/4] xen/balloon: fix accounting in alloc_xenballooned_pages error path Jürgen Groß
2020-07-24 12:42 ` [PATCH v2 2/4] xen/balloon: make the balloon wait interruptible Roger Pau Monne
2020-07-24 13:13 ` Jürgen Groß
2020-07-24 12:42 ` [PATCH v2 3/4] Revert "xen/balloon: Fix crash when ballooning on x86 32 bit PAE" Roger Pau Monne
2020-07-24 13:20 ` Jürgen Groß
2020-07-24 12:42 ` [PATCH v2 4/4] xen: add helpers to allocate unpopulated memory Roger Pau Monne
2020-07-24 14:33 ` Jürgen Groß
2020-07-24 14:34 ` David Hildenbrand
2020-07-24 16:36 ` Boris Ostrovsky
2020-07-27 8:00 ` David Hildenbrand
2020-07-27 8:42 ` Roger Pau Monné
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=20200724124241.48208-2-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sstabellini@kernel.org \
--cc=stable@vger.kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).