From nobody Mon Feb 9 23:01:06 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529374492857944.9256638541073; Mon, 18 Jun 2018 19:14:52 -0700 (PDT) Received: from localhost ([::1]:38541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6AO-0006f8-0F for importer@patchew.org; Mon, 18 Jun 2018 22:14:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hh-0001Fu-OD for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hg-0008BW-Q0 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:05 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:44445) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hg-0008B0-KO; Mon, 18 Jun 2018 21:45:04 -0400 Received: by mail-oi0-x22f.google.com with SMTP id c128-v6so16677688oig.11; Mon, 18 Jun 2018 18:45:04 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id b63-v6sm7203885oia.4.2018.06.18.18.45.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:02 -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; bh=l4veLp1exqJh+BmHTGrlEpoYremYvuCgClF71MFZWnw=; b=PLbE4vVpnKvWqy/fyl9vGBD8n5i3RqVjpiZsm4cZ3PPZdQ9wlRZ7DvsnwtKeHb+Vu9 zFuiB/LTNIaNtc4DU01WKjN0vXfmq0aPAt+Yi9bWeZog75Ead94T2impx8mkoJTOhX8T jZxwRruREpYsuZZHIXnVUKmqBtAyTzI3FtIKApIVcGeOdUvQKk+2/3HxXkb6RAELwApM sTQdcgZ87qQ6a5su1TbTUh7IYBrWnlg/SVry6YLbRgtFRlsSCF5jsdM/gjt6gSb9AzFX LcmZg7W+eCHM429XD6L1vJRebfE9RzcEaQ5k8QB/2xX93OzOD7/7QEmJ1IJFOMmEjFzU chEA== 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; bh=l4veLp1exqJh+BmHTGrlEpoYremYvuCgClF71MFZWnw=; b=CNtGeFAxQLxJ2RvFlbyhXpPPQ7kJUsp4Jhzku7Y7ZXgW4kudrIsVYmFPC4JtytKlbD egLsagmMWSZPyNNAqiG7Spk2rPCy7F/evjtRzpxDa54BQwS8QvASyBd/toueZjoeSUTv JpcTbcuFHeekVWskaHgZLYI5XiL0rurXBz9E/zOxOPkXwZcgDsodiGBumVy26evEkbei QCeiVIhJDwoOkKsqa8mi08LZhOmUahUo3CsrrQwcqIygId4V5qzorntXdoyEyRz2n4SB 9QFkAhzaevpfZGETapC4SMXpBSY2DRXvz4+kIjuT5WPCg823sUkRXhrR9j89Jpc/nqRP kXEQ== X-Gm-Message-State: APt69E1M6NDXz0LFmXMYXsHjTzoH7zC0PL5vmB0ztPcHitdufEXvnEKX 2TnCqqzdQwS+a/mbVPolqjc12SZw X-Google-Smtp-Source: ADUXVKJszeCQhN2OeSiPkmY3rVaF/vVdEFSjXjYPXVhk6HhQteqk75xfQGROHKoHiFvAFQUaM5oKkQ== X-Received: by 2002:aca:a887:: with SMTP id r129-v6mr8469762oie.253.1529372703175; Mon, 18 Jun 2018 18:45:03 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:54 -0500 Message-Id: <20180619014319.28272-29-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22f Subject: [Qemu-devel] [PATCH 028/113] 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: , Cc: Paolo Bonzini , qemu-stable@nongnu.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" From: Paolo Bonzini 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 (cherry picked from commit 785a507ec78bbda1c346f3d3593e5a58b62e73ef) Signed-off-by: Michael Roth --- 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 98d82964cc..987ff115b8 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -20,7 +20,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 @@ -30,9 +38,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 5ed4042f87..ca544027fb 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -318,7 +318,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 226a7e8a2c..b2e23c31f4 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 2.11.0