Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751442AbdHFUOA (ORCPT ); Sun, 6 Aug 2017 16:14:00 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:54128 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751341AbdHFUN7 (ORCPT ); Sun, 6 Aug 2017 16:13:59 -0400 x-originating-ip: 107.180.71.197 From: kys@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com, sthemmin@microsoft.com Cc: Alex Ng , "K. Y. Srinivasan" Subject: [PATCH 2/5] Drivers: hv: balloon: Correctly update onlined page count Date: Sun, 6 Aug 2017 13:12:53 -0700 Message-Id: <1502050376-23662-2-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1502050348-23624-1-git-send-email-kys@exchange.microsoft.com> References: <1502050348-23624-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfFD/8Rzn6rY39n70MtH6ax6LFCV32b5ey9r7tChbMgGMfGfHKBHPRXVdjayU/R11H6NOdJlmszTL1YKkwxlbLXV+RjFyuCPLxUOPqwMJcq5HuaZw+Pxk p+c2ycpHqCWc+/nQxorhFGlK7NgpUTaI/mp7xUowwWYe4TzcvS0ruvsBnruYEGnES3mkEo3BkeqtFjaESBD5osP/+IwVrqLE0Q0WHdFkjKgCR2NFKOV15g/F U7WVusr+HnsVFN3PGDRrIZZfXtQ2aKVlNyVfVTqYEjKWjydnnMIZ7YykyHZDVIXAJeui0z3uP57hBUuCTGLxcdk93F5UO0C5hyq++e92taNyA0/eZ7ZJfaDM x9SSFKest78nE+BPJudyaLncQOCV8xsbzRbPvmMW1Ib2zhzUoXvnPhhPfagCkRyNrDVOGbJxEauT75GefmR1ZEAPyt78CRq+d2EnBXs3vgcKoWlIrcGdSgz7 Lp9H0auEPzmeJCphnIeO1AfnxzAE/N3c+aY9N3VtBU871zbAmP615qWz68Juaqy/9km6moJ4OIexu4ySBA5Bar9FPKVFZj9QBOq4roz/RQ5sDg3gyLHqSXSa wJA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1474 Lines: 41 From: Alex Ng Previously, num_pages_onlined was updated using value from memory online notifier. This is incorrect because they assume that all hot-added pages are online, even though we only online the amount that's backed by the host. We should update num_pages_onlined only when the balloon driver marks a page as online. Signed-off-by: Alex Ng Signed-off-by: K. Y. Srinivasan --- drivers/hv/hv_balloon.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index f5728de..0a5c318 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -584,10 +584,6 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val, switch (val) { case MEM_ONLINE: - spin_lock_irqsave(&dm_device.ha_lock, flags); - dm_device.num_pages_onlined += mem->nr_pages; - spin_unlock_irqrestore(&dm_device.ha_lock, flags); - /* Fall through */ case MEM_CANCEL_ONLINE: if (dm_device.ha_waiting) { dm_device.ha_waiting = false; @@ -644,6 +640,9 @@ static void hv_page_online_one(struct hv_hotadd_state *has, struct page *pg) __online_page_set_limits(pg); __online_page_increment_counters(pg); __online_page_free(pg); + + WARN_ON_ONCE(!spin_is_locked(&dm_device.ha_lock)); + dm_device.num_pages_onlined++; } static void hv_bring_pgs_online(struct hv_hotadd_state *has, -- 1.7.1