This is an archive of the discontinued LLVM Phabricator instance.

Make BPF stack size overridable
ClosedPublic

Authored by niclashedam on Apr 6 2023, 6:58 AM.

Details

Summary

With the emergence of TP 4091 for NVMe, eBPF can be used to offload programs to computational storage processors.
This change introduces the possibility of overriding the default stack size of 512 bytes for non-kernel runtime environments.

Diff Detail

Event Timeline

niclashedam created this revision.Apr 6 2023, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 6:58 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
niclashedam requested review of this revision.Apr 6 2023, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 6:58 AM

makes sense to me. Curious what kind of stack limits in HW do you envision?

Hello Alexei,
I appreciate your prompt attention. Determining the maximum stack size is difficult, but a reasonable estimate could be an increase of two orders of magnitude.
We developed a computational storage processor at the IT University of Copenhagen that executes eBPF programs. During our evaluation of loop versus loop-unrolling performance on hardware, we discovered that the stack is easily prone to exhaustion and that kernel characteristics no longer apply when executing on hardware.
We plan on conducting additional research to comprehend the characteristics of eBPF on computational storage.

I removed the llvm namespace since it is already known through the using statement.
I furthermore made the parameter unsigned since a stack will never be negative.

Sorry for the revision spam.
It looks like using an unsigned integer had adverse effects on the tests. I am reverting to signed integers but keeping the namespace change.

yonghong-song accepted this revision.Apr 9 2023, 11:56 PM

LGTM. How do you verify bpf program in your environment?

This revision is now accepted and ready to land.Apr 9 2023, 11:56 PM

Thanks for the review. I have a colleague at the IT University of Copenhagen doing a PhD on program verification for computational storage. However, for now, it's an open question.
We do some runtime checks, but the real issue is that when compiling BPF for computational storage, the device characteristics (stack size, helper functions, etc.) are unknown. As such, the verification must happen on the device, and the question is how we efficiently do that and how we convey potential verification problems back to the host.

Thanks for the review. I have a colleague at the IT University of Copenhagen doing a PhD on program verification for computational storage. However, for now, it's an open question.
We do some runtime checks, but the real issue is that when compiling BPF for computational storage, the device characteristics (stack size, helper functions, etc.) are unknown. As such, the verification must happen on the device, and the question is how we efficiently do that and how we convey potential verification problems back to the host.

Okay, thanks for explanation. The patch certainly okay as it doesn't change the current default funcitonality. Not exactly sure how the decide will verifier the program but that is a separate issue.

eddyz87 accepted this revision.Apr 17 2023, 8:22 AM

@eddyz87 Ping.

Sorry, since Yonghong and Alexei commented on this diff I hadn't thought that my "accept" is necessary.
The diff seem to be fine.

Hi Eddy. Thanks for the review! I assume your review was the thing @ast was waiting for. Now we can get it merged!

I will push these changes today.

Hi Eddy. Thanks for the review! I assume your review was the thing @ast was waiting for. Now we can get it merged!

Could you please update your profile with email, so that I can set commit author? (or ping me at eddyz87@gmail.com).
I'm following this guide and it suggests setting authors name + email, also commit history suggests that this is the norm.

Hi Eddy. Thanks for the review! I assume your review was the thing @ast was waiting for. Now we can get it merged!

Could you please update your profile with email, so that I can set commit author? (or ping me at eddyz87@gmail.com).
I'm following this guide and it suggests setting authors name + email, also commit history suggests that this is the norm.

There should already be an e-mail on my profile. If you can't see it, here's the info.

Niclas Hedam <niclas@hed.am>

This revision was automatically updated to reflect the committed changes.

Hi Eddy. Thanks for the review! I assume your review was the thing @ast was waiting for. Now we can get it merged!

Could you please update your profile with email, so that I can set commit author? (or ping me at eddyz87@gmail.com).
I'm following this guide and it suggests setting authors name + email, also commit history suggests that this is the norm.

There should already be an e-mail on my profile. If you can't see it, here's the info.

Niclas Hedam <niclas@hed.am>

Thanks, the info is not shown in the profile page for some reason.