Skip to contentSkip to conversation

xen: make multicall debug boot time selectable

PATCH Superseded Juergen Gross 2 participants 4 messages Jul 3, 2024 – Jul 8, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

PATCH 1/1 xen: make multicall debug boot time selectable

Today Xen multicall debugging needs to be enabled via modifying a define in a source file for getting debug data of multicall errors encountered by users.

Switch multicall debugging to depend on a boot parameter "xen_mc_debug" instead, enabling affected users to boot with the new parameter set in order to get better diagnostics.

Add printing all arguments of a single call for better diagnostics.

---
 .../admin-guide/kernel-parameters.txt         |   6 +
 arch/x86/xen/multicalls.c                     | 120 ++++++++++++++----
 2 files changed, 99 insertions(+), 27 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -0
index 27ec49af1bf2..b33d048e01d8 100644
@@ -7427,6 +7427,12 @@
 			Crash from Xen panic notifier, without executing late
 			panic() code such as dumping handler.
 
+	xen_mc_debug	[X86,XEN,EARLY]
+			Enable multicall debugging when running as a Xen PV guest.
+			Enabling this feature will reduce performance a little
+			bit, so it should only be enabled for obtaining extended
+			debug data in case of multicall errors.
+
 	xen_msr_safe=	[X86,XEN,EARLY]
 			Format: <bool>
 			Select whether to always use non-faulting (safe) MSR
arch/x86/xen/multicalls.c +93 -27

169 lines not on this page · raw message

Signature · 1 line
2.35.3
#1 lore raw
Quoted 19 lines · Juergen Gross
  
  #define MC_BATCH	32
arch/x86/xen/multicalls.c +0 -6
-#define MC_DEBUG	0
-
  #define MC_ARGS		(MC_BATCH * 16)
 
 
  struct mc_buffer {
  	unsigned mcidx, argidx, cbidx;
  	struct multicall_entry entries[MC_BATCH];
-#if MC_DEBUG
-	struct multicall_entry debug[MC_BATCH];
-	void *caller[MC_BATCH];
-#endif
  	unsigned char args[MC_ARGS];
  	struct callback {
  		void (*fn)(void *);

arch/x86/xen/multicalls.c struct mc_buffer { · line 50

Quoted 5 lines
arch/x86/xen/multicalls.c +2 -0
@@ -50,13 +46,84 @@ struct mc_buffer {
  	} callbacks[MC_BATCH];
  };
 
+struct mc_debug_data {
+	struct multicall_entry debug[MC_BATCH];

'entries'? It's a mc_debug_data's copy of mc_buffer's entries.

Also, would it be better to keep these fields as a struct of scalars and instead have the percpu array of this struct? Otherwise there is a whole bunch of [MC_BATCH] arrays, all of them really indexed by the same value. (And while at it, there is no reason to have callbacks[MC_BATCH] sized like that -- it has nothing to do with batch size and can probably be made smaller)

arch/x86/xen/multicalls.c struct mc_buffer { · line 57

Quoted 7 lines
arch/x86/xen/multicalls.c +6 -0
+	void *caller[MC_BATCH];
+	size_t argsz[MC_BATCH];
+};
+
  static DEFINE_PER_CPU(struct mc_buffer, mc_buffer);
+static struct mc_debug_data __percpu *mc_debug_data;
+static struct mc_debug_data mc_debug_data_early __initdata;

How about (I think this should work):

static struct mc_debug_data __percpu *mc_debug_data __refdata = &mc_debug_data_early;

Then you won't need get_mc_debug_ptr().

-boris

author maintainer
#2 lore raw
Quoted 17 lines · On 06.07.24 00:36, [email protected] wrote:
Quoted 13 lines · Juergen Gross

  #define MC_BATCH    32

arch/x86/xen/multicalls.c +0 -2
-#define MC_DEBUG    0
-

  #define MC_ARGS        (MC_BATCH * 16)
  struct mc_buffer {
      unsigned mcidx, argidx, cbidx;
      struct multicall_entry entries[MC_BATCH];

arch/x86/xen/multicalls.c +0 -4
-#if MC_DEBUG
-    struct multicall_entry debug[MC_BATCH];
-    void *caller[MC_BATCH];
-#endif

      unsigned char args[MC_ARGS];
      struct callback {

Quoted 8 lines

arch/x86/xen/multicalls.c struct mc_buffer { · line 49

Quoted 6 lines

          void (*fn)(void *);

arch/x86/xen/multicalls.c +2 -0
@@ -50,13 +46,84 @@ struct mc_buffer {
       } callbacks[MC_BATCH];
   };
+struct mc_debug_data {
+    struct multicall_entry debug[MC_BATCH];

'entries'? It's a mc_debug_data's copy of mc_buffer's entries.

Yes, this is better.

Quoted 1 line

Also, would it be better to keep these fields as a struct of scalars and instead have the percpu array of this struct? Otherwise there is a whole bunch of [MC_BATCH] arrays, all of them really indexed by the same value. (And while at it, there is no reason to have callbacks[MC_BATCH] sized like that -- it has nothing to do with batch size and can probably be made smaller)

As today the mc_buffer's entries are copied via a single memcpy(), there are 3 options:

- make mc_debug_data a percpu pointer to a single array, requiring to copy the mc_buffer's entries in a loop

- let struct mc_debug_data contain two arrays (entries[] and struct foo {}[], with struct foo containing the other pointers/values)

- keep the layout as in my patch

Regarding the callbacks: I think the max number of callbacks is indeed MC_BATCH, as for each batch member one callback might be requested. So I'd rather keep it the way it is today.

Quoted 10 lines

arch/x86/xen/multicalls.c struct mc_buffer { · line 57

Quoted 7 lines
arch/x86/xen/multicalls.c +6 -0
+    void *caller[MC_BATCH];
+    size_t argsz[MC_BATCH];
+};
+
   static DEFINE_PER_CPU(struct mc_buffer, mc_buffer);
+static struct mc_debug_data __percpu *mc_debug_data;
+static struct mc_debug_data mc_debug_data_early __initdata;

How about (I think this should work):

Quoted 3 lines

static struct mc_debug_data __percpu *mc_debug_data __refdata = &mc_debug_data_early;

Then you won't need get_mc_debug_ptr().

I like this idea.

Juergen

#3 lore raw
Quoted 9 lines · Jürgen Groß
Quoted 5 lines · On 06.07.24 00:36, [email protected] wrote:

Also, would it be better to keep these fields as a struct of scalars and instead have the percpu array of this struct? Otherwise there is a whole bunch of [MC_BATCH] arrays, all of them really indexed by the same value. (And while at it, there is no reason to have callbacks[MC_BATCH] sized like that -- it has nothing to do with batch size and can probably be made smaller)

As today the mc_buffer's entries are copied via a single memcpy(), there are 3 options:

Ah yes, it's memcpy, I didn't think of that. Then leaving it as is is the best.

Quoted 8 lines

- make mc_debug_data a percpu pointer to a single array, requiring to copy the mc_buffer's entries in a loop

- let struct mc_debug_data contain two arrays (entries[] and struct foo {}[],
  with struct foo containing the other pointers/values)

Quoted 5 lines

- keep the layout as in my patch

Regarding the callbacks: I think the max number of callbacks is indeed MC_BATCH, as for each batch member one callback might be requested. So I'd rather keep it the way it is today.

Right, I was trying to point out that it's the max number but I suspect it usually is smaller -- we currently ask for a callback in fewer than half of the cases where we submit a request.

-boris