Re: [PATCH rdma-next v3 03/11] RDMA/efa: Add the efa.h header file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20-Mar-19 21:23, Jason Gunthorpe wrote:
> On Wed, Mar 20, 2019 at 09:17:56PM +0200, Gal Pressman wrote:
>> On 20-Mar-19 21:13, Jason Gunthorpe wrote:
>>> On Wed, Mar 20, 2019 at 08:17:34PM +0200, Gal Pressman wrote:
>>>
>>>>> I haven't seen it yet, but I guess we have some core kernel code doing
>>>>> the pid now?
>>>>
>>>> Right, I'll start working on ibdev_{err,warn,...} helpers.
>>>
>>> Just copying the pattern in netdev is probably the thing to do,
>>> including the bit about deducing the device name under various
>>> conditions
>>>
>>> I also think we should have a ibdev_uapi_debug() which should be
>>> called for all the cases drivers have for uverbs calls checking
>>> arguments/etc
>>>
>>> Then we could have a global way to switch them on perhaps
>>
>> Global switch other than dynamic debug?
> 
> Maybe a way to trigger them all at once in existing dynamic debug?
> 
> I haven't looked

This is what I have in mind (without the uapi switch):

---
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index a9f29156e486..c7432902481a 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -147,6 +147,49 @@ static int ib_security_change(struct notifier_block *nb, unsigned long event,
 static void ib_policy_change_task(struct work_struct *work);
 static DECLARE_WORK(ib_policy_change_work, ib_policy_change_task);
 
+static void __ibdev_printk(const char *level, const struct ib_device *ibdev,
+			   struct va_format *vaf)
+{
+	if (ibdev && ibdev->dev.parent)
+		dev_printk_emit(level[1] - '0',
+				ibdev->dev.parent,
+				"%s %s %s: %pV",
+				dev_driver_string(ibdev->dev.parent),
+				dev_name(ibdev->dev.parent),
+				dev_name(&ibdev->dev),
+				vaf);
+	else if (ibdev)
+		printk("%s%s: %pV",
+		       level, dev_name(&ibdev->dev), vaf);
+	else
+		printk("%s(NULL ib_device): %pV", level, vaf);
+}
+
+#define define_ibdev_printk_level(func, level)                  \
+void func(const struct ib_device *ibdev, const char *fmt, ...)  \
+{                                                               \
+	struct va_format vaf;                                   \
+	va_list args;                                           \
+								\
+	va_start(args, fmt);                                    \
+								\
+	vaf.fmt = fmt;                                          \
+	vaf.va = &args;                                         \
+								\
+	__ibdev_printk(level, ibdev, &vaf);                     \
+								\
+	va_end(args);                                           \
+}                                                               \
+EXPORT_SYMBOL(func);
+
+define_ibdev_printk_level(ibdev_emerg, KERN_EMERG);
+define_ibdev_printk_level(ibdev_alert, KERN_ALERT);
+define_ibdev_printk_level(ibdev_crit, KERN_CRIT);
+define_ibdev_printk_level(ibdev_err, KERN_ERR);
+define_ibdev_printk_level(ibdev_warn, KERN_WARNING);
+define_ibdev_printk_level(ibdev_notice, KERN_NOTICE);
+define_ibdev_printk_level(ibdev_info, KERN_INFO);
+
 static struct notifier_block ibdev_lsm_nb = {
 	.notifier_call = ib_security_change,
 };
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index b5be093c5474..45a9422e0578 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -72,6 +72,21 @@ extern struct workqueue_struct *ib_wq;
 extern struct workqueue_struct *ib_comp_wq;
 extern struct workqueue_struct *ib_comp_unbound_wq;
 
+__printf(2, 3) __cold
+void ibdev_emerg(const struct ib_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void ibdev_alert(const struct ib_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void ibdev_crit(const struct ib_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void ibdev_err(const struct ib_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void ibdev_warn(const struct ib_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void ibdev_notice(const struct ib_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void ibdev_info(const struct ib_device *dev, const char *format, ...);
+
 union ib_gid {
 	u8	raw[16];
 	struct {




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux