mbox series

[liburing,v2,0/8] aarch64 support

Message ID 20220629175255.1377052-1-ammar.faizi@intel.com (mailing list archive)
Headers show
Series aarch64 support | expand

Message

Ammar Faizi June 29, 2022, 5:58 p.m. UTC
From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Hi Jens,

This is v2 revision of aarch64 support.

This series contains nolibc support for aarch64 and one extra irrelevant
cleanup (patch #1). The missing bit from aarch64 is get_page_size()
which is a bit complicated to implement without libc.

aarch64 supports three values of page size: 4K, 16K, and 64K which are
selected at kernel compilation time. Therefore, we can't hard code the
page size for this arch. In this series we utilize open(), read() and
close() syscall to find the page size from /proc/self/auxv.

The auxiliary vector contains information about the page size, it is
located at `AT_PAGESZ` keyval pair.

For more details about the auxv data structure, check the link below.

Link: https://github.com/torvalds/linux/blob/v5.19-rc4/fs/binfmt_elf.c#L260
Link: https://lwn.net/Articles/631631/

There are 8 patches in this series. Summary:

- Patch 1 is just a trivial changelog fix.
- Patch 2 and 3 are to add open() and read() syscall. We will need them
  to get the page size on aarch64.
- Patch 4 is to remove __INTERNAL__LIBURING_SYSCALL_H checks.
- Patch 5 is to add get_page_size() function.
- Patch 6 is to enable the nolibc support for aarch64.
- Patch 7 is for GitHub bot build.
- Patch 8 is to update the CHANGELOG to note aarch64 nolibc support.

I have built it with GitHub bot and it compiles just fine. But I don't
have an aarch64 machine to run the tests. Since you are using aarch64,
I can rely on you to test it.

How to test this?

  make clean;
  ./configure --nolibc;
  make -j8;

  ldd src/liburing.so.2.3;
  # Make sure you don't see libc.so from the `ldd` command.

  make runtests;

Please give it a test, thanks!

## Changelog

v1 -> v2:
  - Drop aarch64 renaming directory patch.
  - Fallback the page size to 4K if we fail to get it.
  - Cache the page size after we read it from /proc/self/auxv.
  - Massage commit messages.
  - Note aarch64 nolibc support in CHANGELOG.


Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---

Ammar Faizi (8):
  CHANGELOG: Fixup missing space
  arch: syscall: Add `__sys_open()` syscall
  arch: syscall: Add `__sys_read()` syscall
  arch: Remove `__INTERNAL__LIBURING_LIB_H` checks
  arch/aarch64: lib: Add `get_page_size()` function
  arch: Enable nolibc support for aarch64
  .github: Enable aarch64 nolibc build for GitHub bot
  CHANGELOG: Note about aarch64 support

 .github/workflows/build.yml |  2 +-
 CHANGELOG                   |  7 +++++-
 src/arch/aarch64/lib.h      | 45 +++++++++++++++++++++++++++++++++++++
 src/arch/aarch64/syscall.h  |  8 +++----
 src/arch/generic/lib.h      |  4 ----
 src/arch/generic/syscall.h  | 20 +++++++++++++----
 src/arch/syscall-defs.h     | 12 ++++++++++
 src/arch/x86/lib.h          |  4 ----
 src/arch/x86/syscall.h      |  4 ----
 src/lib.h                   | 32 +++++++++++++-------------
 src/syscall.h               |  2 --
 11 files changed, 100 insertions(+), 40 deletions(-)
 create mode 100644 src/arch/aarch64/lib.h


base-commit: 7d1cce2112ddf358b56ae0abd18c86e8ede9447f

Comments

Ammar Faizi July 4, 2022, 12:52 p.m. UTC | #1
On 6/30/22 12:58 AM, Ammar Faizi wrote:
> From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> 
> Hi Jens,
> 
> This is v2 revision of aarch64 support.
> 
> This series contains nolibc support for aarch64 and one extra irrelevant
> cleanup (patch #1). The missing bit from aarch64 is get_page_size()
> which is a bit complicated to implement without libc.
> 
> aarch64 supports three values of page size: 4K, 16K, and 64K which are
> selected at kernel compilation time. Therefore, we can't hard code the
> page size for this arch. In this series we utilize open(), read() and
> close() syscall to find the page size from /proc/self/auxv.
> 
> The auxiliary vector contains information about the page size, it is
> located at `AT_PAGESZ` keyval pair.

This no longer applies, I will send v3 revision soon. If you have some
comments, let me know so I can address it together with the rebase.
Jens Axboe July 4, 2022, 1:05 p.m. UTC | #2
On 7/4/22 6:52 AM, Ammar Faizi wrote:
> On 6/30/22 12:58 AM, Ammar Faizi wrote:
>> From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
>>
>> Hi Jens,
>>
>> This is v2 revision of aarch64 support.
>>
>> This series contains nolibc support for aarch64 and one extra irrelevant
>> cleanup (patch #1). The missing bit from aarch64 is get_page_size()
>> which is a bit complicated to implement without libc.
>>
>> aarch64 supports three values of page size: 4K, 16K, and 64K which are
>> selected at kernel compilation time. Therefore, we can't hard code the
>> page size for this arch. In this series we utilize open(), read() and
>> close() syscall to find the page size from /proc/self/auxv.
>>
>> The auxiliary vector contains information about the page size, it is
>> located at `AT_PAGESZ` keyval pair.
> 
> This no longer applies, I will send v3 revision soon. If you have some
> comments, let me know so I can address it together with the rebase.

Just send a v3, didn't have time to go fully over it yet. One note,
though - for patch 5, I'd split get_page_size() into two pieces so you
just do:

static inline long get_page_size(void)
{
	static long cache_val;

	if (cache_val)
		return cache_val;

	return __get_page_size();
}

With that, we can have __get_page_size() just do that one thing, open
the file and read the value.

No need to init static variables to 0.

And finally, if the read/open/whatever fails in __get_page_size(),
assign cache_val to the fallback value as well. I don't see a point in
retrying the same operation later and expect a different result.
Ammar Faizi July 4, 2022, 3:36 p.m. UTC | #3
On 7/4/22 8:05 PM, Jens Axboe wrote:
> On 7/4/22 6:52 AM, Ammar Faizi wrote:
>> This no longer applies, I will send v3 revision soon. If you have some
>> comments, let me know so I can address it together with the rebase.
> 
> Just send a v3, didn't have time to go fully over it yet. One note,
> though - for patch 5, I'd split get_page_size() into two pieces so you
> just do:
> 
> static inline long get_page_size(void)
> {
> 	static long cache_val;
> 
> 	if (cache_val)
> 		return cache_val;
> 
> 	return __get_page_size();
> }
> 
> With that, we can have __get_page_size() just do that one thing, open
> the file and read the value.
> 
> No need to init static variables to 0.
> 
> And finally, if the read/open/whatever fails in __get_page_size(),
> assign cache_val to the fallback value as well. I don't see a point in
> retrying the same operation later and expect a different result.

OK, I got the idea, folded that in.

Also, it seems we don't have any test that hits that get_page_size()
path. Do we?

I am going to create a new test:

    test/nolibc.c

That file will test the nolibc functionality, let's do get_page_size()
for starting. We can compare the result with a libc function like:

   long a = sysconf(_SC_PAGESIZE);
   long b = get_page_size();
   if (a != b) {
         fprintf(stderr, "get_page_size() fails, %ld != %ld", a, b);
         return T_EXIT_FAIL;
   }