All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Randall S. Becker" <rsbecker@nexbridge.com>
To: "'Emily Shaffer'" <emilyshaffer@google.com>
Cc: git@vger.kernel.org,
	"'Ævar Arnfjörð Bjarmason'" <avarab@gmail.com>,
	"'Junio C Hamano'" <gitster@pobox.com>,
	"'Jeff Hostetler'" <git@jeffhostetler.com>,
	"'Bagas Sanjaya'" <bagasdotme@gmail.com>
Subject: RE: [PATCH v2] tr2: log parent process name
Date: Fri, 21 May 2021 12:24:55 -0400	[thread overview]
Message-ID: <027f01d74e5d$d9866e70$8c934b50$@nexbridge.com> (raw)
In-Reply-To: <025401d74e44$25db7140$719253c0$@nexbridge.com>

On May 21, 2021 9:21 AM, I wrote:
>To: 'Emily Shaffer' <emilyshaffer@google.com>
>Cc: git@vger.kernel.org; 'Ævar Arnfjörð Bjarmason' <avarab@gmail.com>; 'Junio C Hamano' <gitster@pobox.com>; 'Jeff Hostetler'
><git@jeffhostetler.com>; 'Bagas Sanjaya' <bagasdotme@gmail.com>
>Subject: RE: [PATCH v2] tr2: log parent process name
>
>On May 20, 2021 7:24 PM, Emily Shaffer wrote:
>>
>>On Thu, May 20, 2021 at 05:36:25PM -0400, Randall S. Becker wrote:
>>>
>>> On May 20, 2021 5:06 PM, Emily Shaffer wrote:
>>> >To: git@vger.kernel.org
>>> >Cc: Emily Shaffer <emilyshaffer@google.com>; Ævar Arnfjörð Bjarmason
>>> ><avarab@gmail.com>; Junio C Hamano <gitster@pobox.com>; Jeff
>>> >Hostetler <git@jeffhostetler.com>; Bagas Sanjaya
>>> ><bagasdotme@gmail.com>
>>> >Subject: [PATCH v2] tr2: log parent process name
>>> >
>>> >It can be useful to tell who invoked Git - was it invoked manually
>>> >by a user via CLI or script? By an IDE?  In some cases - like 'repo'
>>> >tool - we can influence the source code and set the
>>> >GIT_TRACE2_PARENT_SID environment variable from the caller process.
>>> >In
>'repo''s
>>case, that parent SID is manipulated to include the string "repo",
>>which means we can positively identify when Git was invoked by
>'repo'
>>tool.
>>> >However, identifying parents that way requires both that we know
>>> >which tools invoke Git and that we have the ability to modify the
>>> >source code of those tools. It cannot scale to keep up with
>the various
>>IDEs and wrappers which use Git, most of which we don't know about.
>>> >Learning which tools and wrappers invoke Git, and how, would give us
>>> >insight to decide where to improve Git's usability and
>>performance.
>>> >
>>> >Unfortunately, there's no cross-platform reliable way to gather the
>>> >name of the parent process. If procfs is present, we can use that; otherwise we will need to discover the name another way.
>However,
>>the process ID should be sufficient regardless of platform.
>>>
>>> I like this idea, but there are some platforms where this is unlikely
>>> to work. NonStop, in particular, can initiate git - and I
>frequently do -
>>from a non-POSIX environment where process name is entirely different.
>>In fact, it is something like $ABC (always beginning with a
>$,
>>which makes life very difficult for shell scripts and screws up
>>GIT_SSH_COMMAND, but I digress). I'm going to need to plug in
>something
>>very platform-specific to make this work. getppid() always returns 1 in
>>this situation, which is extraordinarily meaningless on the
>platform
>>and does not represent the actual parent.
>>
>>Ok. It sounds like you're saying I should be more conservative in the
>>commit message as well as in the #ifdef scope? Do you think
>this
>>needs a reroll to made the #ifdef more aggressive, or would you rather get to it when you get to it?
>
>I'll get to it pretty quickly once it's rolled in.
>
>>It looks like the change in config.mak.uname won't affect NonStop; I
>>think also the compat/procinfo.c is probably indicative enough
>of "this
>>stuff is for procfs" that it won't look like it *should* work for
>>NonStop, which means that you should still get the stub for 'trace2_collect_process_info()'. But if you think the guards aren't
readable
>enough I can try to move them around a little more.
>
>Guards are fine. There's just a lot more work to do for me. We need to make sure that the rendering of ancestor processes are
generic
>enough not to be just pid_t through any interfaces where this is queried. In NonStop's case, char[25], should be sufficient for the
short
>term, but I would prefer something longer, say char[128] to be safe for the future in which to stick the ancestor. To be completely
unique,
>the ancestor is going to look like \node.$proc:sequence (where node is a 7 character name, proc is a 5 character name, and sequence
is
>currently a long.

Just so we know what's coming, the code snippet to get a parent on NonStop is as follows (roughly):
        pid_t ossParent = getppid();
        if (ossParent == 1) {
                short pHandle[10];
                short pAncestor[10];
                short ancestorLength;
                short error;
                short attributes[] = { 40 }; /* MOM Process */
                short processNameLength;
                char processName[64];

                PROCESSHANDLE_NULLIT_(pHandle);
                PROCESS_GETINFO_(pHandle);
                error = PROCESS_GETINFOLIST_(,,,, pHandle,
                        attributes, (short) sizeof(attributes)/sizeof(attributes[0]),
                        pAncestor, (short) sizeof(pAncestor), &ancestorLength);
                if (error) {
                        printf("Cannot process parent. Error %d\n", error);
                        return;
                }
                PROCESSHANDLE_TO_FILENAME_(pAncestor, processName, (short) sizeof(processName),
                        &processNameLength);
                processName[processNameLength] = '\0';
                printf("GUARDIAN Parent %s\n", processName);
        } else {
                printf("OSS Parent %d\n", ossParent);
        }

Which in the test program generates
GUARDIAN Parent \HPITUG.$:3:1100:583555076

Regards,
Randall


  reply	other threads:[~2021-05-21 16:25 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07  0:29 [PATCH] tr2: log parent process name Emily Shaffer
2021-05-07  3:25 ` Bagas Sanjaya
2021-05-07 17:09 ` Emily Shaffer
2021-05-10 12:29 ` Ævar Arnfjörð Bjarmason
2021-05-11 21:31   ` Junio C Hamano
2021-05-14 22:06   ` Emily Shaffer
2021-05-16  3:48     ` Junio C Hamano
2021-05-17 20:17       ` Emily Shaffer
2021-05-11 17:28 ` Jeff Hostetler
2021-05-14 22:07   ` Emily Shaffer
2021-05-20 21:05 ` [PATCH v2] " Emily Shaffer
2021-05-20 21:36   ` Randall S. Becker
2021-05-20 23:23     ` Emily Shaffer
2021-05-21 13:20       ` Randall S. Becker
2021-05-21 16:24         ` Randall S. Becker [this message]
2021-05-21  2:09   ` Junio C Hamano
2021-05-21 19:02     ` Emily Shaffer
2021-05-21 23:22       ` Junio C Hamano
2021-05-24 18:37         ` Emily Shaffer
2021-05-21 19:15   ` Jeff Hostetler
2021-05-21 20:05     ` Emily Shaffer
2021-05-21 20:23       ` Randall S. Becker
2021-05-22 11:18       ` Jeff Hostetler
2021-05-24 23:33       ` Ævar Arnfjörð Bjarmason
2021-05-24 20:10   ` [PATCH v3] " Emily Shaffer
2021-05-24 20:49     ` Emily Shaffer
2021-05-25  3:54     ` Junio C Hamano
2021-05-25 13:33       ` Randall S. Becker
2021-06-08 18:58     ` [PATCH v4] " Emily Shaffer
2021-06-08 20:56       ` Emily Shaffer
2021-06-08 22:10       ` [PATCH v5] " Emily Shaffer
2021-06-08 22:16         ` Randall S. Becker
2021-06-08 22:24           ` Emily Shaffer
2021-06-08 22:39             ` Randall S. Becker
2021-06-09 20:17               ` Emily Shaffer
2021-06-16  8:42         ` Junio C Hamano
2021-06-28 16:45         ` Jeff Hostetler
2021-06-29 23:51           ` Emily Shaffer
2021-06-30  6:10             ` Ævar Arnfjörð Bjarmason
2021-07-22  0:21               ` Emily Shaffer
2021-07-22  1:27         ` [PATCH v6 0/2] " Emily Shaffer
2021-07-22  1:27           ` [PATCH v6 1/2] tr2: make process info collection platform-generic Emily Shaffer
2021-08-02  9:34             ` Ævar Arnfjörð Bjarmason
2021-07-22  1:27           ` [PATCH v6 2/2] tr2: log parent process name Emily Shaffer
2021-07-22 21:02             ` Junio C Hamano
2021-08-02  9:38             ` Ævar Arnfjörð Bjarmason
2021-08-02 12:45               ` Ævar Arnfjörð Bjarmason
2021-08-02 10:22             ` Ævar Arnfjörð Bjarmason
2021-08-02 12:47               ` Ævar Arnfjörð Bjarmason
2021-08-02 15:23               ` Jeff Hostetler
2021-08-02 16:10               ` Randall S. Becker
2021-08-02 18:41                 ` Ævar Arnfjörð Bjarmason
2021-08-25 23:19               ` [PATCH 0/6] tr2: plug memory leaks + logic errors + Win32 & Linux feature parity Ævar Arnfjörð Bjarmason
2021-08-25 23:19                 ` [PATCH 1/6] tr2: remove NEEDSWORK comment for "non-procfs" implementations Ævar Arnfjörð Bjarmason
2021-08-25 23:19                 ` [PATCH 2/6] tr2: clarify TRACE2_PROCESS_INFO_EXIT comment under Linux Ævar Arnfjörð Bjarmason
2021-08-25 23:19                 ` [PATCH 3/6] tr2: stop leaking "thread_name" memory Ævar Arnfjörð Bjarmason
2021-08-26  3:09                   ` Taylor Blau
2021-08-25 23:19                 ` [PATCH 4/6] tr2: fix memory leak & logic error in 2f732bf15e6 Ævar Arnfjörð Bjarmason
2021-08-26  3:21                   ` Taylor Blau
2021-08-25 23:19                 ` [PATCH 5/6] tr2: do compiler enum check in trace2_collect_process_info() Ævar Arnfjörð Bjarmason
2021-08-26  3:23                   ` Taylor Blau
2021-08-25 23:19                 ` [PATCH 6/6] tr2: log N parent process names on Linux Ævar Arnfjörð Bjarmason
2021-08-25 23:49                   ` Eric Sunshine
2021-08-26  4:07                   ` Taylor Blau
2021-08-26 12:24                     ` "I don't know what the author meant by that..." (was "Re: [PATCH 6/6] tr2: log N parent process names on Linux") Ævar Arnfjörð Bjarmason
2021-08-26 12:22                 ` [PATCH v2 0/6] tr2: plug memory leaks + logic errors + Win32 & Linux feature parity Ævar Arnfjörð Bjarmason
2021-08-26 12:22                   ` [PATCH v2 1/6] tr2: remove NEEDSWORK comment for "non-procfs" implementations Ævar Arnfjörð Bjarmason
2021-08-26 12:22                   ` [PATCH v2 2/6] tr2: clarify TRACE2_PROCESS_INFO_EXIT comment under Linux Ævar Arnfjörð Bjarmason
2021-08-26 12:22                   ` [PATCH v2 3/6] tr2: stop leaking "thread_name" memory Ævar Arnfjörð Bjarmason
2021-08-26 12:22                   ` [PATCH v2 4/6] tr2: fix memory leak & logic error in 2f732bf15e6 Ævar Arnfjörð Bjarmason
2021-08-26 15:58                     ` Eric Sunshine
2021-08-26 16:42                     ` Junio C Hamano
2021-08-26 12:22                   ` [PATCH v2 5/6] tr2: do compiler enum check in trace2_collect_process_info() Ævar Arnfjörð Bjarmason
2021-08-26 12:22                   ` [PATCH v2 6/6] tr2: log N parent process names on Linux Ævar Arnfjörð Bjarmason
2021-08-26 22:38                   ` [PATCH v2 0/6] tr2: plug memory leaks + logic errors + Win32 & Linux feature parity Taylor Blau
2021-08-27  8:02                   ` [PATCH v3 " Ævar Arnfjörð Bjarmason
2021-08-27  8:02                     ` [PATCH v3 1/6] tr2: remove NEEDSWORK comment for "non-procfs" implementations Ævar Arnfjörð Bjarmason
2021-08-27  8:02                     ` [PATCH v3 2/6] tr2: clarify TRACE2_PROCESS_INFO_EXIT comment under Linux Ævar Arnfjörð Bjarmason
2021-08-27  8:02                     ` [PATCH v3 3/6] tr2: stop leaking "thread_name" memory Ævar Arnfjörð Bjarmason
2021-08-27  8:02                     ` [PATCH v3 4/6] tr2: leave the parent list empty upon failure & don't leak memory Ævar Arnfjörð Bjarmason
2021-08-27  8:02                     ` [PATCH v3 5/6] tr2: do compiler enum check in trace2_collect_process_info() Ævar Arnfjörð Bjarmason
2021-08-27  8:02                     ` [PATCH v3 6/6] tr2: log N parent process names on Linux Ævar Arnfjörð Bjarmason
2021-08-31  0:17                     ` [PATCH v3 0/6] tr2: plug memory leaks + logic errors + Win32 & Linux feature parity Taylor Blau
2021-08-02 10:30             ` [PATCH v6 2/2] tr2: log parent process name Ævar Arnfjörð Bjarmason
2021-08-02 16:24               ` Junio C Hamano
2021-08-02 18:42                 ` Ævar Arnfjörð Bjarmason
2021-07-22 16:59           ` [PATCH v6 0/2] " Jeff Hostetler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='027f01d74e5d$d9866e70$8c934b50$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=avarab@gmail.com \
    --cc=bagasdotme@gmail.com \
    --cc=emilyshaffer@google.com \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.