Skip to contentSkip to conversation

compatibility fallback and replacement of kernel function invoking

PATCH In review Jincheng Miao 3 participants 12 messages Dec 10, 2014 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover compatibility fallback and replacement of kernel function invoking

The related kernel function is:
- pci_num_vf, it is introduced from upstream linux-2.6.34. For RHEL-based kernel, it is defined from RHEL5.9.

- kstrtoul, this function is united kernel API to replace strict_strtoul in the furture. It is introduced from linux-2.6.39. For RHEL6, it is defined from RHEL6.4.

This patchset do some compatiblity work for these two functions, and replace strict_strtoul which is depleted from linux-3.18.

v3:
Adjust pci_num_vf() introduced RHEL version number.
Seperate "replace strict_strtoul with kstrtoul" into 3 patches for igb_uio,
kni, and xen_dom0. Add compat.h in kni and xen_dom0 for compatible with older kernels.

v2:
Merge these two patch in one patchset.
Compatible with old kernel for kstrtoul.
Compatible with RHEL6 for pci_num_vf.

Jincheng Miao (4):
igb_uio: compatible with upstream longterm kernel and RHEL
igb_uio: replace strict_strtoul with kstrtoul
kni: replace strict_strtoul with kstrtoul
xen_dom0: replace strict_strtoul with kstrtoul

 lib/librte_eal/linuxapp/igb_uio/compat.h        |   11 ++++++++++-
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c       |    4 ++--
 lib/librte_eal/linuxapp/kni/compat.h            |   16 ++++++++++++++++
 lib/librte_eal/linuxapp/kni/kni_vhost.c         |    2 +-
 lib/librte_eal/linuxapp/xen_dom0/compat.h       |   16 ++++++++++++++++
 lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c |    2 +-
 6 files changed, 46 insertions(+), 5 deletions(-)
 create mode 100644 lib/librte_eal/linuxapp/kni/compat.h
 create mode 100644 lib/librte_eal/linuxapp/xen_dom0/compat.h
#2 lore raw

PATCH 1/4 igb_uio: compatible with upstream longterm kernel and RHEL

In reply to a message not in the archive

Function pci_num_vf() is introduced from upstream linux-2.6.34. So this patch make compatible with longterm kernel linux-2.6.32.63.

For RHEL, function pci_num_vf() begins from RHEL5 update9. And it is stub-defined when CONFIG_PCI_IOV is not enabled.

So dropped the CONFIG_PCI_IOV checking of commit 11ba0426.

For other distro like RHEL behaved to pci_num_vf(), we could simply append following condition macro:
(!(defined(OTHER_RELEASE_CODE) && \
OTHER_RELEASE_CODE >= OTHER_RELEASE_VERSION(X, Y)))

---
 lib/librte_eal/linuxapp/igb_uio/compat.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
lib/librte_eal/linuxapp/igb_uio/compat.h +2 -1
index 676fa1b..a36f034 100644
@@ -21,7 +21,8 @@
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \
-	!defined(CONFIG_PCI_IOV)
+	(!(defined(RHEL_RELEASE_CODE) && \
+	 RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5, 9))) 
 
 static int pci_num_vf(struct pci_dev *dev)
 {
Signature · 1 line
1.7.1
#3 lore raw

PATCH 2/4 igb_uio: replace strict_strtoul with kstrtoul

In reply to a message not in the archive
Quoted 1 line

From upstream kernel commit 3db2e9cd, strict_strto* serial functions

are removed. So that we should directly used kstrtoul instead.

Kstrtoul exists from RHEL6.4, so for compatible with old kernel and RHEL, add some logic to igb_uio/compat.h, same as what we do for pci_num_vf().

---
 lib/librte_eal/linuxapp/igb_uio/compat.h  |    8 ++++++++
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c |    4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
lib/librte_eal/linuxapp/igb_uio/compat.h +8 -0
index a36f034..214d5de 100644
@@ -44,6 +44,14 @@ static int pci_num_vf(struct pci_dev *dev)
 
 #endif /* < 2.6.34 */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \
+        (!(defined(RHEL_RELEASE_CODE) && \
+           RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)))
+
+#define kstrtoul strict_strtoul
+
+#endif /* < 2.6.39 */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) && \
 	(!(defined(RHEL_RELEASE_CODE) && \
 	   RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 3)))
lib/librte_eal/linuxapp/igb_uio/igb_uio.c +2 -2
index d1ca26e..47ff2f3 100644
@@ -83,7 +83,7 @@ store_max_vfs(struct device *dev, struct device_attribute *attr,
 	unsigned long max_vfs;
 	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
 
-	if (0 != strict_strtoul(buf, 0, &max_vfs))
+	if (0 != kstrtoul(buf, 0, &max_vfs))
 		return -EINVAL;
 
 	if (0 == max_vfs)
@@ -174,7 +174,7 @@ store_max_read_request_size(struct device *dev,
 	unsigned long size = 0;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &size) != 0)
+	if (0 != kstrtoul(buf, 0, &size))
 		return -EINVAL;
 
 	ret = pcie_set_readrq(pci_dev, (int)size);
Signature · 1 line
1.7.1
#4 lore raw

PATCH 3/4 kni: replace strict_strtoul with kstrtoul

In reply to a message not in the archive
Quoted 1 line

From upstream kernel commit 3db2e9cd, strict_strto* serial functions

are removed. So that we should directly used kstrtoul instead.

And add kni/compat.h for be compatible with older kernel.

---
 lib/librte_eal/linuxapp/kni/compat.h    |   16 ++++++++++++++++
 lib/librte_eal/linuxapp/kni/kni_vhost.c |    2 +-
 2 files changed, 17 insertions(+), 1 deletions(-)
 create mode 100644 lib/librte_eal/linuxapp/kni/compat.h
lib/librte_eal/linuxapp/kni/compat.h new file +16 -0
new file mode 100644
index 0000000..c8c662c
@@ -0,0 +1,16 @@
+/*
+ * Minimal wrappers to allow compiling kni on older kernels.
+ */
+
+#ifndef RHEL_RELEASE_VERSION
+#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b))
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \
+        (!(defined(RHEL_RELEASE_CODE) && \
+           RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)))
+
+#define kstrtoul strict_strtoul
+
+#endif /* < 2.6.39 */
+
lib/librte_eal/linuxapp/kni/kni_vhost.c +1 -1
index 7bcc985..c05c868 100644
@@ -740,7 +740,7 @@ set_sock_en(struct device *dev, struct device_attribute *attr,
 	unsigned long en;
 	int err = 0;
 
-	if (0 != strict_strtoul(buf, 0, &en))
+	if (0 != kstrtoul(buf, 0, &en))
 		return -EINVAL;
 
 	if (en)
Signature · 1 line
1.7.1
#11 lore raw

PATCH 4/4 xen_dom0: replace strict_strtoul with kstrtoul

In reply to a message not in the archive
Quoted 1 line

From upstream kernel commit 3db2e9cd, strict_strto* serial functions

are removed. So that we should directly used kstrtoul instead.

And add xen_dom0/compat.h for be compatible with older kernel.

---
 lib/librte_eal/linuxapp/xen_dom0/compat.h       |   16 ++++++++++++++++
 lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c |    2 +-
 2 files changed, 17 insertions(+), 1 deletions(-)
 create mode 100644 lib/librte_eal/linuxapp/xen_dom0/compat.h
lib/librte_eal/linuxapp/xen_dom0/compat.h new file +16 -0
new file mode 100644
index 0000000..ca6e160
@@ -0,0 +1,16 @@
+/*
+ * Minimal wrappers to allow compiling xen_dom0 on older kernels.
+ */
+
+#ifndef RHEL_RELEASE_VERSION
+#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b))
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \
+        (!(defined(RHEL_RELEASE_CODE) && \
+           RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)))
+
+#define kstrtoul strict_strtoul
+
+#endif /* < 2.6.39 */
+
lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c +1 -1
index dfb271d..8a3727d 100644
@@ -123,7 +123,7 @@ store_memsize(struct device *dev, struct device_attribute *attr,
 	int err = 0;
 	unsigned long mem_size;
 
-	if (0 != strict_strtoul(buf, 0, &mem_size))
+	if (0 != kstrtoul(buf, 0, &mem_size))
 		return  -EINVAL;
 
 	mutex_lock(&dom0_dev.data_lock);
Signature · 1 line
1.7.1
Acked-by
#14 lore raw
In reply to a message not in the archive

Note: Don't forget to add the version number to your patch name next time. E.g. [PATCH v3 0/4]

Quoted 47 lines

-----Original Message-----
From: Jincheng Miao [mailto:[email protected]]
Sent: Wednesday, December 10, 2014 11:33 AM
To: [email protected]
Cc: [email protected]; Zhang, Helin; Jincheng Miao
Subject: [PATCH 0/4] compatibility fallback and replacement of kernel function invoking

The related kernel function is:
- pci_num_vf, it is introduced from upstream linux-2.6.34. For RHEL-based kernel, it is defined from RHEL5.9.

- kstrtoul, this function is united kernel API to replace strict_strtoul in the furture. It is introduced from linux-2.6.39. For RHEL6, it is defined from RHEL6.4.

This patchset do some compatiblity work for these two functions, and replace strict_strtoul which is depleted from linux-3.18.

v3:
Adjust pci_num_vf() introduced RHEL version number.
Seperate "replace strict_strtoul with kstrtoul" into 3 patches for igb_uio, kni,
and xen_dom0. Add compat.h in kni and xen_dom0 for compatible with older kernels.

v2:
Merge these two patch in one patchset.
Compatible with old kernel for kstrtoul.
Compatible with RHEL6 for pci_num_vf.

Jincheng Miao (4):
igb_uio: compatible with upstream longterm kernel and RHEL
igb_uio: replace strict_strtoul with kstrtoul
kni: replace strict_strtoul with kstrtoul
xen_dom0: replace strict_strtoul with kstrtoul

 lib/librte_eal/linuxapp/igb_uio/compat.h        |   11 ++++++++++-
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c       |    4 ++--
 lib/librte_eal/linuxapp/kni/compat.h            |   16
++++++++++++++++
 lib/librte_eal/linuxapp/kni/kni_vhost.c         |    2 +-
 lib/librte_eal/linuxapp/xen_dom0/compat.h       |   16
++++++++++++++++
 lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c |    2 +-
 6 files changed, 46 insertions(+), 5 deletions(-)  create mode 100644
lib/librte_eal/linuxapp/kni/compat.h
 create mode 100644 lib/librte_eal/linuxapp/xen_dom0/compat.h
#15 lore raw
In reply to a message not in the archive

Forget to add 'v3' in header.

@helin, thanks for your review.

Quoted 38 lines · Jincheng Miao

The related kernel function is:
- pci_num_vf, it is introduced from upstream linux-2.6.34. For RHEL-based kernel, it is defined from RHEL5.9.

- kstrtoul, this function is united kernel API to replace strict_strtoul in the furture. It is introduced from linux-2.6.39. For RHEL6, it is defined from RHEL6.4.

This patchset do some compatiblity work for these two functions, and replace strict_strtoul which is depleted from linux-3.18.

v3:
Adjust pci_num_vf() introduced RHEL version number.
Seperate "replace strict_strtoul with kstrtoul" into 3 patches for igb_uio,
kni, and xen_dom0. Add compat.h in kni and xen_dom0 for compatible with older kernels.

v2:
Merge these two patch in one patchset.
Compatible with old kernel for kstrtoul.
Compatible with RHEL6 for pci_num_vf.

Jincheng Miao (4):
igb_uio: compatible with upstream longterm kernel and RHEL
igb_uio: replace strict_strtoul with kstrtoul
kni: replace strict_strtoul with kstrtoul
xen_dom0: replace strict_strtoul with kstrtoul

  lib/librte_eal/linuxapp/igb_uio/compat.h        |   11 ++++++++++-
  lib/librte_eal/linuxapp/igb_uio/igb_uio.c       |    4 ++--
  lib/librte_eal/linuxapp/kni/compat.h            |   16 ++++++++++++++++
  lib/librte_eal/linuxapp/kni/kni_vhost.c         |    2 +-
  lib/librte_eal/linuxapp/xen_dom0/compat.h       |   16 ++++++++++++++++
  lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c |    2 +-
  6 files changed, 46 insertions(+), 5 deletions(-)

create mode 100644 lib/librte_eal/linuxapp/kni/compat.h create mode 100644 lib/librte_eal/linuxapp/xen_dom0/compat.h

#6 lore raw

Re: [PATCH 3/4] kni: replace strict_strtoul with kstrtoul

In reply to a message not in the archive

Hi Jincheng,

2014-12-10 11:33, Jincheng Miao:

Quoted 6 lines

From upstream kernel commit 3db2e9cd, strict_strto* serial functions are removed. So that we should directly used kstrtoul instead.

And add kni/compat.h for be compatible with older kernel.

[...]

Quoted 6 lines

new file mode 100644
index 0000000..c8c662c

lib/librte_eal/linuxapp/kni/compat.h new file +1 -0
@@ -0,0 +1,16 @@
+/*

lib/librte_eal/linuxapp/kni/compat.h line 11

Quoted 10 lines
lib/librte_eal/linuxapp/kni/compat.h new file +10 -0
+ * Minimal wrappers to allow compiling kni on older kernels.
+ */
+
+#ifndef RHEL_RELEASE_VERSION
+#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b))
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \
+        (!(defined(RHEL_RELEASE_CODE) && \
+           RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)))

The first indent character must be a tab (highlighted by checkpatch).

[...]

lib/librte_eal/linuxapp/kni/kni_vhost.c set_sock_en(struct device *dev, struct device_attribute *attr, · line 746

Quoted 11 lines
lib/librte_eal/linuxapp/kni/kni_vhost.c +1 -1
@@ -740,7 +740,7 @@ set_sock_en(struct device *dev, struct device_attribute *attr,
 	unsigned long en;
 	int err = 0;
 
-	if (0 != strict_strtoul(buf, 0, &en))
+	if (0 != kstrtoul(buf, 0, &en))
 		return -EINVAL;
 
 	if (en)

It seems you forgot to include the new compat.h.

Did you do some tests with different Fedora/RHEL versions?

Thanks

Signature · 1 line
Thomas
#13 lore raw

Re: [PATCH 4/4] xen_dom0: replace strict_strtoul with kstrtoul

In reply to a message not in the archive

2014-12-10 11:33, Jincheng Miao:

Quoted 6 lines

From upstream kernel commit 3db2e9cd, strict_strto* serial functions are removed. So that we should directly used kstrtoul instead.

And add xen_dom0/compat.h for be compatible with older kernel.

Same comments as patch 3/4 apply here.

Signature · 1 line
Thomas
#7 lore raw

Re: [PATCH 3/4] kni: replace strict_strtoul with kstrtoul

In reply to Thomas Monjalon

----- Original Message -----

Quoted 20 lines

Hi Jincheng,

2014-12-10 11:33, Jincheng Miao:

Quoted 6 lines

From upstream kernel commit 3db2e9cd, strict_strto* serial functions are removed. So that we should directly used kstrtoul instead.

And add kni/compat.h for be compatible with older kernel.

[...]

Quoted 10 lines

new file mode 100644
index 0000000..c8c662c

lib/librte_eal/linuxapp/kni/compat.h new file +5 -0
@@ -0,0 +1,16 @@
+/*
+ * Minimal wrappers to allow compiling kni on older kernels.
+ */
+
+#ifndef RHEL_RELEASE_VERSION
Quoted 8 lines

lib/librte_eal/linuxapp/kni/compat.h line 11

Quoted 6 lines
lib/librte_eal/linuxapp/kni/compat.h new file +6 -0
+#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b))
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \
+        (!(defined(RHEL_RELEASE_CODE) && \
+           RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)))

The first indent character must be a tab (highlighted by checkpatch).

Yes, I think the TAB is replaced by my vim :(

Quoted 13 lines

[...]

Quoted 11 lines
lib/librte_eal/linuxapp/kni/kni_vhost.c +1 -1
@@ -740,7 +740,7 @@ set_sock_en(struct device *dev, struct device_attribute
 *attr,
 	unsigned long en;
 	int err = 0;
 
-	if (0 != strict_strtoul(buf, 0, &en))
+	if (0 != kstrtoul(buf, 0, &en))
 		return -EINVAL;
 
Quoted 5 lines
Quoted 1 line

if (en)

It seems you forgot to include the new compat.h.

Did you do some tests with different Fedora/RHEL versions?

Yes, missing compat.h in kni_vhost.c.

And, I want to get your opinion about adding compat.h to kni and xen_dom0. The pros: easy to implement and minimal wrapper for older kernel.
The cons: there is so many compat.h, and the file kcompat.h also makes user confuse.

Quoted 5 lines

Thanks
--
Thomas

#9 lore raw

Re: [PATCH 3/4] kni: replace strict_strtoul with kstrtoul

In reply to a message not in the archive

2014-12-10 03:48, Jincheng Miao:

Quoted 9 lines
Quoted 3 lines

It seems you forgot to include the new compat.h.

Did you do some tests with different Fedora/RHEL versions?

Yes, missing compat.h in kni_vhost.c.

And, I want to get your opinion about adding compat.h to kni and xen_dom0. The pros: easy to implement and minimal wrapper for older kernel.

Yes I think it's the good approach.

Quoted 1 line

The cons: there is so many compat.h, and the file kcompat.h also makes user confuse.

Why kcompat makes user confuse?

Do you think you could send a new version quickly to integrate it in the next RC (probably today)?

Please test it with RHEL.

Thanks

Signature · 1 line
Thomas
#10 lore raw

Re: [PATCH 3/4] kni: replace strict_strtoul with kstrtoul

----- Original Message -----

Quoted 11 lines

2014-12-10 03:48, Jincheng Miao:

Quoted 9 lines
Quoted 3 lines

It seems you forgot to include the new compat.h.

Did you do some tests with different Fedora/RHEL versions?

Yes, missing compat.h in kni_vhost.c.

And, I want to get your opinion about adding compat.h to kni and xen_dom0. The pros: easy to implement and minimal wrapper for older kernel.

Quoted 6 lines

Yes I think it's the good approach.

Quoted 2 lines

The cons: there is so many compat.h, and the file kcompat.h also makes user confuse.

Why kcompat makes user confuse?

Because a lot of compat fallback in kcompat too. For example, for kni, there is compat.h and kcompat.h. I just confuse about it before.
But if you agree it, I will also agree it.

Quoted 5 lines

Do you think you could send a new version quickly to integrate it in the next RC (probably today)?

Please test it with RHEL.

Yes, I am working on it.

I will report my test result latter.

Jincheng Miao

Quoted 5 lines

Thanks
--
Thomas