From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top, Laurent Vivier <lvivier@redhat.com>
Subject: Re: [PATCH] log: setlogmask(0) can actually result in a system call, don't use it
Date: Sat, 3 Feb 2024 00:05:38 +0100 [thread overview]
Message-ID: <20240203000538.283db37b@elisabeth> (raw)
In-Reply-To: <Zbw_G6NrHIF2zWFg@zatzit>
On Fri, 2 Feb 2024 12:02:19 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> On Fri, Feb 02, 2024 at 12:32:57AM +0100, Stefano Brivio wrote:
> > Before commit 32d07f5e59f2 ("passt, pasta: Completely avoid dynamic
> > memory allocation"), we didn't store the current log mask in a
> > variable, and we fetched it using setlogmask(0) wherever needed.
> >
> > But after that commit, we can just use our log_mask copy instead. And
> > we should: with recent glibc versions, setlogmask(0) actually results
> > in a system call, which causes a substantial overhead with high
> > transfer rates: we use setlogmask(0) even to decide we don't want to
> > print debug messages.
> >
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
>
> The basic idea looks fine to me, but there's a curly edge case. At
> present vlogmsg() works ok before __openlog(), sending the message to
> stderr. We rely on this because there are die() calls before our
> __openlog(), which go via err() -> vlogmsg().
>
> With this change, before the first __setlogmask(), which occurs right
> after the __openlog() then log_mask is initialized to zero. Which
> means, AFAICT, that we'll suppress all error messages before that
> point, which isn't great.
Oops, right, thanks for pointing this out. I had a vague memory of some
side benefit of setlogmask(0) with this regard but I couldn't really
remember and gave up on it -- it was exactly this.
I'm re-posting this with a static initialisation of log_mask now.
--
Stefano
prev parent reply other threads:[~2024-02-02 23:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 23:32 [PATCH] log: setlogmask(0) can actually result in a system call, don't use it Stefano Brivio
2024-02-02 1:02 ` David Gibson
2024-02-02 23:05 ` Stefano Brivio [this message]
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=20240203000538.283db37b@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).