Skip to contentSkip to conversation

xen: cpu: change 'cpu_hotplug_[begin|done]' to inline function

PATCH Superseded Baodong Chen 3 participants 9 messages May 31, 2019 – Jun 3, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: cpu: change 'cpu_hotplug_[begin|done]' to inline function

---
 xen/common/cpu.c      | 10 ----------
 xen/include/xen/cpu.h |  4 ++--
 2 files changed, 2 insertions(+), 12 deletions(-)
xen/common/cpu.c +0 -10
index f388d89..a526b55 100644
@@ -51,16 +51,6 @@ void put_cpu_maps(void)
     spin_unlock_recursive(&cpu_add_remove_lock);
 }
 
-bool_t cpu_hotplug_begin(void)
-{
-    return get_cpu_maps();
-}
-
-void cpu_hotplug_done(void)
-{
-    put_cpu_maps();
-}
-
 static NOTIFIER_HEAD(cpu_chain);
 
 void __init register_cpu_notifier(struct notifier_block *nb)
xen/include/xen/cpu.h +2 -2
index 4638c50..70a2df4 100644
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
 void put_cpu_maps(void);
 
 /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }
 
 /* Receive notification of CPU hotplug events. */
 void register_cpu_notifier(struct notifier_block *nb);
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

Hi,

Quoted 32 lines · Baodong Chen
---
  xen/common/cpu.c      | 10 ----------
  xen/include/xen/cpu.h |  4 ++--
  2 files changed, 2 insertions(+), 12 deletions(-)
xen/common/cpu.c +0 -10
index f388d89..a526b55 100644
@@ -51,16 +51,6 @@ void put_cpu_maps(void)
      spin_unlock_recursive(&cpu_add_remove_lock);
  }
 
-bool_t cpu_hotplug_begin(void)
-{
-    return get_cpu_maps();
-}
-
-void cpu_hotplug_done(void)
-{
-    put_cpu_maps();
-}
-
  static NOTIFIER_HEAD(cpu_chain);
 
  void __init register_cpu_notifier(struct notifier_block *nb)
xen/include/xen/cpu.h +0 -0
index 4638c50..70a2df4 100644

xen/include/xen/cpu.h bool_t get_cpu_maps(void); · line 14

Quoted 7 lines
xen/include/xen/cpu.h +2 -2
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
  void put_cpu_maps(void);
 
  /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }

The coding style should be:

static inline....

{
      ...
}

xen/include/xen/cpu.h bool_t get_cpu_maps(void);

Quoted 4 lines
xen/include/xen/cpu.h +0 -0
  /* Receive notification of CPU hotplug events. */
  void register_cpu_notifier(struct notifier_block *nb);
 

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 31.05.19 at 12:55, <[email protected]> wrote:
Quoted 5 lines · Baodong Chen
xen/include/xen/cpu.h +0 -0
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
  void put_cpu_maps(void);
 
Quoted 5 lines

xen/include/xen/cpu.h bool_t get_cpu_maps(void); · line 14

Quoted 5 lines
xen/include/xen/cpu.h +2 -2
  /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }

Plus please switch to bool at the same time.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 31.05.19 at 12:55, <[email protected]> wrote:
Quoted 5 lines · Baodong Chen
xen/include/xen/cpu.h +0 -0
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
   void put_cpu_maps(void);
 
Quoted 6 lines
Quoted 5 lines

xen/include/xen/cpu.h bool_t get_cpu_maps(void); · line 14

Quoted 5 lines
xen/include/xen/cpu.h +2 -2
   /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }

Plus please switch to bool at the same time.

Yes, types like boot_t or u32 are getting rid of, so should Not be used.

Will be fixed.

Quoted 6 lines

Jan

.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
In reply to Julien Grall
Quoted 42 lines · Julien Grall

Hi,

Quoted 30 lines · Baodong Chen

---
  xen/common/cpu.c      | 10 ----------
  xen/include/xen/cpu.h |  4 ++--

  2 files changed, 2 insertions(+), 12 deletions(-)
xen/common/cpu.c +0 -9
index f388d89..a526b55 100644
@@ -51,16 +51,6 @@ void put_cpu_maps(void)
       spin_unlock_recursive(&cpu_add_remove_lock);
   }
   -bool_t cpu_hotplug_begin(void)
-{
-    return get_cpu_maps();
-}
-
-void cpu_hotplug_done(void)
-{
-    put_cpu_maps();
-}
-
   static NOTIFIER_HEAD(cpu_chain);
     void __init register_cpu_notifier(struct notifier_block *nb)
xen/include/xen/cpu.h +0 -0
index 4638c50..70a2df4 100644

xen/include/xen/cpu.h bool_t get_cpu_maps(void); · line 13

Quoted 6 lines
xen/include/xen/cpu.h +2 -2
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
   void put_cpu_maps(void);
     /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }

The coding style should be:

Quoted 5 lines

static inline....
{
      ...
}

Yes, clang-format automated format code for me, will be fixed.

Quoted 6 lines

xen/include/xen/cpu.h bool_t get_cpu_maps(void);

Quoted 3 lines
xen/include/xen/cpu.h +0 -0
     /* Receive notification of CPU hotplug events. */
   void register_cpu_notifier(struct notifier_block *nb);
 

Cheers,

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw

Hi,

Quoted 44 lines · chenbaodong
Quoted 42 lines · Julien Grall

Hi,

Quoted 30 lines · Baodong Chen

---
  xen/common/cpu.c      | 10 ----------
  xen/include/xen/cpu.h |  4 ++--

  2 files changed, 2 insertions(+), 12 deletions(-)
xen/common/cpu.c +0 -9
index f388d89..a526b55 100644
@@ -51,16 +51,6 @@ void put_cpu_maps(void)
       spin_unlock_recursive(&cpu_add_remove_lock);
   }
   -bool_t cpu_hotplug_begin(void)
-{
-    return get_cpu_maps();
-}
-
-void cpu_hotplug_done(void)
-{
-    put_cpu_maps();
-}
-
   static NOTIFIER_HEAD(cpu_chain);
     void __init register_cpu_notifier(struct notifier_block *nb)
xen/include/xen/cpu.h +0 -0
index 4638c50..70a2df4 100644

xen/include/xen/cpu.h bool_t get_cpu_maps(void); · line 13

Quoted 6 lines
xen/include/xen/cpu.h +2 -2
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
   void put_cpu_maps(void);
     /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }

The coding style should be:

Quoted 6 lines
Quoted 5 lines

static inline....
{
      ...
}

Yes, clang-format automated format code for me, will be fixed.

Hmmm, clang-format does not have Xen coding style support yet. Do you have patches on top to handle it?

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw
Quoted 48 lines · Julien Grall

Hi,

Quoted 45 lines · chenbaodong
Quoted 43 lines · Julien Grall

Hi,

Quoted 30 lines · Baodong Chen

---
  xen/common/cpu.c      | 10 ----------
  xen/include/xen/cpu.h |  4 ++--

  2 files changed, 2 insertions(+), 12 deletions(-)
xen/common/cpu.c +0 -9
index f388d89..a526b55 100644
@@ -51,16 +51,6 @@ void put_cpu_maps(void)
       spin_unlock_recursive(&cpu_add_remove_lock);
   }
   -bool_t cpu_hotplug_begin(void)
-{
-    return get_cpu_maps();
-}
-
-void cpu_hotplug_done(void)
-{
-    put_cpu_maps();
-}
-
   static NOTIFIER_HEAD(cpu_chain);
     void __init register_cpu_notifier(struct notifier_block *nb)
xen/include/xen/cpu.h +0 -0
index 4638c50..70a2df4 100644

xen/include/xen/cpu.h bool_t get_cpu_maps(void); · line 14

Quoted 7 lines
xen/include/xen/cpu.h +2 -2
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
   void put_cpu_maps(void);
     /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return 
 get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }

The coding style should be:

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

static inline....
{
      ...
}

Yes, clang-format automated format code for me, will be fixed.

Hmmm, clang-format does not have Xen coding style support yet. Do you have patches on top to handle it?

No, But the linux kernel seems already have it's clang-format support. Guess can used by xen.

IMO  i don't like the coding style in xen personally.

But it's code base has long years history. can insist on this or make some changes.

I prefer clang-format personally,  because no style issue in patch and will make review easier.

Quoted 3 lines

Cheers,

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw

Hi,

Quoted 54 lines · chenbaodong
Quoted 52 lines · Julien Grall

Hi,

Quoted 49 lines · chenbaodong
Quoted 47 lines · Julien Grall

Hi,

Quoted 30 lines · Baodong Chen

---
  xen/common/cpu.c      | 10 ----------
  xen/include/xen/cpu.h |  4 ++--

  2 files changed, 2 insertions(+), 12 deletions(-)
xen/common/cpu.c +0 -9
index f388d89..a526b55 100644
@@ -51,16 +51,6 @@ void put_cpu_maps(void)
       spin_unlock_recursive(&cpu_add_remove_lock);
   }
   -bool_t cpu_hotplug_begin(void)
-{
-    return get_cpu_maps();
-}
-
-void cpu_hotplug_done(void)
-{
-    put_cpu_maps();
-}
-
   static NOTIFIER_HEAD(cpu_chain);
     void __init register_cpu_notifier(struct notifier_block *nb)
xen/include/xen/cpu.h +0 -0
index 4638c50..70a2df4 100644

xen/include/xen/cpu.h bool_t get_cpu_maps(void); · line 13

Quoted 6 lines
xen/include/xen/cpu.h +2 -2
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
   void put_cpu_maps(void);
     /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }

The coding style should be:

static inline....
{
      ...
}

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, clang-format automated format code for me, will be fixed.

Hmmm, clang-format does not have Xen coding style support yet. Do you have patches on top to handle it?

No, But the linux kernel seems already have it's clang-format support. Guess can used by xen.

Most of Xen code base does not use Linux coding style. The only exception is file imported directly from Linux to ease porting bug fixes.

Quoted 2 lines

IMO  i don't like the coding style in xen personally.

I don't necessarily agree with all of it but some of the Linux style are odd too.

Quoted 2 lines

But it's code base has long years history. can insist on this or make some changes.

Improvement to the coding style are always welcomed. Although, you will notice that anything around coding style (in any project) is a matter of taste and can be difficult to find an agreement.

Quoted 2 lines

I prefer clang-format personally,  because no style issue in patch and will make review easier.

clang-format is not a coding style. It is a tool helping to format in a specific coding style. There are effort to extend clang-format for supporting Xen coding style.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#8 lore raw
Quoted 58 lines · Julien Grall

Hi,

Quoted 55 lines · chenbaodong
Quoted 53 lines · Julien Grall

Hi,

Quoted 50 lines · chenbaodong
Quoted 48 lines · Julien Grall

Hi,

Quoted 30 lines · Baodong Chen

---
  xen/common/cpu.c      | 10 ----------
  xen/include/xen/cpu.h |  4 ++--

  2 files changed, 2 insertions(+), 12 deletions(-)
xen/common/cpu.c +0 -9
index f388d89..a526b55 100644
@@ -51,16 +51,6 @@ void put_cpu_maps(void)
       spin_unlock_recursive(&cpu_add_remove_lock);
   }
   -bool_t cpu_hotplug_begin(void)
-{
-    return get_cpu_maps();
-}
-
-void cpu_hotplug_done(void)
-{
-    put_cpu_maps();
-}
-
   static NOTIFIER_HEAD(cpu_chain);
     void __init register_cpu_notifier(struct notifier_block *nb)
xen/include/xen/cpu.h +0 -0
index 4638c50..70a2df4 100644

xen/include/xen/cpu.h bool_t get_cpu_maps(void); · line 14

Quoted 7 lines
xen/include/xen/cpu.h +2 -2
@@ -10,8 +10,8 @@ bool_t get_cpu_maps(void);
   void put_cpu_maps(void);
     /* Safely perform CPU hotplug and update cpu_online_map, etc. */
-bool_t cpu_hotplug_begin(void);
-void cpu_hotplug_done(void);
+static inline bool_t cpu_hotplug_begin(void) { return 
 get_cpu_maps(); }
+static inline void cpu_hotplug_done(void) { put_cpu_maps(); }

The coding style should be:

static inline....
{
      ...
}

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Yes, clang-format automated format code for me, will be fixed.

Hmmm, clang-format does not have Xen coding style support yet. Do you have patches on top to handle it?

No, But the linux kernel seems already have it's clang-format support. Guess can used by xen.

Most of Xen code base does not use Linux coding style. The only exception is file imported directly from Linux to ease porting bug fixes.

Roger that.

Quoted 5 lines
Quoted 3 lines

IMO  i don't like the coding style in xen personally.

I don't necessarily agree with all of it but some of the Linux style are odd too.

yes yes,  Linux style, eg: 'tab', i also dislike.

Quoted 5 lines
Quoted 3 lines

But it's code base has long years history. can insist on this or make some changes.

Improvement to the coding style are always welcomed. Although, you will notice that anything around coding style (in any project) is a matter of taste and can be difficult to find an agreement.

Agree.

Quoted 5 lines
Quoted 3 lines

I prefer clang-format personally,  because no style issue in patch and will make review easier.

clang-format is not a coding style. It is a tool helping to format in a specific coding style. There are effort to extend clang-format for supporting Xen coding style.

Agree, For xen, it's worth to have it's '.clang-format' file according to it's style.

Quoted 3 lines

Cheers,

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel