Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2305312rwl; Thu, 6 Apr 2023 08:26:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ZknGD91oBBJ5xP89THkm7fBAfwley8/6p3bKxW6LFcMePMVDscVGlEhNANNgnBWGyDigus X-Received: by 2002:a05:6402:451:b0:4fa:56dc:b6e6 with SMTP id p17-20020a056402045100b004fa56dcb6e6mr6222505edw.16.1680794801304; Thu, 06 Apr 2023 08:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680794801; cv=none; d=google.com; s=arc-20160816; b=rsv2ZLPUejiNFxAOi9e2hTofu2OML+/cPlqENK/bMlXNCww+fHTkXsqSaBA2fFQ7eJ a2wlVQlC8yNRBZbEdp3WKMi5r/Lk4aIdl1HOBahMsyK7lpRcG4eZWmDaA3YzGn/E4agA PR3X/7wUOBj+5ODbi18M/2PzVeFrQKr3W/crqyF5DnyaGVGt9gPWQrjZ/0yF9PbbRN2e 6B7mNqcusOSKUySmu+Rmw1hZApn9ihwR+Sj/kHHl1GNQGvYtzfPuaRfFapOv5Jp3LSY4 pNDQXx9SjEVMXK2MOJPhwpxGCyzkwRie+nJyycH+quMjwA1f0H+7WUG6Ey6G+2rrX7OM ltcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SrgVmLFNIiXz60UyzKRU9OO4QhY5ffv1afEFRrWoK98=; b=WrYbIew1Sa1qSM2KgZnw/2MrXbJfATnufuCy1IoJh+oezSKR/1Haj4OEl2Lci3jegy DZLKv6/3exaZQP2fEHOaODR1XPVr1ZWoZ9TSKTTZlFSE0UCsagKHaaumb7ne2pibGtyF y1WBAfNjUv9ZnuR8g4xtMMZDcNoxbuUAwGiSgSl0bLDbR9o0xXXDPVkiYDW7z/NkrWr2 aNLgZoWPYWlLrthjmYHB9hNbXg3ET9lzcR6VhyRaLsukRT5x6lpl3KE17mK1UIyZSwmj qgzYLzmoN8DMbvVGXKVGx7MzKwoeQgy0phrDkm/g6kR6ENjDD6+0Bw1dX2Hvi+ISu1fx klyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IshdjaxE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020a50eb41000000b004fd1ef9b95csi1386030edp.598.2023.04.06.08.26.16; Thu, 06 Apr 2023 08:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IshdjaxE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239642AbjDFPOb (ORCPT + 99 others); Thu, 6 Apr 2023 11:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237840AbjDFPOa (ORCPT ); Thu, 6 Apr 2023 11:14:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C9A319F; Thu, 6 Apr 2023 08:14:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D77EC643F1; Thu, 6 Apr 2023 15:13:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8F85C433EF; Thu, 6 Apr 2023 15:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680794038; bh=mTtbRnkeMKTbF2q4A4f9Ak2ifsvNdnsM0H92Nh3Qxmg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IshdjaxEfBw6XI54sB39NmKjwTpyvFhda4R5a9R4WhEJrRKbOcuMkJVaX6Os+K1S1 eCX/ECIQApw4njlgkWg8ELz5eoOG0qDBOKGbBHKOUssHQGSqyTLV+onmg3gniruIEf A4nNzd/MB6lr0oa+WsKQTLnLfv2iosl2w8rH32uW6vvRf/Oz1Va3inJDArw2RQrd+B 5kQ6FrfUv6pi+KGS5Y4MDqjLZ0YdqcmqrruWQ908FkxoTYEEd9HzAkJpsbxaCCoAiI xgkKdaGTXkD9uuYWC1nmP1kytL7y0ZW+M0fW3wG4Nd0SNLJEuS430SD6Xi6tK0jvD2 gzG5nGQRXtixQ== Date: Thu, 6 Apr 2023 17:13:54 +0200 From: Frederic Weisbecker To: Marco Elver Cc: Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Oleg Nesterov , "Eric W. Biederman" , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Dmitry Vyukov , kasan-dev@googlegroups.com Subject: Re: [PATCH v6 1/2] posix-timers: Prefer delivery of signals to the current thread Message-ID: References: <20230316123028.2890338-1-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le Thu, Apr 06, 2023 at 04:12:04PM +0200, Marco Elver a ?crit : > On Thu, 16 Mar 2023 at 13:31, Marco Elver wrote: > One last semi-gentle ping. ;-) > > 1. We're seeing that in some applications that use POSIX timers > heavily, but where the main thread is mostly idle, the main thread > receives a disproportional amount of the signals along with being > woken up constantly. This is bad, because the main thread usually > waits with the help of a futex or really long sleeps. Now the main > thread will steal time (to go back to sleep) from another thread that > could have instead just proceeded with whatever it was doing. > > 2. Delivering signals to random threads is currently way too > expensive. We need to resort to this crazy algorithm: 1) receive timer > signal, 2) check if main thread, 3) if main thread (which is likely), > pick a random thread and do tgkill. To find a random thread, iterate > /proc/self/task, but that's just abysmal for various reasons. Other > alternatives, like inherited task clock perf events are too expensive > as soon as we need to enable/disable the timers (does IPIs), and > maintaining O(#threads) timers is just as horrible. > > This patch solves both the above issues. > > We acknowledge the unfortunate situation of attributing this patch to > one clear subsystem and owner: it straddles into signal delivery and > POSIX timers territory, and perhaps some scheduling. The patch itself > only touches kernel/signal.c. > > If anyone has serious objections, please shout (soon'ish). Given the > patch has been reviewed by Oleg, and scrutinized by Dmitry and myself, > presumably we need to find a tree that currently takes kernel/signal.c > patches? > > Thanks! Thanks for the reminder! In the very unlikely case Thomas ignores this before the next merge window, I'll tentatively do a pull request to Linus. Thanks. > > -- Marco