Skip to contentSkip to conversation

RDMA/rxe: Make pr_fmt work

PATCH In review Yanjun.Zhu 4 participants 11 messages Mar 23, 2024 – Apr 8, 2024 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Yanjun.Zhu

author
#0 lore raw

PATCH 1/1 RDMA/rxe: Make pr_fmt work

From: Zhu Yanjun <[email protected]>

If the definition of pr_fmt is before the header file. The pr_fmt will be overwritten by the header file. So move the definition of pr_fmt to the below of the header file.

---
 drivers/infiniband/sw/rxe/rxe.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/infiniband/sw/rxe/rxe.h +5 -5
index d8fb2c7af30a..dc2d8dd2f681 100644
@@ -7,11 +7,6 @@
 #ifndef RXE_H
 #define RXE_H
 
-#ifdef pr_fmt
-#undef pr_fmt
-#endif
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 #include <linux/skbuff.h>
 
 #include <rdma/ib_verbs.h>
@@ -30,6 +25,11 @@
 #include "rxe_verbs.h"
 #include "rxe_loc.h"
 
+#ifdef pr_fmt
+#undef pr_fmt
+#endif
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 /*
  * Version 1 and Version 2 are identical on 64 bit machines, but on 32 bit
  * machines Version 2 has a different struct layout.
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Yanjun.Zhu

From: Zhu Yanjun <[email protected]>

If the definition of pr_fmt is before the header file. The pr_fmt will be overwritten by the header file. So move the definition of pr_fmt to the below of the header file.

Awesome. You fix my problem.

Quoted 38 lines
---
 drivers/infiniband/sw/rxe/rxe.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/infiniband/sw/rxe/rxe.h +5 -6
index d8fb2c7af30a..dc2d8dd2f681 100644
@@ -7,11 +7,6 @@
 #ifndef RXE_H
 #define RXE_H
 
-#ifdef pr_fmt
-#undef pr_fmt
-#endif
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 #include <linux/skbuff.h>
 
 #include <rdma/ib_verbs.h>
@@ -30,6 +25,11 @@
 #include "rxe_verbs.h"
 #include "rxe_loc.h"
 
+#ifdef pr_fmt
+#undef pr_fmt
+#endif
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 /*
  * Version 1 and Version 2 are identical on 64 bit machines, but on 32 bit
  * machines Version 2 has a different struct layout.
--

2.34.1

#2 lore raw
In reply to Yanjun.Zhu
Quoted 5 lines · Yanjun.Zhu

From: Zhu Yanjun <[email protected]>

If the definition of pr_fmt is before the header file. The pr_fmt will be overwritten by the header file. So move the definition of pr_fmt to the below of the header file.

what header file?

Jason

author
#3 lore raw
Quoted 7 lines · Jason Gunthorpe
Quoted 5 lines · Yanjun.Zhu

From: Zhu Yanjun <[email protected]>

If the definition of pr_fmt is before the header file. The pr_fmt will be overwritten by the header file. So move the definition of pr_fmt to the below of the header file.

what header file?

include/linux/printk.h

Because this driver will finally call printk function to output the logs, the header file include/linux/printk.h needs be included.

In include/linux/printk.h, pr_fmt is defined.

I made a simple checks. In about 130 header files, this pr_fmt is defined.

Zhu Yanjun

Quoted 2 lines

Jason

#4 lore raw
Quoted 8 lines · Zhu Yanjun
Quoted 6 lines · Jason Gunthorpe
Quoted 5 lines · Yanjun.Zhu

From: Zhu Yanjun <[email protected]>

If the definition of pr_fmt is before the header file. The pr_fmt will be overwritten by the header file. So move the definition of pr_fmt to the below of the header file.

Quoted 8 lines
Quoted 1 line

what header file?

include/linux/printk.h

Because this driver will finally call printk function to output the logs, the header file include/linux/printk.h needs be included.

In include/linux/printk.h, pr_fmt is defined.

This doesn't make sense, printk.h has:

#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif

Before or after printk.h should not have an impact.

Jason

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#6 lore raw
Quoted 17 lines · Zhu Yanjun
Quoted 14 lines · Jason Gunthorpe
Quoted 13 lines · Zhu Yanjun
Quoted 7 lines · Jason Gunthorpe
Quoted 5 lines · Yanjun.Zhu

From: Zhu Yanjun<[email protected]>

If the definition of pr_fmt is before the header file. The pr_fmt will be overwritten by the header file. So move the definition of pr_fmt to the below of the header file.

what header file?

include/linux/printk.h

Because this driver will finally call printk function to output the logs, the header file include/linux/printk.h needs be included.

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

In include/linux/printk.h, pr_fmt is defined.

This doesn't make sense, printk.h has:

#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif

Before or after printk.h should not have an impact.

Sorry. The previous mail is not sent successfully. I resend it.

Quoted 4 lines

#ifndef pr_fmt

...

Quoted 8 lines

#endif

The above will not undefine pr_fmt.

#undef pr_fmt will undefine pr_fmt.

This link explains the above in details.

https://www.techonthenet.com/c_language/directives/ifndef.php

Quoted 6 lines

Thanks a lot for your comments.

Zhu Yanjun

Quoted 1 line

Jason

#7 lore raw
Quoted 21 lines · Zhu Yanjun
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

Because this driver will finally call printk function to output the logs, the header file include/linux/printk.h needs be included.

In include/linux/printk.h, pr_fmt is defined.

This doesn't make sense, printk.h has:

#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif

Before or after printk.h should not have an impact.

Sorry. The previous mail is not sent successfully. I resend it.

Quoted 6 lines

#ifndef pr_fmt

...

#endif

Quoted 7 lines
Quoted 6 lines

The above will not undefine pr_fmt.

#undef pr_fmt will undefine pr_fmt.

This link explains the above in details.

https://www.techonthenet.com/c_language/directives/ifndef.php

Why would you want to undefine it? The point is to #define it to the rxe specific value. If it is already set to the rxe specific value before including printk.h then it will work fine?

Jason

author
#8 lore raw
Quoted 26 lines · Jason Gunthorpe
Quoted 25 lines · Zhu Yanjun
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

Because this driver will finally call printk function to output the logs, the header file include/linux/printk.h needs be included.

In include/linux/printk.h, pr_fmt is defined.

This doesn't make sense, printk.h has:

#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif

Before or after printk.h should not have an impact.

Sorry. The previous mail is not sent successfully. I resend it.

Quoted 10 lines

#ifndef pr_fmt

...

#endif

The above will not undefine pr_fmt.

#undef pr_fmt will undefine pr_fmt.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

This link explains the above in details.

https://www.techonthenet.com/c_language/directives/ifndef.php

Why would you want to undefine it? The point is to #define it to the rxe specific value. If it is already set to the rxe specific value before including printk.h then it will work fine?

Got your point. There are about more 130 header files that define pr_fmt in the kernel include directory. And these header files are included one another. Is there any tool to clarify the including relationship between these header files?

Thanks a lot
Zhu Yanjun

Quoted 2 lines

Jason

#9 lore raw
Quoted 4 lines · Zhu Yanjun

Got your point. There are about more 130 header files that define pr_fmt in the kernel include directory. And these header files are included one another. Is there any tool to clarify the including relationship between these header files?

No tool I am aware of, but if headers define it then they should be local to a subsystem and never included outside it. Such as what rxe is doing.

Ideally they would be private headers not under include/

Jason

#10 lore raw
In reply to Yanjun.Zhu
Quoted 10 lines · Yanjun.Zhu

From: Zhu Yanjun <[email protected]>

If the definition of pr_fmt is before the header file. The pr_fmt will be overwritten by the header file. So move the definition of pr_fmt to the below of the header file.

---
 drivers/infiniband/sw/rxe/rxe.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Let's just convert RXE to ibdev*() prints instead.

Thanks

author
#11 lore raw
Quoted 7 lines · Leon Romanovsky
Quoted 6 lines · Yanjun.Zhu

From: Zhu Yanjun <[email protected]>

If the definition of pr_fmt is before the header file. The pr_fmt will be overwritten by the header file. So move the definition of pr_fmt to the below of the header file.

Quoted 6 lines
Quoted 4 lines
---
  drivers/infiniband/sw/rxe/rxe.h | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

Let's just convert RXE to ibdev*() prints instead.

OK. I will do. But it takes me some time because it seems a big task.^_^

Zhu Yanjun

Quoted 2 lines

Thanks