From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3864A3858C27 for ; Fri, 24 Dec 2021 16:05:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3864A3858C27 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-127-oz3FBgnWO1WWhE6Jm2Xtkg-1; Fri, 24 Dec 2021 11:05:28 -0500 X-MC-Unique: oz3FBgnWO1WWhE6Jm2Xtkg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 488E0801ADC; Fri, 24 Dec 2021 16:05:25 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.104]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7570F5F4F4; Fri, 24 Dec 2021 16:05:19 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org, John Mellor-Crummey , Ben Woodard , Alexander Monakov Subject: Re: [PATCH v7 09/16] elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533) References: <20211222132712.523295-1-adhemerval.zanella@linaro.org> <20211222132712.523295-10-adhemerval.zanella@linaro.org> Date: Fri, 24 Dec 2021 17:05:17 +0100 In-Reply-To: <20211222132712.523295-10-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Wed, 22 Dec 2021 10:27:05 -0300") Message-ID: <875yre9ef6.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Dec 2021 16:05:33 -0000 * Adhemerval Zanella: > The rtld-audit interfaces introduces a slowdown due to enabling > profiling instrumentation (as if LD_AUDIT implied LD_PROFILE). > However, instrumenting is only necessary if one of audit libraries > provides PLT callbacks (la_pltenter or la_pltexit symbols). Otherwise, > the slowdown can be avoided. > > The following patch adjusts the logic that enables profiling to iterate > over all audit modules and check if any of those provides a PLT hook. > To keep la_symbind to work even without PLT callbacks, _dl_fixup now > calls the audit callback if the modules implements it. > > Co-authored-by: Alexander Monakov > > Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. > --- > NEWS | 3 ++ > elf/Makefile | 14 ++++++- > elf/dl-reloc.c | 20 ++++++++- > elf/dl-runtime.c | 31 ++++++++++++++ > elf/rtld.c | 8 +--- > elf/tst-audit19a.c | 38 +++++++++++++++++ > elf/tst-audit19b.c | 94 +++++++++++++++++++++++++++++++++++++++++++ > elf/tst-audit19bmod.c | 23 +++++++++++ > elf/tst-auditmod19a.c | 25 ++++++++++++ > elf/tst-auditmod19b.c | 46 +++++++++++++++++++++ > include/link.h | 2 + > 11 files changed, 294 insertions(+), 10 deletions(-) > create mode 100644 elf/tst-audit19a.c > create mode 100644 elf/tst-audit19b.c > create mode 100644 elf/tst-audit19bmod.c > create mode 100644 elf/tst-auditmod19a.c > create mode 100644 elf/tst-auditmod19b.c I like the version with the l_reloc_result check much better. > diff --git a/elf/tst-audit19b.c b/elf/tst-audit19b.c > new file mode 100644 > index 0000000000..da015734f2 > --- /dev/null > +++ b/elf/tst-audit19b.c > @@ -0,0 +1,94 @@ > + setenv ("LD_AUDIT", "tst-auditmod18b.so", 0); > + struct support_capture_subprocess result > + = support_capture_subprogram (spargv[0], spargv); > + support_capture_subprocess_check (&result, "tst-audit18b", 0, sc_allow_stderr); > + > + bool find_symbind = false; > + > + FILE *out = fmemopen (result.err.buffer, result.err.length, "r"); > + TEST_VERIFY (out != NULL); > + char *buffer = NULL; > + size_t buffer_length = 0; > + while (xgetline (&buffer, &buffer_length, out)) > + if (startswith (buffer, "la_symbind: tst_audit18bmod1_func") == 0) > + find_symbind = true; > + > + TEST_COMPARE (find_symbind, true); > + > + free (buffer); > + xfclose (out); You could use strstr to find the "\nla_symbind: tst_audit18bmod1_func" string (possibly after altering the output so that the \n is always there). But the version above works for me as well. Reviewed-by: Florian Weimer Thanks, Florian