From nobody Sat May 18 06:04:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=samsung.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519289226355750.6840924886448; Thu, 22 Feb 2018 00:47:06 -0800 (PST) Received: from localhost ([::1]:36780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eomWm-0001yZ-CI for importer@patchew.org; Thu, 22 Feb 2018 03:46:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eomVN-0001LN-EM for qemu-devel@nongnu.org; Thu, 22 Feb 2018 03:45:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eomVK-0002r4-7N for qemu-devel@nongnu.org; Thu, 22 Feb 2018 03:45:29 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:56663) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eomVJ-0002qF-PO for qemu-devel@nongnu.org; Thu, 22 Feb 2018 03:45:26 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180222084521euoutp0199830ed93bd7087e41d731eb245f1988~VmWgnmsfE2381523815euoutp01B; Thu, 22 Feb 2018 08:45:21 +0000 (GMT) Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180222084521eucas1p1c93dc215ab1a951948ea61c85b8ee078~VmWf46pB82647326473eucas1p1a; Thu, 22 Feb 2018 08:45:21 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id EB.44.05700.0238E8A5; Thu, 22 Feb 2018 08:45:20 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180222084520eucas1p16aa4a165d2e1c0f5ec4da12257eda269~VmWfHiyve2648526485eucas1p11; Thu, 22 Feb 2018 08:45:20 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F9.D8.04183.0238E8A5; Thu, 22 Feb 2018 08:45:20 +0000 (GMT) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4J00GS2MZBY120@eusync4.samsung.com>; Thu, 22 Feb 2018 08:45:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180222084521euoutp0199830ed93bd7087e41d731eb245f1988~VmWgnmsfE2381523815euoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519289121; bh=m8H9WB9kp/SXYcRNCJjfXDfn3Tr0MyGgBnmuaEjpT2E=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=PthFwWP8dC5uidiz6Wawwa9XbJ1iRd6IoZTtyJm332LTkixe94/H4jrHlq50KEfKD a6KpcOKeez2ht3vfcbXICkqCukHKVdwRMQKqRfHskBc8Y3tBiOqg6iDm7S6glUBwGw dCGusyKGNCR5O/jw+Th3cfdpPn5mNNDiY/R2+MJw= X-AuditID: cbfec7f2-1c1ff70000011644-ba-5a8e8320bf8e From: Alexey Perevalov To: qemu-devel@nongnu.org, dgilbert@redhat.com Date: Thu, 22 Feb 2018 11:45:07 +0300 Message-id: <1519289107-20251-2-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1519289107-20251-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRmVeSWpSXmKPExsWy7djP87oKzX1RBs0PTC3m3j3PYrFy8hIm i95t99gtTmw6yGzxqUHKYsv+b+wWx3t3sFjc2dLHZHH65mZ2B06PAy8Wsns8ubaZyeP9vqts Hn1bVjEGsERx2aSk5mSWpRbp2yVwZazv7WAueOBR0bbyClMD41OLLkZODgkBE4kLy84wdjFy cQgJrGCUmLJ0BwuE85lRYv+ybUAZDrCq5dulIOLLGCUetn1mg3C6mSS63t1mByliEzCQ2HfP FsQUEdCTmHA1EqSEWWAjo8TOO+9ZQLYJCzhInD/ZxwRSwyKgKjHvISNImFfAXeLd46WsEAfJ Sdw818kMYnMKeEis2j2XCWSOhMAENonpS2azQBS5SBxf+58NwhaWeHV8CzuELSNxeXI3C0RD O6NE985OVqhuRokz0/9CVdlLnLp5lQnEZhbgk5i0bTozxJe8Eh1tQhAlHhJfWncwQdiOEt+m N7JDPDybUWLyxU9MExilFjAyrGIUTy0tzk1PLTbMSy3XK07MLS7NS9dLzs/dxAiM0NP/jn/a wfj1UtIhRgEORiUe3g1lvVFCrIllxZW5hxglOJiVRHiXhvZFCfGmJFZWpRblxxeV5qQWH2KU 5mBREueN06iLEhJITyxJzU5NLUgtgskycXBKNTAmNVh4bXyWqZpU/2rFS82+LYeW7XbefOdi 76W5Wpun1rM8ejdrqUalkaPv7VkP5hb35t/6FD1htdLuhRpXlHMyA6a4HyyUncD+tHnvlbMv LB7vDch/ranz9cbjV9lOM6J5jYVfeeaYGR1c8+loqlDPnJC27isPfY+Ln7SaNFHqvMTi1k7v u9WhSizFGYmGWsxFxYkAJWtG2swCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkluLIzCtJLcpLzFFi42I5/e/4NV2F5r4og1OfeCzm3j3PYrFy8hIm i95t99gtTmw6yGzxqUHKYsv+b+wWx3t3sFjc2dLHZHH65mZ2B06PAy8Wsns8ubaZyeP9vqts Hn1bVjEGsERx2aSk5mSWpRbp2yVwZazv7WAueOBR0bbyClMD41OLLkYODgkBE4nl26W6GLk4 hASWMEr0zb7BCuH0Mkkcm/eVBaSITcBAYt89WxBTREBPYsLVSJASZoGNjBK/ZtwFqufkEBZw kDh/so8JpIZFQFVi3kNGkDCvgLvEu8dLwUokBOQkbp7rZAaxOQU8JFbtnssEYgsB1dyev5Np AiPPAkaGVYwiqaXFuem5xUZ6xYm5xaV56XrJ+bmbGIEBtO3Yzy07GLveBR9iFOBgVOLh3VDW GyXEmlhWXJl7iFGCg1lJhHdpaF+UEG9KYmVValF+fFFpTmrxIUZpDhYlcd7zBpVRQgLpiSWp 2ampBalFMFkmDk6pBsaq4NfWt/ZfOTDVk3G6R+mre9vrDXLnPV2qy+BbNmOWle+mD1pbjitI Wd8u32R5z/vJYYH3beardK/aLQ6ZIt42Zc3Leoce+ziBGGaVn6dTfcRmu3fUzrjmUx/s9Cgw MqhmxeeneyI+JvsIrV3Ftvzm3OdsQln3tTslOftlpsZfu9T6+LPsozAlluKMREMt5qLiRAAW ZAPXHAIAAA== X-CMS-MailID: 20180222084520eucas1p16aa4a165d2e1c0f5ec4da12257eda269 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180222084520eucas1p16aa4a165d2e1c0f5ec4da12257eda269 X-RootMTR: 20180222084520eucas1p16aa4a165d2e1c0f5ec4da12257eda269 References: <1519289107-20251-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.11 Subject: [Qemu-devel] [PATCH v4] migration: change blocktime type to uint32_t 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: lvivier@redhat.com, v.kuramshin@samsung.com, quintela@redhat.com, ash.billore@samsung.com, Alexey Perevalov , peterx@redhat.com, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Initially int64_t was used, but on PowerPC architecture, clang doesn't have atomic_*_8 function, so it produces link time error. QEMU is working with time as with 64bit value, but by fact 32 bit is enough with CLOCK_REALTIME. In this case blocktime will keep only 1200 hours time interval. Signed-off-by: Alexey Perevalov Acked-by: Eric Blake --- hmp.c | 4 ++-- migration/postcopy-ram.c | 52 ++++++++++++++++++++++++++++----------------= ---- migration/trace-events | 4 ++-- qapi/migration.json | 4 ++-- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/hmp.c b/hmp.c index be091e0..ec90043 100644 --- a/hmp.c +++ b/hmp.c @@ -267,7 +267,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) } =20 if (info->has_postcopy_blocktime) { - monitor_printf(mon, "postcopy blocktime: %" PRId64 "\n", + monitor_printf(mon, "postcopy blocktime: %u\n", info->postcopy_blocktime); } =20 @@ -275,7 +275,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) Visitor *v; char *str; v =3D string_output_visitor_new(false, &str); - visit_type_int64List(v, NULL, &info->postcopy_vcpu_blocktime, NULL= ); + visit_type_uint32List(v, NULL, &info->postcopy_vcpu_blocktime, NUL= L); visit_complete(v, &str); monitor_printf(mon, "postcopy vcpu blocktime: %s\n", str); g_free(str); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 05475e0..c46225c 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -63,16 +63,17 @@ struct PostcopyDiscardState { =20 typedef struct PostcopyBlocktimeContext { /* time when page fault initiated per vCPU */ - int64_t *page_fault_vcpu_time; + uint32_t *page_fault_vcpu_time; /* page address per vCPU */ uintptr_t *vcpu_addr; - int64_t total_blocktime; + uint32_t total_blocktime; /* blocktime per vCPU */ - int64_t *vcpu_blocktime; + uint32_t *vcpu_blocktime; /* point in time when last page fault was initiated */ - int64_t last_begin; + uint32_t last_begin; /* number of vCPU are suspended */ int smp_cpus_down; + uint64_t start_time; =20 /* * Handler for exit event, necessary for @@ -99,22 +100,23 @@ static void migration_exit_cb(Notifier *n, void *data) static struct PostcopyBlocktimeContext *blocktime_context_new(void) { PostcopyBlocktimeContext *ctx =3D g_new0(PostcopyBlocktimeContext, 1); - ctx->page_fault_vcpu_time =3D g_new0(int64_t, smp_cpus); + ctx->page_fault_vcpu_time =3D g_new0(uint32_t, smp_cpus); ctx->vcpu_addr =3D g_new0(uintptr_t, smp_cpus); - ctx->vcpu_blocktime =3D g_new0(int64_t, smp_cpus); + ctx->vcpu_blocktime =3D g_new0(uint32_t, smp_cpus); =20 ctx->exit_notifier.notify =3D migration_exit_cb; + ctx->start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); qemu_add_exit_notifier(&ctx->exit_notifier); return ctx; } =20 -static int64List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx) +static uint32List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx) { - int64List *list =3D NULL, *entry =3D NULL; + uint32List *list =3D NULL, *entry =3D NULL; int i; =20 for (i =3D smp_cpus - 1; i >=3D 0; i--) { - entry =3D g_new0(int64List, 1); + entry =3D g_new0(uint32List, 1); entry->value =3D ctx->vcpu_blocktime[i]; entry->next =3D list; list =3D entry; @@ -145,7 +147,7 @@ void fill_destination_postcopy_migration_info(Migration= Info *info) info->postcopy_vcpu_blocktime =3D get_vcpu_blocktime_list(bc); } =20 -static uint64_t get_postcopy_total_blocktime(void) +static uint32_t get_postcopy_total_blocktime(void) { MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyBlocktimeContext *bc =3D mis->blocktime_ctx; @@ -610,6 +612,13 @@ static int get_mem_fault_cpu_index(uint32_t pid) return -1; } =20 +static uint32_t get_low_time_offset(PostcopyBlocktimeContext *dc) +{ + int64_t start_time_offset =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - + dc->start_time; + return start_time_offset < 1 ? 1 : start_time_offset & UINT32_MAX; +} + /* * This function is being called when pagefault occurs. It * tracks down vCPU blocking time. @@ -624,7 +633,7 @@ static void mark_postcopy_blocktime_begin(uintptr_t add= r, uint32_t ptid, int cpu, already_received; MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyBlocktimeContext *dc =3D mis->blocktime_ctx; - int64_t now_ms; + uint32_t low_time_offset; =20 if (!dc || ptid =3D=3D 0) { return; @@ -634,14 +643,14 @@ static void mark_postcopy_blocktime_begin(uintptr_t a= ddr, uint32_t ptid, return; } =20 - now_ms =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + low_time_offset =3D get_low_time_offset(dc); if (dc->vcpu_addr[cpu] =3D=3D 0) { atomic_inc(&dc->smp_cpus_down); } =20 - atomic_xchg__nocheck(&dc->last_begin, now_ms); - atomic_xchg__nocheck(&dc->page_fault_vcpu_time[cpu], now_ms); - atomic_xchg__nocheck(&dc->vcpu_addr[cpu], addr); + atomic_xchg(&dc->last_begin, low_time_offset); + atomic_xchg(&dc->page_fault_vcpu_time[cpu], low_time_offset); + atomic_xchg(&dc->vcpu_addr[cpu], addr); =20 /* check it here, not at the begining of the function, * due to, check could accur early than bitmap_set in @@ -688,22 +697,20 @@ static void mark_postcopy_blocktime_end(uintptr_t add= r) MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyBlocktimeContext *dc =3D mis->blocktime_ctx; int i, affected_cpu =3D 0; - int64_t now_ms; bool vcpu_total_blocktime =3D false; - int64_t read_vcpu_time; + uint32_t read_vcpu_time, low_time_offset; =20 if (!dc) { return; } =20 - now_ms =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); - + low_time_offset =3D get_low_time_offset(dc); /* lookup cpu, to clear it, * that algorithm looks straighforward, but it's not * optimal, more optimal algorithm is keeping tree or hash * where key is address value is a list of */ for (i =3D 0; i < smp_cpus; i++) { - uint64_t vcpu_blocktime =3D 0; + uint32_t vcpu_blocktime =3D 0; =20 read_vcpu_time =3D atomic_fetch_add(&dc->page_fault_vcpu_time[i], = 0); if (atomic_fetch_add(&dc->vcpu_addr[i], 0) !=3D addr || @@ -711,7 +718,7 @@ static void mark_postcopy_blocktime_end(uintptr_t addr) continue; } atomic_xchg__nocheck(&dc->vcpu_addr[i], 0); - vcpu_blocktime =3D now_ms - read_vcpu_time; + vcpu_blocktime =3D low_time_offset - read_vcpu_time; affected_cpu +=3D 1; /* we need to know is that mark_postcopy_end was due to * faulted page, another possible case it's prefetched @@ -726,7 +733,8 @@ static void mark_postcopy_blocktime_end(uintptr_t addr) =20 atomic_sub(&dc->smp_cpus_down, affected_cpu); if (vcpu_total_blocktime) { - dc->total_blocktime +=3D now_ms - atomic_fetch_add(&dc->last_begin= , 0); + dc->total_blocktime +=3D low_time_offset - atomic_fetch_add( + &dc->last_begin, 0); } trace_mark_postcopy_blocktime_end(addr, dc, dc->total_blocktime, affected_cpu); diff --git a/migration/trace-events b/migration/trace-events index 59b1a2d..def03c4 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -115,8 +115,8 @@ process_incoming_migration_co_end(int ret, int ps) "ret= =3D%d postcopy-state=3D%d" process_incoming_migration_co_postcopy_end_main(void) "" migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" migration_set_outgoing_channel(void *ioc, const char *ioctype, const char = *hostname, void *err) "ioc=3D%p ioctype=3D%s hostname=3D%s err=3D%p" -mark_postcopy_blocktime_begin(uint64_t addr, void *dd, int64_t time, int c= pu, int received) "addr: 0x%" PRIx64 ", dd: %p, time: %" PRId64 ", cpu: %d,= already_received: %d" -mark_postcopy_blocktime_end(uint64_t addr, void *dd, int64_t time, int aff= ected_cpu) "addr: 0x%" PRIx64 ", dd: %p, time: %" PRId64 ", affected_cpu: %= d" +mark_postcopy_blocktime_begin(uint64_t addr, void *dd, uint32_t time, int = cpu, int received) "addr: 0x%" PRIx64 ", dd: %p, time: %u, cpu: %d, already= _received: %d" +mark_postcopy_blocktime_end(uint64_t addr, void *dd, uint32_t time, int af= fected_cpu) "addr: 0x%" PRIx64 ", dd: %p, time: %u, affected_cpu: %d" =20 # migration/rdma.c qemu_rdma_accept_incoming_migration(void) "" diff --git a/qapi/migration.json b/qapi/migration.json index 90d125c..c4737f8 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -175,8 +175,8 @@ '*setup-time': 'int', '*cpu-throttle-percentage': 'int', '*error-desc': 'str', - '*postcopy-blocktime' : 'int64', - '*postcopy-vcpu-blocktime': ['int64']} } + '*postcopy-blocktime' : 'uint32', + '*postcopy-vcpu-blocktime': ['uint32']} } =20 ## # @query-migrate: --=20 2.7.4