Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LPAR name as prefix of thread names #577

Open
swhobbit opened this issue Jun 25, 2023 · 23 comments
Open

Add LPAR name as prefix of thread names #577

swhobbit opened this issue Jun 25, 2023 · 23 comments
Labels
Enhancement This issue does not describe a problem but rather describes a suggested change or improvement.

Comments

@swhobbit
Copy link
Contributor

When running multiple Hercules instances, if one shows threads on Linux one ends up with multiple names like "Processor CP00". It would be more useful to say "LPARNAME Processor CP00" or even "LPARNAME CP00"

@Fish-Git Fish-Git added the Enhancement This issue does not describe a problem but rather describes a suggested change or improvement. label Jun 25, 2023
@Fish-Git Fish-Git changed the title enhancement: Add LPAR name as prefix of thread names Add LPAR name as prefix of thread names Jun 25, 2023
@Fish-Git
Copy link
Member

That sounds like a quite good and perfectly reasonable request! Thanks Drew! I'll get right on it as soon as I can!

@swhobbit
Copy link
Contributor Author

swhobbit commented Jun 25, 2023

That sounds like a quite good and perfectly reasonable request!

You are most kind. I thought it would easier than some. :-)

BTW, my example only showed CPU threads, but getting all reasonable threads would be great.

@Fish-Git
Copy link
Member

One caveat though: I'm pretty sure on Windows that thread names are limited to 16 characters (or maybe 15; can't recall). I think Linux might impose a limit too, but am not sure about that, nor what the limit actually is if it does. Prefixing each thread's name with the LPARNAME could end up being a little tricky depending on how long your LPAR name is!

@Fish-Git
Copy link
Member

It looks like *Nix imposes a maximum length of only 15 characters:

@Fish-Git Fish-Git added the Researching... The issue is being looked into or additional information is being gathered/located. label Jun 26, 2023
@Fish-Git
Copy link
Member

Hercules code:

hyperion/hscutl.c

Lines 1647 to 1673 in 65c97fd

/*-------------------------------------------------------------------*/
/* Set thead name (nonstandard GNU extension) */
/* (note: retcode is error code, NOT errno) */
/*-------------------------------------------------------------------*/
DLL_EXPORT int nix_set_thread_name( pthread_t tid, const char* name )
{
int rc = 0;
char threadname[16];
if (!name) return 0; /* (ignore premature calls) */
STRLCPY( threadname, name );
/* Some platforms (e.g. Mac) can only set name of current thread */
#if defined( PTHREAD_SET_NAME_ONLY )
if (!pthread_equal( tid, pthread_self()))
return EINVAL;
rc = pthread_setname_np( threadname );
#elif defined( PTHREAD_SET_NAME_3ARGS )
rc = pthread_setname_np( tid, "%s", threadname );
#else
rc = pthread_setname_np( tid, threadname );
#endif
/* Ignore any error; it either worked or it didn't */
return rc;
}

@Fish-Git
Copy link
Member

Fish-Git commented Jun 26, 2023

LPARNAME is an 8 character field. So as I said, implementing this enhancement request may prove to be rather challenging (tricky).

Any ideas, Drew?  (Or anyone else?)

@Fish-Git Fish-Git added the QUESTION... A question was asked but has not been answered yet, -OR- additional feedback is requested. label Jun 26, 2023
@swhobbit
Copy link
Contributor Author

Take whole LPAR name if possible, space, seven characters for the thread data:

CPxx
idlCCUU, CCUU (no idle), or IDLEcuu (which lops the high order nibble)
TIMER

What other types do you have? Sometimes, you gotta think like a S/360 programmer lop stuff down to size.

We close with a reading from the tenth edition (May 1990) of the IBM Jargon dictionary, edited by IBM Fellow Mike Cowlishaw:

token n. An 8-character alphanumeric operand. This size was chosen because it just happened to fit the size of one of the System/360 atomic units of storage (the doubleword). Some operating systems and programs used to (and often still do) insist on parsing all input and truncating any words longer than 8 characters. [Especially annoying to those with 9-letter surnames.]

(Of course, Cowlishaw is nine characters.)

@Fish-Git
Copy link
Member

What other types do you have?

hyperion/hthreads.h

Lines 245 to 275 in 65c97fd

/*-------------------------------------------------------------------*/
/* Thread Names */
/*-------------------------------------------------------------------*/
/* Thread names must be less than 16 characters (15 chars + NULL) */
// "1...5...10...15"
#define BOOTSTRAP_NAME "bootstrap"
#define IMPL_THREAD_NAME "impl_thread"
#define PANEL_THREAD_NAME "panel_display"
#define SOCKET_THREAD_NAME "socket_thread"
#define LOGGER_THREAD_NAME "logger_thread"
#define SCRIPT_THREAD_NAME "script_thread"
#define TIMER_THREAD_NAME "timer_thread"
#if defined( _FEATURE_073_TRANSACT_EXEC_FACILITY )
#define RUBATO_THREAD_NAME "rubato_thread"
#endif
#define SCSISTAT_THREAD_NAME "scsi_status"
#define SCSIMOUNT_THREAD_NAME "scsi_mount"
#define CCKD_RA_THREAD_NAME "cckd_ra"
#define CCKD_WR_THREAD_NAME "cckd_writer"
#define CCKD_GC_THREAD_NAME "cckd_gcol"
#define CON_CONN_THREAD_NAME "console_connect"
#define CONN_CLI_THREAD_NAME "connect_client"
#define HAO_THREAD_NAME "hao_thread"
#define HTTP_SRVR_THREAD_NAME "http_server"
#define HTTP_REQ_THREAD_NAME "http_request"
#define WATCHDOG_THREAD_NAME "watchdog_thread"
#define HERCLIN_KB_THREAD "keyboard thread"

@swhobbit
Copy link
Contributor Author

#define BOOTSTRAP_NAME   "boot"
#define IMPL_NAME        "impl"
#define PANEL_NAME       "panel"
#define SOCKET_NAME      "sock"
#define LOGGER_NAME      "log"
#define SCRIPT_NAME      "scrpt"
#define TIMER_NAME       "timer"
#if defined( _FEATURE_073_TRANSACT_EXEC_FACILITY )
#define RUBATO_NAME      "rubato"
#endif
#define SCSISTAT_NAME    "scsist"
#define SCSIMOUNT_NAME   "scsimt"
#define CCKD_RA_NAME     "dra"
#define CCKD_WR_NAME     "dwtr"
#define CCKD_GC_NAME     "dol"
#define CON_CONN_NAME    "ttynew"
#define CONN_CLI_NAME    "ttycli"
#define HAO_NAME         "hao"
#define HTTP_SRVR_NAME   "websvr"
#define HTTP_REQ_NAME    "webreq"
#define WATCHDOG_NAME    "wdog"
#define HERCLIN_KB       "keybd"

@swhobbit
Copy link
Contributor Author

SET_THREAD_NAME( exename );  

FYI: I would replace something like this with LPARNAME HERC.

@Fish-Git
Copy link
Member

Fish-Git commented Jun 26, 2023

I'm also thinking this should probably be a new command-line option too, so the user can choose on a case-by-case basis whether they want thread names to be prefixed with some user-defined value or not.

That is to say, prefixing thread names with the LPARNAME, now that I think about it, might not be possible (or at least more difficult) to implement, given that the LPARNAME won't be known until the configuration files is processed (and, although I haven't checked, I believe some threads might get created before the LPARNAME has been processed and is known).

What do you think? New command-line option?

@Fish-Git
Copy link
Member

Fish-Git commented Jun 26, 2023

#define BOOTSTRAP_NAME   "boot"
#define IMPL_NAME        "impl"
#define PANEL_NAME       "panel"
#define SOCKET_NAME      "sock"
...

I like it!  :)

@swhobbit
Copy link
Contributor Author

swhobbit commented Jun 26, 2023

What do you think? New command-line option?

If you want, but since on Linux by default top doesn't show threads in the first place (YMMV), it doesn't matter that much.

@swhobbit
Copy link
Contributor Author

swhobbit commented Jun 26, 2023

threads

Thread panel_display   tid=f7db9dc0 created on 16:11:03.901607 at hthreads.c:206  
Thread logger_thread   tid=f72a4440 created on 16:11:03.902303 at logger.c:584    
Thread watchdog_thread tid=f6efa440 created on 16:11:03.910833 at impl.c:1478     
Thread Processor CP00  tid=f69ff440 created on 16:11:03.912193 at config.c:1065   
Thread timer_thread    tid=f66ff440 created on 16:11:03.913430 at cpu.c:2345      
Thread http_server     tid=f6df9440 created on 16:11:03.941149 at httpserv.c:1044 
Thread socket_thread   tid=f6cbe440 created on 16:11:03.944343 at sockdev.c:533   
Thread console_connect tid=f57ff440 created on 16:11:03.947787 at console.c:718   
Thread CTCE 0E40 Liste tid=f4ef6440 created on 16:11:04.019277 at ctcadpt.c:2237  
Thread CTCE 0E40 Conne tid=f4df5440 created on 16:11:04.019992 at ctcadpt.c:3567  
Thread CTCE 0E41 Liste tid=f4cf4440 created on 16:11:04.020866 at ctcadpt.c:2237  
Thread CTCE 0E41 Conne tid=f4bf3440 created on 16:11:04.021605 at ctcadpt.c:3567  
Thread hao_thread      tid=f48f0440 created on 16:11:04.095450 at hao.c:93        
Thread CTCE 0E44 RecvT tid=f45ed440 created on 16:11:04.240214 at ctcadpt.c:2413  
Thread CTCE 0E45 RecvT tid=f44ec440 created on 16:11:04.240502 at ctcadpt.c:2413  
Thread cckd_ra         tid=f42ea440 created on 16:11:14.130132 at cckddasd.c:1594 
Thread dev 0E44 thrd   tid=f38ff440 created on 16:11:21.833460 at channel.c:2677  
Thread idle dev thrd   tid=f37fe440 created on 16:11:21.834877 at channel.c:2677  
Thread cckd_writer     tid=f46ee440 created on 16:14:02.161484 at cckddasd.c:1883 

Commenting on this partial display from a running system:

  • As noted previously, drop Processor, thread, and thrd.
  • Drop CTCE, the reader can do a devlist to determine a device type.
  • Change idle dev to dev idle so it matches dev 0E44
  • Change cckd to dasd?
  • What's the ra in cckd_ra? (If it's "read", change ra to rd)

@Fish-Git
Copy link
Member

If you want, but since on Linux top doesn't show threads in the first place (YMMV), it doesn't matter that much.

Eh?! What's this?! If top doesn't show threads, then what command does? What command are you using that prompted you (compelled you) to create this enhancement request in the first dang place?!

I'm confused!  :(

@swhobbit
Copy link
Contributor Author

I bad. (Original comment corrected.)

If you want, but since on Linux top doesn't show threads in the first place (YMMV), it doesn't matter that much.

should read:

If you want, but since on Linux top by default doesn't show threads in the first place (YMMV), it doesn't matter that much.

Threads are enabled by capital H.

@wrljet
Copy link
Member

wrljet commented Jun 27, 2023

Huh? in top?

@swhobbit
Copy link
Contributor Author

swhobbit commented Jun 27, 2023

Huh? in top?

More context please. What in top? Threads? Yes, capital H. Quoting the top manual age on Bullseye:

-H Threads-mode operation
Instructs top to display individual threads. Without this command-line option a summation of all threads in each process is shown. Later this can be changed with the H interactive command.

@wrljet
Copy link
Member

wrljet commented Jun 27, 2023

I see no effect using -H command line option, or the H once Top is running.

@Fish-Git
Copy link
Member

  • As noted previously, drop Processor, thread, and thrd.

Makes sense.

  • Change idle dev to dev idle so it matches dev 0E44

Also makes perfect sense.

  • Change cckd to dasd?

Nah. Dasd code and CCKD code are quite different things internally. As "dasd" and "cckd" are both 4 characters, I'm compelled to leave those as-is if you don't mind.

  • What's the ra in cckd_ra? (If it's "read", change ra to rd)

Again, no. The "ra" in the name stands for "read ahead":

 

@swhobbit
Copy link
Contributor Author

I see no effect using -H command line option, or the H once Top is running.

Are you running threaded apps?

I specifically said I was using Bullseye (actually Raspberry PI OS B Bullseye); the top command was installed by apt. I even quoted the man page.

I also verified this on ubuntu 22.04.2 LTS (Jammy Jellyfish).

Hint: The second line of the top display changes from tasks to threads when you switch modes.

-ahd-

@wrljet
Copy link
Member

wrljet commented Jun 27, 2023

I see no effect using -H command line option, or the H once Top is running.

Are you running threaded apps?

I don't know.

I specifically said I was using Bullseye (actually Raspberry PI OS B Bullseye); the top command was installed by apt. I even quoted the man page.

I also verified this on ubuntu 22.04.2 LTS (Jammy Jellyfish).

Hint: The second line of the top display changes from tasks to threads when you switch modes.

I did notice the change to "Threads". But nothing special was running at the time.

@swhobbit
Copy link
Contributor Author

Change cckd to dasd?

Nah. Dasd code and CCKD code are quite different things internally. As "dasd" and "cckd" are both 4 characters, I'm compelled to leave those as-is if you don't mind.

What's the ra in cckd_ra? (If it's "read", change ra to rd)

Again, no. The "ra" in the name stands for "read ahead":

SGTM

@Fish-Git Fish-Git removed the QUESTION... A question was asked but has not been answered yet, -OR- additional feedback is requested. label Jul 29, 2023
@Fish-Git Fish-Git removed the Researching... The issue is being looked into or additional information is being gathered/located. label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement This issue does not describe a problem but rather describes a suggested change or improvement.
Projects
None yet
Development

No branches or pull requests

3 participants