From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Alexey Kardashevskiy" <aik@ozlabs.ru>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"KONRAD Frederic" <frederic.konrad@adacore.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Peter Maydell" <peter.maydell@linaro.org>
Subject: [PATCH-for-6.1 v3 2/5] memory: Add memory_region_set_priority()
Date: Sat, 27 Mar 2021 15:34:49 +0100 [thread overview]
Message-ID: <20210327143452.1514392-3-f4bug@amsat.org> (raw)
In-Reply-To: <20210327143452.1514392-1-f4bug@amsat.org>
Add an helper to change the priority of a memory region at runtime.
Suggested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/exec/memory.h | 10 ++++++++++
softmmu/memory.c | 11 +++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 5728a681b27..6ad9ff83457 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1983,6 +1983,16 @@ void memory_region_set_size(MemoryRegion *mr, uint64_t size);
void memory_region_set_alias_offset(MemoryRegion *mr,
hwaddr offset);
+/**
+ * memory_region_set_priority: dynamically update the priority of a region.
+ *
+ * Dynamically updates the priority of a region.
+ *
+ * @mr: the #MemoryRegion to be updated.
+ * @priority: priority of the region.
+ */
+void memory_region_set_priority(MemoryRegion *mr, int priority);
+
/**
* memory_region_present: checks if an address relative to a @container
* translates into #MemoryRegion within @container
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 4fbeee02dc7..fdba938f299 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2504,6 +2504,17 @@ void memory_region_set_size(MemoryRegion *mr, uint64_t size)
memory_region_transaction_commit();
}
+void memory_region_set_priority(MemoryRegion *mr, int priority)
+{
+ if (priority == mr->priority) {
+ return;
+ }
+ memory_region_transaction_begin();
+ mr->priority = priority;
+ memory_region_update_pending = true;
+ memory_region_transaction_commit();
+}
+
static void memory_region_readd_subregion(MemoryRegion *mr)
{
MemoryRegion *container = mr->container;
--
2.26.2
next prev parent reply other threads:[~2021-03-27 14:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-27 14:34 [PATCH v3 0/5] memory: Add 'priority' property setter Philippe Mathieu-Daudé
2021-03-27 14:34 ` [PATCH-for-6.0 v3 1/5] memory: Fix memory_region 'priority' property sign Philippe Mathieu-Daudé
2021-03-27 14:34 ` Philippe Mathieu-Daudé [this message]
2021-03-27 14:34 ` [PATCH-for-6.1 v3 3/5] memory: Rename MemoryRegion object getters Philippe Mathieu-Daudé
2021-03-27 14:34 ` [PATCH-for-6.1 v3 4/5] memory: Add setter for MemoryRegion object 'size' property Philippe Mathieu-Daudé
2021-03-27 14:34 ` [PATCH-for-6.1 v3 5/5] memory: Add setter for MemoryRegion object 'priority' property Philippe Mathieu-Daudé
2021-03-27 16:58 ` [PATCH v3 0/5] memory: Add 'priority' property setter Peter Maydell
2021-03-27 18:44 ` Philippe Mathieu-Daudé
2021-03-27 19:43 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210327143452.1514392-3-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=aik@ozlabs.ru \
--cc=frederic.konrad@adacore.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).