Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp871613rdb; Tue, 19 Sep 2023 12:40:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkRIhZ0TGFEcQitoPiJwcWYvUl9aRVkjUGJrtK+f9JZpjFS8BSMY+7A1g4vCtMJHLyVFQH X-Received: by 2002:a17:90a:b901:b0:274:8be8:f767 with SMTP id p1-20020a17090ab90100b002748be8f767mr663919pjr.15.1695152440569; Tue, 19 Sep 2023 12:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695152440; cv=none; d=google.com; s=arc-20160816; b=tIRPYwB3WX5CK8qVdDQxM5j95nhMp30SDC1ZMoRoA7X33ZH2fOv+DnbHO6U/GGmbwb F/ks20Mi/gqL5u9aZ9dIWPd1s9sE1PyrxOqFLV3MvfFT+hoTE62jRAZG2tRm5K3yX+pg JqSsmXPWOBEVAu29wy7BSbh+UfXpyVeAhQd7aPKD+yiOG5RJsTPyEQyz/n07wtN17aZ9 3gCWnxcV74XTcFta7ybWchTwGW7opRgpN+bZFyCVk2+N9lmB0M6bnNKw3+iBR7hGfk4K ceffIAhDqVoPnwqEvXqV68bq0V9/y7ePROB1kUIEKuxAaoQ80Yozw74dzy1JoLtuowEe R9/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=F6HJIRD4PyaX4+pUjqGdadn05E3sV+30VO4ObkBi4tA=; fh=fEr0y4muKx+0kEP1Gxp/amYhcVYQgN93BMFDjjl2RSs=; b=y28zAqk7rKzDEGbaHIe7poYDtF0oCzHQYqXqyg43tQhf7CzXaDUAyif0CAVoFPEbRA K0WOr8d+ojk2HHymY9i2a84Tu6Bog4sba33VLouy6ByANCvD5Nulf4prwKRR5O+L0W5g 5vHF/5nDK4YmCD1bt8A5B+AC0Qh8Xm/4b+7NCD1kESCjdyWp4JY9QfFSB48MtVBu1zkl Y36v3Xd9Ps52O+RwsiIhu6UpxwwdPRsfX7etaWGPqQdi9RQNjMugbY0dWAaLb8x/FbDW nk02EhHzmA0qaJTvUkk5/Maf2Ghl0j6vTda64RMWv/QGF1XKRj+uNOOWUd3Sal6RNY3W D8qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=INe3beAV; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u13-20020a17090ae00d00b00274ac0df61bsi7290732pjy.122.2023.09.19.12.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 12:40:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=INe3beAV; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EFEE4825F151; Tue, 19 Sep 2023 06:44:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232623AbjISNoe (ORCPT + 99 others); Tue, 19 Sep 2023 09:44:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232474AbjISNoL (ORCPT ); Tue, 19 Sep 2023 09:44:11 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEDE11738 for ; Tue, 19 Sep 2023 06:43:31 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695131008; 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=F6HJIRD4PyaX4+pUjqGdadn05E3sV+30VO4ObkBi4tA=; b=INe3beAVUGy7X1rPg0jVCOBApZrBIols9AlzAGXgMjPV257Vi8uogUm7f+1Kqn1dxss5w3 Qd0i8v4W/KraIOm+0T08nhMyYiNAOuSdipyvpsH3wNCmEDgs6EpI6kzYy1p6edIzt5fRsM P3qq2iMbd4rnkAcfTNo2E4Mimdyz7ezivL28bRK930bJKJgeepHh1qRS0BwzW2gGyPjpzO FsKZToH8pgbrfbDvRRO4VZRnQlJziFXI2AOfdGkEzVhRgYrR7LTr5h7nXciBgTG+k58Etx Ndd3xkgzvmITTLqDMaD3fS+b1tdLInm1s1/Jc1ttwJ+JYsXw7NcqZLonBfCbWQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695131008; 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=F6HJIRD4PyaX4+pUjqGdadn05E3sV+30VO4ObkBi4tA=; b=tqREo84zIB2g7/8J6CTjDIfHTI+ZuUEpff2uM/m8NQcbyKurWmVLCLHVVCMc9TsZfuSA/a /Stk4hnv9k0JS6Bw== To: Ingo Molnar , Linus Torvalds Cc: Peter Zijlstra , Ankur Arora , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, akpm@linux-foundation.org, luto@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, willy@infradead.org, mgorman@suse.de, rostedt@goodmis.org, jon.grimm@amd.com, bharata@amd.com, raghavendra.kt@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, jgross@suse.com, andrew.cooper3@citrix.com Subject: Re: [PATCH v2 7/9] sched: define TIF_ALLOW_RESCHED In-Reply-To: References: <87edj64rj1.fsf@oracle.com> <87zg1u1h5t.fsf@oracle.com> <20230911150410.GC9098@noisy.programming.kicks-ass.net> <87h6o01w1a.fsf@oracle.com> <20230912082606.GB35261@noisy.programming.kicks-ass.net> <87cyyfxd4k.ffs@tglx> Date: Tue, 19 Sep 2023 15:43:27 +0200 Message-ID: <87fs3awa68.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 19 Sep 2023 06:44:44 -0700 (PDT) On Tue, Sep 19 2023 at 10:43, Ingo Molnar wrote: > * Ingo Molnar wrote: > Ie. a modern scheduler might have mooted much of this change: > > 4542057e18ca ("mm: avoid 'might_sleep()' in get_mmap_lock_carefully()") > > ... because now we'll only reschedule on timeslice exhaustion, or if a task > comes in with a big deadline deficit. > > And even the deadline-deficit wakeup preemption can be turned off further > with: > > $ echo NO_WAKEUP_PREEMPTION > /debug/sched/features > > And we are considering making that the default behavior for same-prio tasks > - basically turn same-prio SCHED_OTHER tasks into SCHED_BATCH - which > should be quite similar to what NEED_RESCHED_LAZY achieves on -rt. I don't think that you can get rid of NEED_RESCHED_LAZY for !RT because there is a clear advantage of having the return to user preemption point. It spares to have the kernel/user transition just to get the task back via the timeslice interrupt. I experimented with that on RT and the result was definitely worse. We surely can revisit that, but I'd really start with the straight forward mappable LAZY bit approach and if experimentation turns out to provide good enough results by not setting that bit at all, then we still can do so without changing anything except the core scheduler decision logic. It's again a cheap thing due to the way how the return to user TIF handling works: ti_work = read_thread_flags(); if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK)) ti_work = exit_to_user_mode_loop(regs, ti_work); TIF_LAZY_RESCHED is part of EXIT_TO_USER_MODE_WORK, so the non-work case does not become more expensive than today. If any of the bits is set, then the slowpath wont get measurably different performance whether the bit is evaluated or not in exit_to_user_mode_loop(). As we really want TIF_LAZY_RESCHED for RT, we just keep all of this consistent in terms of code and purely a scheduler decision whether it utilizes it or not. As a consequence PREEMPT_RT is not longer special in that regard and the main RT difference becomes the lock substitution and forced interrupt threading. For the magic 'spare me the extra conditional' optimization of exit_to_user_mode_loop() if LAZY can be optimized out for !RT because the scheduler is sooo clever (which I doubt), we can just use the same approach as for other TIF bits and define them to 0 :) So lets start consistent and optimize on top if really required. Thanks, tglx