* [Qemu-devel] [PATCH] make pci_bridge_region_cleanup to be done in rcu queue after flatview_destroy.
@ 2018-07-10 3:12 QiaoChong
0 siblings, 0 replies; 3+ messages in thread
From: QiaoChong @ 2018-07-10 3:12 UTC (permalink / raw)
To: qemu-devel; +Cc: qiaochong
pci_bridge_region_cleanup need to done after flatview_destroy,
because memory_region_unref need access memory regions in PCIBridgeWindows in flatview_destroy.
here we delay pci_bridge_region_cleanup to be done in rcu queue work.
bellow are gdb backtraces.
oldcode mr->name will be freed in object_unparent, before flatview_destroy.
0 _int_free (av=0x7fffe00bcb20 <main_arena>, p=0x555556a988c0, have_lock=0) at malloc.c:3947
1 0x00007fffdfd7c53c in __GI___libc_free (mem=<optimized out>) at malloc.c:2968
2 0x000055555587ad73 in memory_region_finalize (obj=<optimized out>) at /work/work/loongson/qemu/qemu-latest/memory.c:1731
3 0x0000555555b52e52 in object_deinit (type=0x5555565a54f0, obj=0x5555567dcbf0) at qom/object.c:462
4 object_finalize (data=0x5555567dcbf0) at qom/object.c:476
5 object_unref (obj=0x5555567dcbf0) at qom/object.c:924
6 0x0000555555b51e57 in object_property_del_child (obj=0x55555695f3d0, child=child@entry=0x5555567dcbf0, errp=0x0) at qom/object.c:436
7 0x0000555555b525e4 in object_unparent (obj=obj@entry=0x5555567dcbf0) at qom/object.c:455
8 0x0000555555a7bd70 in pci_bridge_region_cleanup (w=0x5555567dca10, br=<optimized out>) at hw/pci/pci_bridge.c:229
9 0x0000555555a7c336 in pci_bridge_update_mappings (br=<optimized out>) at hw/pci/pci_bridge.c:248
10 0x0000555555a7c3ba in pci_bridge_write_config (d=0x55555695f3d0, address=4, val=44040192, len=4) at hw/pci/pci_bridge.c:272
here mr mr->owner, mr->name has been freed in object_unparent before.
0 memory_region_unref_do (mr=0x5555567dcbf0) at /work/work/loongson/qemu/qemu-latest/memory.c:296
1 0x0000555555877c49 in flatview_destroy (view=0x555557344020) at /work/work/loongson/qemu/qemu-latest/memory.c:290
2 0x0000555555c4a0ae in call_rcu_thread (opaque=<optimized out>) at util/rcu.c:284
3 0x00007fffe00c96ba in start_thread (arg=0x7fffd007c700) at pthread_create.c:333
4 0x00007fffdfdff41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
void memory_region_unref(MemoryRegion *mr)
{
if (mr && mr->owner) {
object_unref(mr->owner);
}
}
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
---
hw/pci/pci_bridge.c | 14 +++++++++++++-
include/hw/pci/pci_bridge.h | 1 +
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index 40a39f5..c080471 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -233,6 +233,18 @@ static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)
g_free(w);
}
+/*
+ * pci_bridge_region_cleanup need to done after flatview_destroy,
+ * because memory_region_unref need access memory regions in PCIBridgeWindows
+ * in flatview_destroy.Here we delay pci_bridge_region_cleanup to be done
+ * in rcu queue work.
+ */
+
+static void pci_bridge_region_cleanup_schedule(PCIBridgeWindows *w)
+{
+ pci_bridge_region_cleanup(NULL, w);
+}
+
void pci_bridge_update_mappings(PCIBridge *br)
{
PCIBridgeWindows *w = br->windows;
@@ -243,7 +255,7 @@ void pci_bridge_update_mappings(PCIBridge *br)
pci_bridge_region_del(br, br->windows);
br->windows = pci_bridge_region_init(br);
memory_region_transaction_commit();
- pci_bridge_region_cleanup(br, w);
+ call_rcu(w, pci_bridge_region_cleanup_schedule, rcu);
}
/* default write_config function for PCI-to-PCI bridge */
diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h
index 0347da5..0e1fd82 100644
--- a/include/hw/pci/pci_bridge.h
+++ b/include/hw/pci/pci_bridge.h
@@ -37,6 +37,7 @@ typedef struct PCIBridgeWindows PCIBridgeWindows;
* as subregions.
*/
struct PCIBridgeWindows {
+ struct rcu_head rcu;
MemoryRegion alias_pref_mem;
MemoryRegion alias_mem;
MemoryRegion alias_io;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] make pci_bridge_region_cleanup to be done in rcu queue after flatview_destroy.
2018-07-10 2:44 QiaoChong
@ 2018-07-10 2:48 ` no-reply
0 siblings, 0 replies; 3+ messages in thread
From: no-reply @ 2018-07-10 2:48 UTC (permalink / raw)
To: qiaochong; +Cc: famz, qemu-devel
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 1531190661-19327-1-git-send-email-qiaochong@loongson.cn
Subject: [Qemu-devel] [PATCH] make pci_bridge_region_cleanup to be done in rcu queue after flatview_destroy.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/1531190661-19327-1-git-send-email-qiaochong@loongson.cn -> patchew/1531190661-19327-1-git-send-email-qiaochong@loongson.cn
Switched to a new branch 'test'
47be5f4199 make pci_bridge_region_cleanup to be done in rcu queue after flatview_destroy.
=== OUTPUT BEGIN ===
Checking PATCH 1/1: make pci_bridge_region_cleanup to be done in rcu queue after flatview_destroy....
ERROR: line over 90 characters
#55: FILE: hw/pci/pci_bridge.c:238:
+because memory_region_unref need access memory regions in PCIBridgeWindows in flatview_destroy.
total: 1 errors, 0 warnings, 31 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH] make pci_bridge_region_cleanup to be done in rcu queue after flatview_destroy.
@ 2018-07-10 2:44 QiaoChong
2018-07-10 2:48 ` no-reply
0 siblings, 1 reply; 3+ messages in thread
From: QiaoChong @ 2018-07-10 2:44 UTC (permalink / raw)
To: qemu-devel; +Cc: qiaochong
pci_bridge_region_cleanup need to done after flatview_destroy,
because memory_region_unref need access memory regions in PCIBridgeWindows in flatview_destroy.
here we delay pci_bridge_region_cleanup to be done in rcu queue work.
bellow are gdb backtraces.
oldcode mr->name will be freed in object_unparent, before flatview_destroy.
mask=<optimized out>, attrs=...) at /work/work/loongson/qemu/qemu-latest/memory.c:559
access_size_min=<optimized out>, access_size_max=<optimized out>, access_fn=0x555555876850 <memory_region_write_accessor>,
mr=0x5555569608c0, attrs=...) at /work/work/loongson/qemu/qemu-latest/memory.c:626
at /work/work/loongson/qemu/qemu-latest/memory.c:1518
buf=buf@entry=0x7fffbff0ae40 "", len=len@entry=4, addr1=4, l=4, mr=0x5555569608c0) at /work/work/loongson/qemu/qemu-latest/exec.c:3255
at /work/work/loongson/qemu/qemu-latest/exec.c:3294
at /work/work/loongson/qemu/qemu-latest/exec.c:2910
shift=<optimized out>, mask=<optimized out>, attrs=...) at /work/work/loongson/qemu/qemu-latest/memory.c:585
access_size_min=<optimized out>, access_size_max=<optimized out>, access_fn=0x555555874700 <memory_region_write_with_attrs_accessor>,
mr=0x555557338120, attrs=...) at /work/work/loongson/qemu/qemu-latest/memory.c:626
size=size@entry=4, attrs=...) at /work/work/loongson/qemu/qemu-latest/memory.c:1518
val=val@entry=44040192, addr=addr@entry=18446744072502722564, retaddr=retaddr@entry=140736012783717, recheck=false, size=4)
at /work/work/loongson/qemu/qemu-latest/accel/tcg/cputlb.c:905
mmu_idx=<optimized out>, env=0x55555681d218) at /work/work/loongson/qemu/qemu-latest/accel/tcg/softmmu_template.h:268
at /work/work/loongson/qemu/qemu-latest/accel/tcg/softmmu_template.h:304
at /work/work/loongson/qemu/qemu-latest/accel/tcg/cpu-exec.c:171
at /work/work/loongson/qemu/qemu-latest/accel/tcg/cpu-exec.c:612
here mr mr->owner, mr->name has been freed in object_unparent before.
void memory_region_unref(MemoryRegion *mr)
{
if (mr && mr->owner) {
object_unref(mr->owner);
}
}
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
---
hw/pci/pci_bridge.c | 12 +++++++++++-
include/hw/pci/pci_bridge.h | 1 +
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index 40a39f5..a3c9501 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -233,6 +233,16 @@ static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)
g_free(w);
}
+/*
+pci_bridge_region_cleanup need to done after flatview_destroy,
+because memory_region_unref need access memory regions in PCIBridgeWindows in flatview_destroy.
+here we delay pci_bridge_region_cleanup to be done in rcu queue work.
+*/
+static void pci_bridge_region_cleanup_schedule(PCIBridgeWindows *w)
+{
+ pci_bridge_region_cleanup(NULL, w);
+}
+
void pci_bridge_update_mappings(PCIBridge *br)
{
PCIBridgeWindows *w = br->windows;
@@ -243,7 +253,7 @@ void pci_bridge_update_mappings(PCIBridge *br)
pci_bridge_region_del(br, br->windows);
br->windows = pci_bridge_region_init(br);
memory_region_transaction_commit();
- pci_bridge_region_cleanup(br, w);
+ call_rcu(w, pci_bridge_region_cleanup_schedule, rcu);
}
/* default write_config function for PCI-to-PCI bridge */
diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h
index 0347da5..0e1fd82 100644
--- a/include/hw/pci/pci_bridge.h
+++ b/include/hw/pci/pci_bridge.h
@@ -37,6 +37,7 @@ typedef struct PCIBridgeWindows PCIBridgeWindows;
* as subregions.
*/
struct PCIBridgeWindows {
+ struct rcu_head rcu;
MemoryRegion alias_pref_mem;
MemoryRegion alias_mem;
MemoryRegion alias_io;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-10 3:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-10 3:12 [Qemu-devel] [PATCH] make pci_bridge_region_cleanup to be done in rcu queue after flatview_destroy QiaoChong
-- strict thread matches above, loose matches on Subject: below --
2018-07-10 2:44 QiaoChong
2018-07-10 2:48 ` no-reply
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.