From mboxrd@z Thu Jan 1 00:00:00 1970 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 B9ADBC001DE for ; Tue, 25 Jul 2023 10:12:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbjGYKMJ (ORCPT ); Tue, 25 Jul 2023 06:12:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjGYKMI (ORCPT ); Tue, 25 Jul 2023 06:12:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3185110DC for ; Tue, 25 Jul 2023 03:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690279839; 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: in-reply-to:in-reply-to:references:references; bh=qHJHNAQ/EaLrVgiClukNB6YD2cCwQOLa9+8g/RD5pIg=; b=AcaYPfHJ16TGfLNjf66r6cHTGb4PzGrZqR1pIY0MyfiGbf2e2Zo0O+ndGaILzMD4+meh9e hZazaQM+KeFl6CI3CphrFJafCHs3/a8aYJt/IGt8zY7pbNa0EmNWQBGeu/uzDXR8MBZ62t jDB0pSyIBK13gy8ZoNROt7kKhHVvHnA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-189-bl1ri7QHNwmYQJA2DqT-7A-1; Tue, 25 Jul 2023 06:10:36 -0400 X-MC-Unique: bl1ri7QHNwmYQJA2DqT-7A-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fbe590234aso31742625e9.1 for ; Tue, 25 Jul 2023 03:10:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690279835; x=1690884635; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qHJHNAQ/EaLrVgiClukNB6YD2cCwQOLa9+8g/RD5pIg=; b=IkVJ+DREV1o33BN/SSZWaKAmIGhm2LobXF1wMytX9KF5ztBY8DzKR4ZJtQ4v+rNRjV X5T6DoTV6M6BeQAAUYWzJGR9YfIkmbwnF/PJ+iAMX4itd98oF8GvNMTSSC9EcDnlMtvL tm7/tNEvB1iQlINVaul1VLTGIRf495/Va1SnOLsRDkXNZg6MJGr1Al9fiMWKplrND/NB vrVtrT5w4AvYLDFJ/uie5AzK88C60jICOXB/86gBW2M7shv8EbpjnuH0uqL8DtFPCAEk +HjNw9PuRNHhrtdBeDF3ycfGSr831X60rLvGwtm0+/g/Bdf7vgyEPDZDh3cxwDF9QV97 2i1Q== X-Gm-Message-State: ABy/qLZuoGVxv5WkAEo7yUhTNb15emdoUTYzd2Q80wbcxRGtyBiMjMgx IWudC7cXK3/tf0azKxoVHaY30XVl5ZJry+io7twBaQbUr1DkTVzrglMO5dRgaZh7FBLkl+IqJMy 4IalstuiJRww8ht5Y5UtW4+EIz6HKz5WC X-Received: by 2002:a7b:c3c8:0:b0:3fc:182:7eac with SMTP id t8-20020a7bc3c8000000b003fc01827eacmr9484390wmj.33.1690279835124; Tue, 25 Jul 2023 03:10:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBwe5grVle2BJoQfU1CdlrA5E008mXbdTKHKW2tEfZga9rph2myp9KegOF9DFTCjiBwJ8J/Q== X-Received: by 2002:a7b:c3c8:0:b0:3fc:182:7eac with SMTP id t8-20020a7bc3c8000000b003fc01827eacmr9484330wmj.33.1690279834786; Tue, 25 Jul 2023 03:10:34 -0700 (PDT) Received: from vschneid.remote.csb ([149.12.7.81]) by smtp.gmail.com with ESMTPSA id p1-20020a05600c204100b003fc17e8a1efsm15201059wmg.45.2023.07.25.03.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 03:10:34 -0700 (PDT) From: Valentin Schneider To: Frederic Weisbecker Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, x86@kernel.org, rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, Nicolas Saenz Julienne , Steven Rostedt , Masami Hiramatsu , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Josh Poimboeuf , Jason Baron , Kees Cook , Sami Tolvanen , Ard Biesheuvel , Nicholas Piggin , Juerg Haefliger , Nicolas Saenz Julienne , "Kirill A. Shutemov" , Nadav Amit , Dan Carpenter , Chuang Wang , Yang Jihong , Petr Mladek , "Jason A. Donenfeld" , Song Liu , Julian Pidancet , Tom Lendacky , Dionna Glaze , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: Re: [RFC PATCH v2 15/20] context-tracking: Introduce work deferral infrastructure In-Reply-To: References: <20230720163056.2564824-1-vschneid@redhat.com> <20230720163056.2564824-16-vschneid@redhat.com> Date: Tue, 25 Jul 2023 11:10:31 +0100 Message-ID: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org On 24/07/23 21:18, Frederic Weisbecker wrote: > On Mon, Jul 24, 2023 at 05:55:44PM +0100, Valentin Schneider wrote: >> I can make that a 'do {} while ()' instead to force at least one execution >> of the cmpxchg(). >> >> This is only about reducing the race window, right? If we're executing this >> just as the target CPU is about to enter userspace, we're going to be in >> racy territory anyway. Regardless, I'm happy to do that change. > > Right, it's only about narrowing down the race window. It probably don't matter > in practice, but it's one less thing to consider for the brain :-) > Ack > Also, why bothering with handling CONTEXT_IDLE? > I have reasons! I just swept them under the rug and didn't mention them :D Also looking at the config dependencies again I got it wrong, but nevertheless that means I get to ramble about it. With NO_HZ_IDLE, we get CONTEXT_TRACKING_IDLE, so we get these transitions: ct_idle_enter() ct_kernel_exit() ct_state_inc_clear_work() ct_idle_exit() ct_kernel_enter() ct_work_flush() Now, if we just make CONTEXT_TRACKING_WORK depend on CONTEXT_TRACKING_IDLE rather than CONTEXT_TRACKING_USER, we get to leverage the IPI deferral for NO_HZ_IDLE kernels - in other words, we get to keep idle CPUs idle longer. It's a completely different argument than reducing interference for NOHZ_FULL userspace applications and I should have at the very least mentioned it in the cover letter, but it's the exact same backing mechanism. Looking at it again, I'll probably make the CONTEXT_IDLE thing a separate patch with a proper changelog.