RDMA/rxe: Make pr_fmt work
Subsystems (2)
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
@@ -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
Quoted 6 lines · Yanjun.Zhu
From: Zhu Yanjun <[email protected]>
If the definition of
pr_fmtis before the header file. Thepr_fmtwill be overwritten by the header file. So move the definition ofpr_fmtto the below of the header file.
Awesome. You fix my problem.
Quoted 38 lines
Signed-off-by Zhu Yanjun <[email protected]>--- drivers/infiniband/sw/rxe/rxe.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/infiniband/sw/rxe/rxe.h +5
-6@@ -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
Quoted 5 lines · Yanjun.Zhu
From: Zhu Yanjun <[email protected]>
If the definition of
pr_fmtis before the header file. Thepr_fmtwill be overwritten by the header file. So move the definition ofpr_fmtto the below of the header file.
what header file?
Jason
Quoted 7 lines · Jason Gunthorpe
Quoted 5 lines · Yanjun.Zhu
From: Zhu Yanjun <[email protected]>
If the definition of
pr_fmtis before the header file. Thepr_fmtwill be overwritten by the header file. So move the definition ofpr_fmtto 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
Quoted 10 lines · Yanjun.Zhu
From: Zhu Yanjun <[email protected]>
If the definition of
pr_fmtis before the header file. Thepr_fmtwill be overwritten by the header file. So move the definition ofpr_fmtto the below of the header file.Signed-off-by Zhu Yanjun <[email protected]>--- drivers/infiniband/sw/rxe/rxe.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Let's just convert RXE to ibdev*() prints instead.
Thanks
Quoted 7 lines · Leon Romanovsky
Quoted 6 lines · Yanjun.Zhu
From: Zhu Yanjun <[email protected]>
If the definition of
pr_fmtis before the header file. Thepr_fmtwill be overwritten by the header file. So move the definition ofpr_fmtto the below of the header file.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Zhu Yanjun <[email protected]>--- 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
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_fmtis before the header file. Thepr_fmtwill be overwritten by the header file. So move the definition ofpr_fmtto the below of the header file.
Quoted 8 lines
Quoted 1 line
what header file?
include/linux/printk.hBecause this driver will finally call printk function to output the logs, the header file
include/linux/printk.hneeds be included.In
include/linux/printk.h,pr_fmtis 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
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_fmtis before the header file. Thepr_fmtwill be overwritten by the header file. So move the definition ofpr_fmtto the below of the header file.what header file?
include/linux/printk.hBecause this driver will finally call printk function to output the logs, the header file
include/linux/printk.hneeds be included.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
In
include/linux/printk.h,pr_fmtis defined.This doesn't make sense,
printk.hhas:#ifndef
pr_fmt
#definepr_fmt(fmt)fmt
#endifBefore or after
printk.hshould 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_fmtwill undefinepr_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
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.hneeds be included.In
include/linux/printk.h,pr_fmtis defined.This doesn't make sense,
printk.hhas:#ifndef
pr_fmt
#definepr_fmt(fmt)fmt
#endifBefore or after
printk.hshould 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_fmtwill undefinepr_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
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.hneeds be included.In
include/linux/printk.h,pr_fmtis defined.This doesn't make sense,
printk.hhas:#ifndef
pr_fmt
#definepr_fmt(fmt)fmt
#endifBefore or after
printk.hshould 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_fmtwill undefinepr_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.hthen 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
Quoted 4 lines · Zhu Yanjun
Got your point. There are about more 130 header files that define
pr_fmtin 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