Skip to content

Commit ce8b1be

Browse files
author
Dong H. Ahn
committed
launchmon: Add IBM Spectrum and PowerLE support
Adjust for OpenPower ABI functional call convension change: The ABI adds two different entry points, one for intramodule call and the other intermodule call (being done through TOC). Port for IBM Spectrum jsrun. Add new spectrum definition and also adjust back end deamon code as to how it should synchronize itself with Spectrum MPI target. Adjust how to handle new thread creation. When a new thread is created, we will get the SIGTRAP notification via waitpid on the parent thread that spawns a new thread. But on a recent Linux kernal, we have to check the high order bits of waitpid returned status as: leftshift status by 8 bits and then to see if it is equal to (SIGTRAP | (LINUX_TRACER_EVENT_CLONE << 8). Add a work around for jsrun's broken MPIR_attach_fifo. It is expecting ASCII 1 to be sent to the FIFO when it should expect a numeric 1. Need to drop it when IBM ultimately fixes the issue. (Bug filed to IBM).
1 parent e2c5fc2 commit ce8b1be

17 files changed

+209
-114
lines changed

launchmon/src/linux/lmon_api/lmon_be_sync_mpi.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ lmon_rc_e LMON_be_procctl_init(rm_catalogue_e rmtype, MPIR_PROCDESC_EXT *ptab,
116116
case RC_cray:
117117
case RC_gupc:
118118
case RC_mpiexec_hydra:
119+
case RC_ibm_spectrum:
119120
//
120121
// Call generic Linux init
121122
//
@@ -170,6 +171,7 @@ lmon_rc_e LMON_be_procctl_stop(rm_catalogue_e rmtype, MPIR_PROCDESC_EXT *ptab,
170171
case RC_cray:
171172
case RC_gupc:
172173
case RC_mpiexec_hydra:
174+
case RC_ibm_spectrum:
173175
//
174176
// Call generic Linux stop
175177
//
@@ -230,6 +232,7 @@ lmon_rc_e LMON_be_procctl_run(rm_catalogue_e rmtype, int signum,
230232
case RC_cray:
231233
case RC_gupc:
232234
case RC_mpiexec_hydra:
235+
case RC_ibm_spectrum:
233236
//
234237
// Call generic Linux run
235238
//
@@ -292,6 +295,7 @@ lmon_rc_e LMON_be_procctl_initdone(rm_catalogue_e rmtype,
292295
case RC_cray:
293296
case RC_gupc:
294297
case RC_mpiexec_hydra:
298+
case RC_ibm_spectrum:
295299
//
296300
// Call generic Linux initdone
297301
//
@@ -346,6 +350,7 @@ lmon_rc_e LMON_be_procctl_done(rm_catalogue_e rmtype, MPIR_PROCDESC_EXT *ptab,
346350
case RC_cray:
347351
case RC_gupc:
348352
case RC_mpiexec_hydra:
353+
case RC_ibm_spectrum:
349354
//
350355
// You need to do nothing for these resource managers
351356
//
@@ -402,6 +407,7 @@ lmon_rc_e LMON_be_procctl_perf(rm_catalogue_e rmtype, MPIR_PROCDESC_EXT *ptab,
402407
case RC_cray:
403408
case RC_gupc:
404409
case RC_mpiexec_hydra:
410+
case RC_ibm_spectrum:
405411
//
406412
// You need to do nothing for these resource managers
407413
//

launchmon/src/linux/main.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int main(int argc, char* argv[]) {
5454
try {
5555
int rc = EXIT_FAILURE;
5656
#if X86_ARCHITECTURE || X86_64_ARCHITECTURE || PPC_ARCHITECTURE || \
57-
AARCH64_ARCHITECTURE
57+
AARCH64_ARCHITECTURE || POWERLE_ARCHITECTURE
5858
//
5959
// driver instantiation for the linux platform.
6060
//

launchmon/src/linux/sdbg_linux_driver_impl.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ linux_driver_t<LINUX_DRIVER_TEMPLPARAM>::create_process(pid_t pid,
9191

9292
#if X86_ARCHITECTURE || X86_64_ARCHITECTURE
9393
return_proc = new linux_x86_process_t(pid, mi, md, mt, mc);
94-
#elif PPC_ARCHITECTURE
94+
#elif PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
9595
return_proc = new linux_ppc_process_t(pid, mi, md, mt, mc);
9696
#elif IA64_ARCHITECTURE
9797
return_proc = new linux_ia64_process_t(pid, mi, md, mt, mc);
@@ -122,7 +122,7 @@ linux_driver_t<LINUX_DRIVER_TEMPLPARAM>::create_process(pid_t pid,
122122
//
123123
#if X86_ARCHITECTURE || X86_64_ARCHITECTURE
124124
return_proc = new linux_x86_process_t(pid, mi);
125-
#elif PPC_ARCHITECTURE
125+
#elif PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
126126
return_proc = new linux_ppc_process_t(pid, mi);
127127
#elif IA64_ARCHITECTURE
128128
return_proc = new linux_ia64_process_t(pid, mi);

launchmon/src/linux/sdbg_linux_launchmon.cxx

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,16 +1055,16 @@ bool linux_launchmon_t::handle_mpir_variables(
10551055
p.set_launch_hidden_bp(NULL);
10561056
}
10571057
la_bp = new linux_breakpoint_t();
1058-
la_bp->set_address_at(launch_bp_sym.get_relocated_address());
1058+
la_bp->set_address_at(launch_bp_sym.get_relocated_lowest_address());
10591059

10601060
#if PPC_ARCHITECTURE
10611061
//
10621062
// DHA Mar 05 2009
10631063
// PowerPC Linux has begun to change the linking convention
10641064
// such that binaries no longer export direct function
10651065
// symbols. (e.g., .MPIR_Breakpoint). But rather, undotted
1066-
// global data symbols (e.g., MPIR_Breakpoint) contains the
1067-
// address for the corresponding function.
1066+
// global data symbols (e.g., MPIR_Breakpoint) is the function
1067+
// descriptor
10681068
//
10691069
// Added indirect breakpoint support for that and use this
10701070
// method on all PPC systems across the board including
@@ -1486,16 +1486,15 @@ launchmon_event_e linux_launchmon_t::decipher_an_event(
14861486
//
14871487
// Parent gets SIGTRAP when a new thread is created
14881488
// Used to be: return_ev = LM_STOP_NOT_INTERESTED;
1489-
int upper16;
1490-
upper16 = event.get_rawstatus() >> 16;
1491-
if (upper16 == LINUX_TRACER_EVENT_CLONE) {
1489+
int high = event.get_rawstatus() >> 8;
1490+
if (high == (SIGTRAP | (LINUX_TRACER_EVENT_CLONE << 8))) {
14921491
return_ev = LM_STOP_AT_THREAD_CREATION;
1493-
} else {
1494-
//
1495-
// SIGTRAP due to fork for example
1496-
//
1497-
return_ev = LM_STOP_NOT_INTERESTED;
1498-
}
1492+
} else {
1493+
//
1494+
// SIGTRAP due to fork for example
1495+
//
1496+
return_ev = LM_STOP_NOT_INTERESTED;
1497+
}
14991498
} else if (event.get_signum() == SIGSTOP) {
15001499
return_ev = LM_RELAY_SIGNAL;
15011500

@@ -1578,12 +1577,13 @@ launchmon_rc_e linux_launchmon_t::handle_trap_after_attach_event(
15781577

15791578
#if MEASURE_TRACING_COST
15801579
beginTS = gettimeofdayD();
1580+
#endif
1581+
15811582
{
1582-
self_trace_t::trace(true, // print always
1583+
self_trace_t::trace(LEVELCHK(level2),
15831584
MODULENAME, 0,
15841585
"The RM process has just been trapped due to attach");
15851586
}
1586-
#endif
15871587

15881588
bool use_cxt = true;
15891589
image_base_t<T_VA, elf_wrapper> *dynloader_im = NULL;
@@ -1649,7 +1649,7 @@ launchmon_rc_e linux_launchmon_t::handle_trap_after_attach_event(
16491649
dynloader_im->get_a_symbol(p.get_loader_breakpoint_sym());
16501650

16511651
lo_bp = new linux_breakpoint_t();
1652-
addr_dl_bp = dynload_sym.get_relocated_address();
1652+
addr_dl_bp = dynload_sym.get_relocated_lowest_address();
16531653
lo_bp->set_address_at(addr_dl_bp);
16541654
#if PPC_ARCHITECTURE
16551655
lo_bp->set_use_indirection();
@@ -1781,9 +1781,9 @@ launchmon_rc_e linux_launchmon_t::handle_trap_after_exec_event(
17811781
#endif
17821782

17831783
{
1784-
self_trace_t::trace(true, // print always
1785-
MODULENAME, 0,
1786-
"The RM process has just been forked and exec'ed.");
1784+
self_trace_t::trace(LEVELCHK(level2),
1785+
MODULENAME, 0, "The RM process (%d) has "
1786+
"just been forked and exec'ed.", p.get_pid (true));
17871787
}
17881788

17891789
bool use_cxt = true;
@@ -1830,7 +1830,7 @@ launchmon_rc_e linux_launchmon_t::handle_trap_after_exec_event(
18301830
//
18311831
// Corner case; we deal with a heuristics
18321832
//
1833-
#if PPC_ARCHITECTURE
1833+
#if PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
18341834
//
18351835
// DHA Mar 05 2009
18361836
// There're systems that do not directly
@@ -1858,7 +1858,7 @@ launchmon_rc_e linux_launchmon_t::handle_trap_after_exec_event(
18581858
#else
18591859
= p.get_gprset(use_cxt)->get_pc() & 0xffff0000;
18601860
#endif
1861-
#else /* PPC_ARCHITECTURE */
1861+
#else /* PPC_ARCHITECTURE || POWERLE_ARCHITECTURE */
18621862
//
18631863
// This requires the actual page size to compute this loader load
18641864
// address implictly. Just using the following bits for now.
@@ -1915,13 +1915,13 @@ launchmon_rc_e linux_launchmon_t::handle_trap_after_exec_event(
19151915
countHandler++;
19161916
// accum and countHandler now contain the cost of this handler which
19171917
// is invoked just once per job
1918-
#endif
1919-
19201918
{
19211919
self_trace_t::trace(
19221920
true, // print always
19231921
MODULENAME, 0, "Just continued the RM process out of the first trap");
19241922
}
1923+
#endif
1924+
19251925

19261926
set_last_seen(gettimeofdayD());
19271927
return LAUNCHMON_OK;
@@ -2652,12 +2652,19 @@ launchmon_rc_e linux_launchmon_t::handle_thrcreate_request(
26522652
memset(&tinfo, '\0', sizeof(tinfo));
26532653
tinfo.ti_lid = (lwpid_t)newlwpid;
26542654

2655+
{
2656+
self_trace_t::trace(LEVELCHK(level2), MODULENAME,0,
2657+
"thread creation request event handler "
2658+
"invoked for thread (%d)", newlwpid);
2659+
}
2660+
2661+
26552662
if (p.get_thrlist().find(tinfo.ti_lid) == p.get_thrlist().end()) {
26562663
// this thread has not been seen
26572664
#if X86_ARCHITECTURE || X86_64_ARCHITECTURE
26582665
thread_base_t<SDBG_LINUX_DFLT_INSTANTIATION> *thrinfo =
26592666
new linux_x86_thread_t();
2660-
#elif PPC_ARCHITECTURE
2667+
#elif PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
26612668
thread_base_t<SDBG_LINUX_DFLT_INSTANTIATION> *thrinfo =
26622669
new linux_ppc_thread_t();
26632670
#elif AARCH64_ARCHITECTURE

launchmon/src/linux/sdbg_linux_mach.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ bool linux_x86_process_t::basic_init(const std::string& mi,
520520
return true;
521521
}
522522

523-
#elif PPC_ARCHITECTURE
523+
#elif PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
524524

525525
////////////////////////////////////////////////////////////////////
526526
//

launchmon/src/linux/sdbg_linux_mach.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ struct ps_prochandle {
516516
process_base_t<SDBG_LINUX_DFLT_INSTANTIATION>* p;
517517
};
518518

519-
#elif PPC_ARCHITECTURE
519+
#elif PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
520520

521521
//! linux_ppc_gpr_set_t:
522522
/*!

launchmon/src/linux/sdbg_linux_std.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ const T_VA T_UNINIT_HEX = 0xdeadbeef;
356356
#define SDBG_LINUX_DFLT_INSTANTIATION \
357357
T_VA, T_WT, T_IT, T_GRS, T_FRS, my_thrinfo_t, elf_wrapper
358358

359-
#elif PPC_ARCHITECTURE
359+
#elif PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
360360

361361
//
362362
//

launchmon/src/linux/sdbg_linux_symtab.hxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ class linux_image_t : public image_base_t<VA, elf_wrapper> {
203203
level);
204204
}
205205

206+
VA get_local_entry_point (const unsigned char o);
207+
206208
// For self tracing
207209
//
208210
std::string MODULENAME;

launchmon/src/linux/sdbg_linux_symtab_impl.hxx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*
2929
*
3030
* Update Log:
31+
* May 19 2018 DHA: Added OpenPower ABI's dual entry points.
3132
* Oct 27 2010 DHA: Added is_defined, is_globally_visible,
3233
* is_locally_visible virtual methods.
3334
* Dec 20 2009 DHA: Fixed a bug that arose when Mark's patch
@@ -482,6 +483,10 @@ linux_image_t<LINUX_IMAGE_TEMPLPARAM>::read_linkage_symbols() throw(
482483
decode_type(first_sym->st_info, tmp);
483484
a_linksym->set_type(tmp);
484485
a_linksym->set_defined((first_sym->st_shndx != SHN_UNDEF) ? true : false);
486+
a_linksym->set_info(first_sym->st_info);
487+
a_linksym->set_other(first_sym->st_other);
488+
a_linksym->set_local_entry_offset(
489+
get_local_entry_point(first_sym->st_other));
485490

486491
string keystr(symname);
487492

@@ -864,6 +869,47 @@ void linux_image_t<LINUX_IMAGE_TEMPLPARAM>::decode_visibility(
864869
}
865870
}
866871

872+
873+
//! PRIVATE: linux_image_t<VA>::get_local_entry_point --
874+
/*!
875+
Calculate the entry point used by an intramodule function call
876+
*/
877+
template <LINUX_IMAGE_TEMPLATELIST>
878+
VA
879+
linux_image_t<LINUX_IMAGE_TEMPLPARAM>::get_local_entry_point (const unsigned char o)
880+
{
881+
VA rc = 0;
882+
#if POWERLE_ARCHITECTURE
883+
/* The "OpenPOWER ABI for Linux Supplement, Power Architecture 64-Bit ELF V2
884+
* ABI, Advance":
885+
* "The OpenPOWER ABI uses the three most-significant bits
886+
* in the symbol st_other field to specify the number of instructions between a
887+
* function's global entry point and local entry point. The global entry point
888+
* is used when it is necessary to set up the TOC pointer (r2) for the
889+
* function. The local entry point is used when r2 is known to already be valid
890+
* for the function. A value of zero in these bits asserts that the function
891+
* does not use r2."
892+
*/
893+
const int code = (o >> 5) & 0x7;
894+
switch (code)
895+
{
896+
case 2: /* 1 instruction */
897+
case 3: /* 2 instructions */
898+
case 4: /* 4 instructions */
899+
case 5: /* 8 instructions */
900+
case 6: /* 16 instructions */
901+
rc = (1 << (code - 2)) * 4; /* TODO: augment template param to includ IT */
902+
break;
903+
case 0: /* local == global */
904+
case 1: /* local == global */
905+
case 7: /* Reserved */
906+
break;
907+
} /* switch */
908+
#endif
909+
return rc;
910+
}
911+
912+
867913
template <LINUX_IMAGE_TEMPLATELIST>
868914
void linux_image_t<LINUX_IMAGE_TEMPLPARAM>::set_image_base_address(VA ba) {
869915
image_base_t<VA, elf_wrapper>::set_image_base_address(ba);

launchmon/src/linux/sdbg_proc_service.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extern "C" {
6262
#include <limits.h>
6363
}
6464

65-
#if X86_ARCHITECTURE || PPC_ARCHITECTURE
65+
#if X86_ARCHITECTURE || PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
6666

6767
#ifndef PTRACE_GET_THREAD_AREA
6868
#define PTRACE_GET_THREAD_AREA 25
@@ -243,7 +243,7 @@ extern "C" ps_err_e ps_get_thread_area(const struct ps_prochandle *ph,
243243
lwpid_t lpid, int x, psaddr_t *addr) {
244244
bool use_cxt = true;
245245

246-
#if X86_ARCHITECTURE || PPC_ARCHITECTURE
246+
#if X86_ARCHITECTURE || PPC_ARCHITECTURE || POWERLE_ARCHITECTURE
247247
/*
248248
* How to fetch thread-specific area for x86/linux and powerPC/linux
249249
*

0 commit comments

Comments
 (0)