From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 3C8005A026F for ; Sat, 3 Feb 2024 00:06:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706915177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/B99zVqEEMM0ZUbV6FRBvEwODxZnYCEF3ITcQf0q7kw=; b=jH8jWpXqh7+opDh+aGEtdAsDEnqkWT9JnWQoozW6+LszLYfo7z6lOs6DVQZrtC5NTII28P l3N0UBeeHN5U8DO0TqBL768XsyfYoe0aXGlp5/zr3s1ufBcQ792P88sFM/6lOOZ906m1B3 M/KmKf+MtPUsnFtvNVm4FmTDEb86idY= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-IRzVbxpwNtuIiJJUK0BNzQ-1; Fri, 02 Feb 2024 18:06:16 -0500 X-MC-Unique: IRzVbxpwNtuIiJJUK0BNzQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a36fd38d133so66576566b.3 for ; Fri, 02 Feb 2024 15:06:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706915174; x=1707519974; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/B99zVqEEMM0ZUbV6FRBvEwODxZnYCEF3ITcQf0q7kw=; b=DUHmCs7ycRMAAyjVl82/8fLHqbLG5c9yBYrx8m+fYYwMgdATb5Ic4vobwo0r22HR5n BG/fWJAkSfzA5u0NMffTImDjF5TneOgTd5A4Z3B6hS9mYTt1VJZ6j05JvbpHZiXbukcz RmGYUg7n8XGLaSagg9qQFMYBtqT2T9oNIBh2FxBofhl3V9HvcLSU+EzjQT1v0digkkEN 0j1a8Mc19zr7jVVtGJCCPOBcqIhLmj/oA7a2cZ/0+gHIR7/pUXerj5dVlCx1ir/kYQ1o NF4bebf+zqymXBaOYejKhREn0h9suEY9Ab65S34QrVrcuc8Zv7NplbXPhNNNFknTcigV gSMQ== X-Gm-Message-State: AOJu0Yw9eaCjaFmrwmGLyrg9TwB6pV4n0jw70olrRewAhd2CJVGSsxOZ lgXJJrFyvNsBHuDH8Y2MthjWFpJY9SyPWvte8E9TKDyMa26jz90W23Cb5n+jU1nNqBbILCaPD4J 3i/dhw8wZw+Hwd4xKUrCkAMWR6MQQ09llNUVxglHW5bNWDirp7F+jFONR5Nsu X-Received: by 2002:a17:906:6a24:b0:a37:20be:d010 with SMTP id qw36-20020a1709066a2400b00a3720bed010mr2404233ejc.51.1706915174524; Fri, 02 Feb 2024 15:06:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1MBzHApH0ATC5kRaAbiSvI9EVqglM6bBp5/ia4csqD5UzQ3Fd23LS7BJ6VTZc9Hy/sXWMcA== X-Received: by 2002:a17:906:6a24:b0:a37:20be:d010 with SMTP id qw36-20020a1709066a2400b00a3720bed010mr2404221ejc.51.1706915174089; Fri, 02 Feb 2024 15:06:14 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUekaIMNZuqAjMdQxu4d7dFcmD9EHcxLhmNBU6sG9ZpkPJPDi8lvIyilvxlpZdxQPwMMz0azdAHgLlXFHrKkedWKpc= Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id vi2-20020a170907d40200b00a37024b48d1sm1143050ejc.189.2024.02.02.15.06.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2024 15:06:13 -0800 (PST) Date: Sat, 3 Feb 2024 00:05:38 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] log: setlogmask(0) can actually result in a system call, don't use it Message-ID: <20240203000538.283db37b@elisabeth> In-Reply-To: References: <20240201233257.2287025-1-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.1.1 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: YQAPBT2FEUULVARGSTADICCFGFC4YMVI X-Message-ID-Hash: YQAPBT2FEUULVARGSTADICCFGFC4YMVI X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 2 Feb 2024 12:02:19 +1100 David Gibson 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 > > 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