Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add(function): modify find_first_bit function to support building on … #292

Merged
merged 2 commits into from
Nov 20, 2019

Conversation

wangzihao3
Copy link
Contributor

…arm64

Related to: openebs/openebs#1295

Modify the find_first_bit function in istgt_lu_disk.c, which is
implemented by using asm and cannot run on arm64. And add the
implementation by using c language.

Signed-off-by: wangzihao [email protected]

…arm64

Related to: openebs/openebs#1295

Modify the find_first_bit function in istgt_lu_disk.c, which is
implemented by using asm and cannot run on arm64. And add the
implementation by using c language.

Signed-off-by: wangzihao <[email protected]>
@mynktl
Copy link
Contributor

mynktl commented Nov 19, 2019

Hi @Wangzihao18
Thanks for the changes.

I think few more changes are required to build istgt for ARM architecture..

  1. need to add rte files for ARM. openebs-archive/libcstor@a534beb

  2. need update config.sub, config.guess. (automake --add-missing --copy --force-missing will generate the latest files)

diff --git a/src/istgt_lu.h b/src/istgt_lu.h
index a4144ec..690b7cc 100644
--- a/src/istgt_lu.h
+++ b/src/istgt_lu.h
@@ -57,7 +57,9 @@
 #include "ring_mempool.h"
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) && (defined(__aarch64__) || defined(__arm__))
+#include <aarch64-linux-gnu/sys/queue.h>
+#else
 #include <x86_64-linux-gnu/sys/queue.h>
 #endif
 #include <stdbool.h>

Details of the system used for compilation :

System Information
	Manufacturer: FOXCONN
	Product Name: R2-1221R-A4
	Version: 1A21MT100-600-G

Linux 4.15.0-36-generic #39~16.04.1-Ubuntu SMP aarch64 aarch64 aarch64 GNU/Linux

@wangzihao3
Copy link
Contributor Author

Hi @Wangzihao18
Thanks for the changes.

I think few more changes are required to build istgt for ARM architecture..

  1. need to add rte files for ARM. openebs/libcstor@a534beb
  2. need update config.sub, config.guess. (automake --add-missing --copy --force-missing will generate the latest files)
diff --git a/src/istgt_lu.h b/src/istgt_lu.h
index a4144ec..690b7cc 100644
--- a/src/istgt_lu.h
+++ b/src/istgt_lu.h
@@ -57,7 +57,9 @@
 #include "ring_mempool.h"
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) && (defined(__aarch64__) || defined(__arm__))
+#include <aarch64-linux-gnu/sys/queue.h>
+#else
 #include <x86_64-linux-gnu/sys/queue.h>
 #endif
 #include <stdbool.h>

Details of the system used for compilation :

System Information
	Manufacturer: FOXCONN
	Product Name: R2-1221R-A4
	Version: 1A21MT100-600-G

Linux 4.15.0-36-generic #39~16.04.1-Ubuntu SMP aarch64 aarch64 aarch64 GNU/Linux

Hi, @mynktl .Yes, thanks for your tips. Some changes can be seen in this commit wangzihao3@166463b. Because the modifications are little too much. I am not sure the changes are all right, So I split them up. I will continue update the other changes

@mynktl
Copy link
Contributor

mynktl commented Nov 19, 2019

Ok @Wangzihao18 . Thanks for the information!

res_final +=res;
if((unsigned long)res != nbits)
res_final += res;
if ((unsigned long)res != nbits)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we fix it for this case also as you did for aarch64? Can we put a check if ((unsigned long)res != nbits << 6) here also.

res += 64;
}
}
res_final += res;
Copy link
Contributor

@pawanpraka1 pawanpraka1 Nov 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets have these 3 lines common for both the case and put it out of #ifdef.

res += __builtin_ffsl(addr[idx]) - 1;
break;
} else {
res += 64;
Copy link
Contributor

@pawanpraka1 pawanpraka1 Nov 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sizeof (addr[0]) or sizeof (*addr) instead of constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thanks @pawanpraka1 . These changes are great. I will update them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question is, the value of sizeof(*addr) is 8, but we should plus 64 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I use sizeof(*addr) * 8or other methods ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. sizeof returns bytes, we should convert that to bits here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do sizeof(*addr) << 3 and put some comments saying we need bits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will update it now ^^

return res_final;
#elif defined(__aarch64__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also there is no aarch64 specific code here. Lets put this in #else section so that it works for all other architecture.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes , I am working on these codes.

Copy link
Contributor

@pawanpraka1 pawanpraka1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

@vishnuitta vishnuitta merged commit c3fa155 into openebs-archive:replication Nov 20, 2019
@mynktl
Copy link
Contributor

mynktl commented Nov 21, 2019

@Wangzihao18
Can you raise the next PR for rte header files and remaining changes?
Thanks!

@wangzihao3
Copy link
Contributor Author

@Wangzihao18
Can you raise the next PR for rte header files and remaining changes?
Thanks!

Sure @mynktl . I am working on it now. I can build it successfully, but I don't know how to test it. I will raise the PR now.

@mynktl
Copy link
Contributor

mynktl commented Nov 21, 2019

Ok @Wangzihao18 . We will test it in our lab.

@kmova kmova modified the milestones: 1.6.0, 1.5.0 Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants