Skip to content

Commit

Permalink
Use new linux headers that support ARM (pixie-io#894)
Browse files Browse the repository at this point in the history
Summary: PR pixie-io#883 added the docker build for an ARM version of linux
headers. This PR pulls those linux headers into our Pixie build.
Which set of merged headers to use is determined by the platform bazel
is building for.

Relevant Issues: pixie-io#147

Type of change: /kind cleanup

Test Plan: Tested a skaffold deploy on each of x86_64 and aarch64.

Signed-off-by: James Bartlett <jamesbartlett@pixielabs.ai>
  • Loading branch information
JamesMBartlett authored Feb 17, 2023
1 parent 17a6df1 commit 92e505c
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 23 deletions.
14 changes: 10 additions & 4 deletions bazel/linux_headers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ def linux_headers():
)

http_file(
name = "linux_headers_merged_tar_gz",
urls = ["https://storage.googleapis.com/pixie-dev-public/linux-headers/pl5/linux-headers-merged-pl5.tar.gz"],
sha256 = "2fa58d4658f0d12c294c72d2ae4410e16968b049e145adde283dcb51a3c148a4",
downloaded_file_path = "linux-headers-merged.tar.gz",
name = "linux_headers_merged_x86_64_tar_gz",
urls = ["https://storage.googleapis.com/pixie-dev-public/linux-headers/pl6/linux-headers-merged-x86_64-pl6.tar.gz"],
sha256 = "b99ac9def26c0c1ef03f34583a1e62b96b3b5f8b038428fa582ed28aacbe0ac3",
downloaded_file_path = "linux-headers-merged-x86_64.tar.gz",
)
http_file(
name = "linux_headers_merged_arm64_tar_gz",
urls = ["https://storage.googleapis.com/pixie-dev-public/linux-headers/pl6/linux-headers-merged-arm64-pl6.tar.gz"],
sha256 = "3daa69cc0e0516c2e9190b6c90ed42cbd8cdabc377c30571fc7037354dc5c57f",
downloaded_file_path = "linux-headers-merged-arm64.tar.gz",
)

def gen_timeconst_file(name, const):
Expand Down
7 changes: 4 additions & 3 deletions src/stirling/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ pl_cc_library(
# Note that each linux header tarball is ~15MB compressed and ~230MB uncompressed.
# Trimmed versions are ~8MB compressed and ~110MB uncompressed.
# These are all trimmed versions, so we have 8 * 12 = 96 MB of headers.
stirling_linux_headers_tarballs = [
"@linux_headers_merged_tar_gz//file:file",
]
stirling_linux_headers_tarballs = select({
"@platforms//cpu:aarch64": ["@linux_headers_merged_arm64_tar_gz//file:file"],
"@platforms//cpu:x86_64": ["@linux_headers_merged_x86_64_tar_gz//file:file"],
})

# Used by stirling runtime to replace the on-the-fly installed Linux headers from
# stirling_linux_headers_tarballs, in order to match the host's actual configs.
Expand Down
9 changes: 8 additions & 1 deletion src/stirling/utils/linux_headers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,15 @@ KernelVersionOrder CompareKernelVersions(KernelVersion a, KernelVersion b) {

StatusOr<PackagedLinuxHeadersSpec> FindClosestPackagedLinuxHeaders(
const std::filesystem::path& packaged_headers_root, KernelVersion kernel_version) {
#if X86_64
const std::string kHeaderDirPrefix =
std::filesystem::path(packaged_headers_root / "linux-headers-").string();
std::filesystem::path(packaged_headers_root / "linux-headers-x86_64-").string();
#elif AARCH64
const std::string kHeaderDirPrefix =
std::filesystem::path(packaged_headers_root / "linux-headers-arm64-").string();
#else
#error Architecture not supported
#endif
const std::string_view kHeaderDirSuffix = ".tar.gz";

PackagedLinuxHeadersSpec selected;
Expand Down
27 changes: 12 additions & 15 deletions src/stirling/utils/linux_headers_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,44 +230,41 @@ TEST(LinuxHeadersUtils, FindClosestPackagedLinuxHeaders) {
const std::string kTestSrcDir =
testing::BazelRunfilePath("src/stirling/utils/testdata/test_header_packages");

std::string prefix = "src/stirling/utils/testdata/test_header_packages/linux-headers-";
#if X86_64
prefix = prefix + "x86_64-";
#elif AARCH64
prefix = prefix + "arm64-";
#endif

{
ASSERT_OK_AND_ASSIGN(PackagedLinuxHeadersSpec match,
FindClosestPackagedLinuxHeaders(kTestSrcDir, KernelVersion{4, 4, 18}));
EXPECT_THAT(
match.path.string(),
EndsWith("src/stirling/utils/testdata/test_header_packages/linux-headers-4.14.176.tar.gz"));
EXPECT_THAT(match.path.string(), EndsWith(prefix + "4.14.176.tar.gz"));
}

{
ASSERT_OK_AND_ASSIGN(PackagedLinuxHeadersSpec match,
FindClosestPackagedLinuxHeaders(kTestSrcDir, KernelVersion{4, 15, 10}));
EXPECT_THAT(
match.path.string(),
EndsWith("src/stirling/utils/testdata/test_header_packages/linux-headers-4.14.176.tar.gz"));
EXPECT_THAT(match.path.string(), EndsWith(prefix + "4.14.176.tar.gz"));
}

{
ASSERT_OK_AND_ASSIGN(PackagedLinuxHeadersSpec match,
FindClosestPackagedLinuxHeaders(kTestSrcDir, KernelVersion{4, 18, 1}));
EXPECT_THAT(
match.path.string(),
EndsWith("src/stirling/utils/testdata/test_header_packages/linux-headers-4.18.20.tar.gz"));
EXPECT_THAT(match.path.string(), EndsWith(prefix + "4.18.20.tar.gz"));
}

{
ASSERT_OK_AND_ASSIGN(PackagedLinuxHeadersSpec match,
FindClosestPackagedLinuxHeaders(kTestSrcDir, KernelVersion{5, 0, 0}));
EXPECT_THAT(
match.path.string(),
EndsWith("src/stirling/utils/testdata/test_header_packages/linux-headers-5.3.18.tar.gz"));
EXPECT_THAT(match.path.string(), EndsWith(prefix + "5.3.18.tar.gz"));
}

{
ASSERT_OK_AND_ASSIGN(PackagedLinuxHeadersSpec match,
FindClosestPackagedLinuxHeaders(kTestSrcDir, KernelVersion{5, 7, 20}));
EXPECT_THAT(
match.path.string(),
EndsWith("src/stirling/utils/testdata/test_header_packages/linux-headers-5.3.18.tar.gz"));
EXPECT_THAT(match.path.string(), EndsWith(prefix + "5.3.18.tar.gz"));
}
}

Expand Down
Empty file.
Empty file.
Empty file.

0 comments on commit 92e505c

Please sign in to comment.