From nobody Sat Oct 25 09:08:52 2025 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520342825670763.5441118529196; Tue, 6 Mar 2018 05:27:05 -0800 (PST) Received: from localhost ([::1]:55733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etCcS-0003nV-Kd for importer@patchew.org; Tue, 06 Mar 2018 08:27:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etCVc-0005Gs-IR for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:20:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etCVW-0006NO-F2 for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:20:00 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:39657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1etCVW-0006Mh-95 for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:19:54 -0500 Received: by mail-wr0-x241.google.com with SMTP id w77so20920129wrc.6 for ; Tue, 06 Mar 2018 05:19:54 -0800 (PST) Received: from 640k.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id l38sm25652538wrc.96.2018.03.06.05.19.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 05:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=ejuOZ4fycEmyLZGVgVLzduy4qGDCYyllGJMr3iKT+Iw=; b=gMUq8Qq4POuEslZclOUGk3hQpyCgK9g71Zrrm0gFyO6diIRL4KPfk9tL/I9SD/oOYh hIBdUC/bQFRg0bYRifrk/fVHCpJqTSuVnoQFxTjfloikyRzhLc5SNwxE5zMf+7HB2O/A z0CiWMJwgTiQeqkzXZotxneDXylg6N0CBx6vjLsoxphN1KOZKxMqDnsl/Ns7DdURqFEk KMfvNm44xVPvhd6KSNmmn0pcxBNG67tZ+VUqz3CtS2bQ5fwiRmshxkmn3JBffqZf35mN J0McrCj5/VTxy2ic4nu8XCwIy8CRxCJSuEAOtNyMbDFQkQXIHYKTtP2T/W6LbYqiRtDH gqjA== 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:subject:date:message-id :in-reply-to:references; bh=ejuOZ4fycEmyLZGVgVLzduy4qGDCYyllGJMr3iKT+Iw=; b=ccg2YUxbzB3MFri8hMQvDqP7ccqF8U3lhBJVfQEVzR4RrEnxk89w6kKBEP+OG9ajBE mz27sja3Xq3qdx2DGc5bRTaScTL98Ao3cs1NWzTcdYPVMaTADa5uDk10vK0y2rP5ht3Q 8v2Ci8QhK/OhJb3g2oHXY00P288MeGLWVmPX/0U/ZRM2xSJXS6SpWC2BbhSXtub0AB9L 9C+NhdsrNievNiTb+KLwP018+F3YTyybFRlIWKTZAHRCnEfS4H4x/cVmdYDN4NOUbKM2 WkiX3aeMIXybTtYN5+zMc0WSTe9Cn5t7GLWV5qrwzrcuHGGCQV5c+5TfQJhKcbZsMwWb j1cg== X-Gm-Message-State: APf1xPCzDFHI44c9mBB86shF+Ym7ZdYe3yskEwAFin+Q7EentVFbJgPM uAuT5CHPNrx95b/GOZEdhhbPnpuX X-Google-Smtp-Source: AG47ELuwKMluna1yckpRUy39DrNzjFDSnFJYgAOkH8ErEsZ22kAPg1qJv+ShjGzRmK76jT3XQBdcRw== X-Received: by 10.223.190.17 with SMTP id n17mr14929224wrh.189.1520342392730; Tue, 06 Mar 2018 05:19:52 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Mar 2018 14:19:12 +0100 Message-Id: <1520342370-123606-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520342370-123606-1-git-send-email-pbonzini@redhat.com> References: <1520342370-123606-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 16/34] memory: inline some performance-sensitive accessors 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: , 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" These accessors are called from inlined functions, and the call sequence is much more expensive than just inlining the access. Move the struct declaration to memory-internal.h so that exec.c and memory.c can both use an inline function. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini --- include/exec/memory-internal.h | 13 +++++++++---- include/exec/memory.h | 22 +++++++++++++++++++++- memory.c | 30 ------------------------------ 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index 4162474..6a5ee42 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -21,7 +21,15 @@ #define MEMORY_INTERNAL_H =20 #ifndef CONFIG_USER_ONLY -typedef struct AddressSpaceDispatch AddressSpaceDispatch; +static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv) +{ + return fv->dispatch; +} + +static inline AddressSpaceDispatch *address_space_to_dispatch(AddressSpace= *as) +{ + return flatview_to_dispatch(address_space_to_flatview(as)); +} =20 extern const MemoryRegionOps unassigned_mem_ops; =20 @@ -31,9 +39,6 @@ bool memory_region_access_valid(MemoryRegion *mr, hwaddr = addr, void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); void address_space_dispatch_compact(AddressSpaceDispatch *d); - -AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as); -AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv); void address_space_dispatch_free(AddressSpaceDispatch *d); =20 void mtree_print_dispatch(fprintf_function mon, void *f, diff --git a/include/exec/memory.h b/include/exec/memory.h index 15e8111..4b65b56 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -326,7 +326,27 @@ struct AddressSpace { QTAILQ_ENTRY(AddressSpace) address_spaces_link; }; =20 -FlatView *address_space_to_flatview(AddressSpace *as); +typedef struct AddressSpaceDispatch AddressSpaceDispatch; +typedef struct FlatRange FlatRange; + +/* Flattened global view of current active memory hierarchy. Kept in sort= ed + * order. + */ +struct FlatView { + struct rcu_head rcu; + unsigned ref; + FlatRange *ranges; + unsigned nr; + unsigned nr_allocated; + struct AddressSpaceDispatch *dispatch; + MemoryRegion *root; +}; + +static inline FlatView *address_space_to_flatview(AddressSpace *as) +{ + return atomic_rcu_read(&as->current_map); +} + =20 /** * MemoryRegionSection: describes a fragment of a #MemoryRegion diff --git a/memory.c b/memory.c index 6515131..e70b64b 100644 --- a/memory.c +++ b/memory.c @@ -210,8 +210,6 @@ static bool memory_region_ioeventfd_equal(MemoryRegionI= oeventfd a, && !memory_region_ioeventfd_before(b, a); } =20 -typedef struct FlatRange FlatRange; - /* Range of memory in the global map. Addresses are absolute. */ struct FlatRange { MemoryRegion *mr; @@ -222,19 +220,6 @@ struct FlatRange { bool readonly; }; =20 -/* Flattened global view of current active memory hierarchy. Kept in sort= ed - * order. - */ -struct FlatView { - struct rcu_head rcu; - unsigned ref; - FlatRange *ranges; - unsigned nr; - unsigned nr_allocated; - struct AddressSpaceDispatch *dispatch; - MemoryRegion *root; -}; - typedef struct AddressSpaceOps AddressSpaceOps; =20 #define FOR_EACH_FLAT_RANGE(var, view) \ @@ -322,21 +307,6 @@ static void flatview_unref(FlatView *view) } } =20 -FlatView *address_space_to_flatview(AddressSpace *as) -{ - return atomic_rcu_read(&as->current_map); -} - -AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv) -{ - return fv->dispatch; -} - -AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as) -{ - return flatview_to_dispatch(address_space_to_flatview(as)); -} - static bool can_merge(FlatRange *r1, FlatRange *r2) { return int128_eq(addrrange_end(r1->addr), r2->addr.start) --=20 1.8.3.1