Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions kernel/linux/efa/config/efa.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ function(try_compile_prog_test)
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/${tmp_dir})
endfunction()

function(wait_for_pid pid)
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/config/wait_for_pid.sh ${pid})
function(wait_for_completion donefile)
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/config/wait_for_completion.sh ${donefile})
endfunction()

function(wait_for_pids)
function(wait_for_completions)
# Wait for everyone to finish
foreach(pid ${pids})
wait_for_pid(${pid})
foreach(donefile ${pending})
wait_for_completion(${donefile})
endforeach()
endfunction()

function(process_rl)
list(LENGTH pids list_len)
list(LENGTH pending list_len)
if(list_len EQUAL max_process)
list(GET pids 0 pid)
wait_for_pid(${pid})
list(REMOVE_AT pids 0)
set(pids "${pids}" CACHE INTERNAL "")
list(GET pending 0 donefile)
wait_for_completion(${donefile})
list(REMOVE_AT pending 0)
set(pending "${pending}" CACHE INTERNAL "")
endif()
endfunction()

# CMake "global" variable
set(pids "" CACHE INTERNAL "")
set(pending "" CACHE INTERNAL "")

include(ProcessorCount)
ProcessorCount(max_process)
Expand All @@ -59,9 +59,9 @@ function(try_compile prologue body success_def fail_def)
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/config/runbg.sh ${CMAKE_SOURCE_DIR}/config/compile_conftest.sh ${CMAKE_CURRENT_BINARY_DIR}/${tmp_dir} ${KERNEL_DIR} "${success_def}" "${fail_def}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE pid)
list(APPEND pids ${pid})
set(pids "${pids}" CACHE INTERNAL "")
OUTPUT_VARIABLE donefile)
list(APPEND pending ${donefile})
set(pending "${pending}" CACHE INTERNAL "")
endfunction()

function(try_compile_dev_or_ops fp_name prologue fn success_def fail_def)
Expand Down Expand Up @@ -534,5 +534,5 @@ char *name = errname(ERR_PTR(-EIO));
"
HAVE_PRINT_ERR_PTR "")

wait_for_pids()
wait_for_completions()
message("-- Inspecting kernel - done")
5 changes: 3 additions & 2 deletions kernel/linux/efa/config/runbg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
# Copyright 2021 Amazon.com, Inc. or its affiliates. All rights reserved.

nohup "$@" &>/dev/null </dev/null &
echo $!
donefile=$(mktemp -u).done
(nohup "$@" &>/dev/null </dev/null; touch "$donefile") &
echo "$donefile"
10 changes: 10 additions & 0 deletions kernel/linux/efa/config/wait_for_completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
# Copyright 2021 Amazon.com, Inc. or its affiliates. All rights reserved.

donefile=$1

while [ ! -f "$donefile" ]; do
sleep 0.2
done
rm -f "$donefile"
19 changes: 0 additions & 19 deletions kernel/linux/efa/config/wait_for_pid.sh

This file was deleted.