When remapping text or data, segments are prepared in a child process and later remapped. The status code from the segment preparation is not checked and in the event of failure to copy text or data, the main process gets killed later when it remaps a useless segment with no data. This patch checks the return values from prepare_segment() and recovers gracefully in the event prepare_segment() fails. The impact for tests is that remapping tests that previously received a SIGKILL or SIGBUS when the hugepage pool was too small will instead FAIL with the message "small_bss is not hugepage" or similar.
Signed-off-by: Mel Gorman <[EMAIL PROTECTED]> --- elflink.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/elflink.c b/elflink.c index 3401ed9..6f55c02 100644 --- a/elflink.c +++ b/elflink.c @@ -1027,6 +1027,9 @@ static int obtain_prepared_file(struct seg_info *htlb_seg_info) return -1; } + if (WEXITSTATUS(status) != 0) + return -1; + DEBUG("Prepare succeeded\n"); return 0; } @@ -1216,7 +1219,12 @@ void __lh_hugetlbfs_setup_elflink(void) for (i = 0; i < htlb_num_segs; i++) { ret = obtain_prepared_file(&htlb_seg_table[i]); if (ret < 0) { - DEBUG("Failed to setup hugetlbfs file\n"); + DEBUG("Failed to setup hugetlbfs file for segment %d\n", i); + + /* Close files we have already prepared */ + for (; i >= 0; i--) + close(htlb_seg_table[i].fd); + return; } } ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel