Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE550C54EAA for ; Fri, 27 Jan 2023 06:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232033AbjA0G7J (ORCPT ); Fri, 27 Jan 2023 01:59:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231767AbjA0G7G (ORCPT ); Fri, 27 Jan 2023 01:59:06 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEDA029177 for ; Thu, 26 Jan 2023 22:58:53 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id f34so6688512lfv.10 for ; Thu, 26 Jan 2023 22:58:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8WCgizZfT3yoGO+GYCgj+PgReZhP+Yfp87mpDwfRLzU=; b=kFeTVN5wS6wRKITnxJnZGjfSRmIkkSHlKETp2oVwFVmyIUgbeqmf7NiMIl+w4U5tqw xo0T172KRnJN1jFWZenIFTQhbtKB6KDUP85P7DqFZKE3f2Nr1LKAuU8gBX5fVbzDqea3 2sfCqsY51z4RLNLheVTCC2jm9a1zz2Dp8hV0A55SQvFEa/QvneCSsh0ExkwTcCr5ApXb H2IYhqlmJdEZ8F/TmBetzxmK/UjdTeVHI6/DoCaVOdyuPnh5kT9oJDjrvbCV/+w0+7Rq A6p8YQOcVHQJt58Mf4sNdnv9ETszlw43Z1X8oY1wPCBoxqzJUOLBzkAEjEGosDSdCAhw Y8sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8WCgizZfT3yoGO+GYCgj+PgReZhP+Yfp87mpDwfRLzU=; b=M49huxV1bi9alR744uiITcdqRDYUHbaSviQzGzABVWg5vwfdSuNZQw0l3JzyDtyYKi /0pBoyotdVoavNJIdpxZwV/s/zU35f2Hltz+EDCp8nOesESzobqVXy7r5utKcKfYlSiH wlT+vW8CjtzTf37otqTeEyW01hPJntDSUh6DmhBsWWrpEmpecr6xmu6NCqJAioYS1zjA hUI8DrTRAUMKJdeoFyjy3Lg9TmkdWzJWVntuZnzI0xWZVjMNDAMnZo3LBmuqSAUvjnOW I4MJLckNvk2w/bfZ8lBjnq+6HT9rvGpNfd6phGF11OcTVeiKS6qW96WRMuv9qjvXNzqC k0rQ== X-Gm-Message-State: AFqh2kpn9mYcx/wCIFkpTEFd/heKYeVLH589YXW5Dvqi3YMlePp1JH87 kJmW4dElfbKLfioAdOaJxU2sN7M43UmwYio7MuTFSfncVKLvu1eMK6w= X-Google-Smtp-Source: AMrXdXuDqJhLflIXt8tmkzM/wowN80kk9vheLxAF/PK+ri7IEWG5zqq8M1NihxnpVDQnoFnxJgulmoWXrCjmfejm7sI= X-Received: by 2002:a05:6512:401b:b0:4cc:7222:74f5 with SMTP id br27-20020a056512401b00b004cc722274f5mr4523511lfb.371.1674802731723; Thu, 26 Jan 2023 22:58:51 -0800 (PST) MIME-Version: 1.0 References: <20230126105128.2249938-1-dvyukov@google.com> <20230126154118.2393850-1-dvyukov@google.com> <87o7qlgjce.ffs@tglx> In-Reply-To: <87o7qlgjce.ffs@tglx> From: Dmitry Vyukov Date: Fri, 27 Jan 2023 07:58:39 +0100 Message-ID: Subject: Re: [PATCH v4] posix-timers: Prefer delivery of signals to the current thread To: Thomas Gleixner Cc: Marco Elver , oleg@redhat.com, linux-kernel@vger.kernel.org, "Eric W . Biederman" , Frederic Weisbecker Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Jan 2023 at 20:57, Thomas Gleixner wrote: > > On Thu, Jan 26 2023 at 18:51, Marco Elver wrote: > > On Thu, 26 Jan 2023 at 16:41, Dmitry Vyukov wrote: > >> > >> Prefer to deliver signals to the current thread if SIGEV_THREAD_ID > >> is not set. We used to prefer the main thread, but delivering > >> to the current thread is both faster, and allows to sample actual thread > >> activity for CLOCK_PROCESS_CPUTIME_ID timers, and does not change > >> the semantics (since we queue into shared_pending, all thread may > >> receive the signal in both cases). > > > > Reviewed-by: Marco Elver > > > > Nice - and and given the test, hopefully this behaviour won't regress in future. > > The test does not tell much. It just waits until each thread got a > signal once, which can take quite a while. It does not tell about the > distribution of the signals, which can be completely randomly skewed > towards a few threads. > > Also for real world use cases where you have multiple threads with > different periods and runtime per period I have a hard time to > understand how that signal measures anything useful. > > The most time consuming thread might actually trigger rarely while other > short threads end up being the ones which cause the timer to fire. > > What's the usefulness of this information? > > Thanks, > > tglx Hi Thomas, Our goal is to sample what threads are doing in production with low frequency and low overhead. We did not find any reasonable existing way of doing it on Linux today, as outlined in the RFC version of the patch (other solutions are either much more complex and/or incur higher memory and/or CPU overheads): https://lore.kernel.org/all/20221216171807.760147-1-dvyukov@google.com/ This sampling does not need to be 100% precise as CPU profilers would require, getting high precision generally requires more complexity and overheads. The accent is on use in production and low overhead. Consider we sample with O(seconds) interval, so some activities can still be unsampled whatever we do here (if they take