From patchwork Tue Aug 1 16:17:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 796318 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bs28dFTN"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xMM1s2Dt8z9tWR for ; Wed, 2 Aug 2017 02:18:25 +1000 (AEST) Received: from localhost ([::1]:43583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcZsF-0004LB-51 for incoming@patchwork.ozlabs.org; Tue, 01 Aug 2017 12:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcZrT-0004J0-QT for qemu-devel@nongnu.org; Tue, 01 Aug 2017 12:17:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcZrR-00079e-IE for qemu-devel@nongnu.org; Tue, 01 Aug 2017 12:17:35 -0400 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]:35210) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dcZrR-00079O-BL for qemu-devel@nongnu.org; Tue, 01 Aug 2017 12:17:33 -0400 Received: by mail-wr0-x230.google.com with SMTP id k71so8875502wrc.2 for ; Tue, 01 Aug 2017 09:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3phhBElh5R06fCTw2OQSxTgJjC7ZmvLYm7oJQm2q2RA=; b=bs28dFTNYEPVRyZkaYVZP/u5PG4OE6SNNar11NySBSjOmVM6Iq3mXlAee+OV6uw2i1 jUMWUITFDL6KlxCz+2BZru/pjLH1PgVPSrNLm8+LcurrvAsl7KiIHpydCDhn0FN+3QjF IzWzWq9Sa9muf06LcaiM2ml3doTvpzKrNZhP86Al+zB2V5Gkz7DWPSpzTfD1cRI4BmIg LBeciuGedAhCJaejg50+U5Mio/1uh2TuEPPaHW3ew+X6austMZxLIuH1qwBNAqzB6Ds5 tpf8wOkJuZWTmJAmLMdUdnfmVxtYbSta9rtiTquSslSGcwvOcHfI8tIM70GphvzSYAWl 8/Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3phhBElh5R06fCTw2OQSxTgJjC7ZmvLYm7oJQm2q2RA=; b=UnItUuooME37TYXUl7q0fdJrXVK4wOFR0p7/oM8MugqhAxRqLXW2fT4G6KwOZqfXoY 8GJm8EDKVlOVTCDFrltTNMgrN7/Kfoebuf0fa1VVOP8JlHnnzwg/V+z0+/MmWaY4LxPf WH2esuRtb357Q5AFssoSN16fZNI4t6saoHaBDOdf9Mm2CK79Ois74KaDTl+2RNx1CH4E oWa0SPdgKHzPlXL6PArejO5pzFQJVSTDPGMzo0M0qUL0mNMAhYabURAatNaZOJhX0QqF Dvr34QXHiYtKv32T47ZEe93XAdbtVhdJ71dXR9cqp+JQXMJF2WfZaoZvTAWxh3Xpq3Ew 3xcg== X-Gm-Message-State: AIVw1104oSTHzO17kVzuFzZM+YIpzHIYC8Kgh6e+slqJ9WyIPFJUryTu bZWz3aGFq26yEO2xrZA= X-Received: by 10.223.179.211 with SMTP id x19mr1937441wrd.7.1501604252051; Tue, 01 Aug 2017 09:17:32 -0700 (PDT) Received: from 640k.lan (94-39-192-75.adsl-ull.clienti.tiscali.it. [94.39.192.75]) by smtp.gmail.com with ESMTPSA id u187sm1724160wmd.26.2017.08.01.09.17.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Aug 2017 09:17:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 1 Aug 2017 18:17:10 +0200 Message-Id: <1501604245-33460-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1501604245-33460-1-git-send-email-pbonzini@redhat.com> References: <1501604245-33460-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::230 Subject: [Qemu-devel] [PULL 02/17] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Dr. David Alan Gilbert" This code has an optimised, word aligned version, and a boring unaligned version. Recently 084140bd498909 fixed a missing offset addition from the core of both versions. However, the offset isn't necessarily aligned and thus the choice between the two versions needs fixing up to also include the offset. Symptom: A few stuck unsent pages during migration; not normally noticed unless under very low bandwidth in which case the migration may get stuck never ending and never performing a 2nd sync; noticed by a hanging postcopy-test on a very heavily loaded system. Fixes: 084140bd498909 Signed-off-by: Dr. David Alan Gilbert Reported-by: Alex Benneé Tested-by: Alex Benneé --- v2 Move 'page' inside the if (Comment from Paolo) Message-Id: <20170724165125.29887-1-dgilbert@redhat.com> Signed-off-by: Paolo Bonzini --- include/exec/ram_addr.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index c04f4f6..d017639 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -377,19 +377,20 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb, uint64_t *real_dirty_pages) { ram_addr_t addr; - unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS); + unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS); uint64_t num_dirty = 0; unsigned long *dest = rb->bmap; /* start address is aligned at the start of a word? */ - if (((page * BITS_PER_LONG) << TARGET_PAGE_BITS) == start) { + if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) == + (start + rb->offset)) { int k; int nr = BITS_TO_LONGS(length >> TARGET_PAGE_BITS); unsigned long * const *src; - unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS); unsigned long idx = (word * BITS_PER_LONG) / DIRTY_MEMORY_BLOCK_SIZE; unsigned long offset = BIT_WORD((word * BITS_PER_LONG) % DIRTY_MEMORY_BLOCK_SIZE); + unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS); rcu_read_lock();