Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2756139rdh; Mon, 30 Oct 2023 06:58:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjGuTnAJGK/GqHtQmnpb422lNITVPPbZhHkybW8rhtX8EEdB0o/woytS68K2zX7JwvKPH0 X-Received: by 2002:a17:902:e5ce:b0:1cc:5730:ce55 with SMTP id u14-20020a170902e5ce00b001cc5730ce55mr1551219plf.66.1698674293123; Mon, 30 Oct 2023 06:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698674293; cv=none; d=google.com; s=arc-20160816; b=oRyUbUnlkL2qEsc29/DUriYgGf2nop6rExx03ZYm3xuHBuSJW59v5WNIolBeCzthKu KB664v7KEwRiz4c83D7dCtod2FhxwPoQZr0eUlvIxHgiYZqDxWogAHTmJsFUtocXKVAd XriDagg0yCgNw/2lscIaUBONm21Fq5BL1L4qIxGSQaS2OAOdOyBLS/QaW92dWJ428oMZ OlfgXpo6N6J57EHvmUX83wliRKgz2f02UT+ZcEI9qhbR0l4YId1w46X2mCbegWljWRjO tH+0QYSoHtVOrwZI1eSOq44JNLSBb07m9UvVQ3QRQQ7CQl4ID8g+05EC37v3ZxLqh/ia 7pcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=eja6aRiaD2ilx62BEkcPCk0tsOkkuif4qACFXAntnn0=; fh=FtWGlnqqdNaWYeoHYcUTjqCFSoyEMXwasmZosU8Dn4Y=; b=aT5Tj62HPQjVqPXcAeR4TLfEQa89OUeHPoQ8NhqJo2rIY298rPql/531FJ7rI8PteB B+QARbqIASAcBbjtZmD/rJ+PaxAgOWzlofNOeMOJ/rxe0gmZeCokz5ow8pYWJBOf5D5W Jb0g+/Dhm7xN6VYSaAdenNU9LOD+a5l//ifBOxuSdqdQP/yd9zDW2Ajc4AK3T/eMfJXl oZ0H+Iikklzgs9mt+SvvHUHZRxTXdpPNzyb9egVFFXepwo0vCndfHJn6ewmY9iYju6o5 hXsP0HXo+9qEcJEi2P9AXzqh8zzt6qmsp90RXT2vhgrjJnawpf+2BQvK7EHx9h9tSpSK 8A0w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u19-20020a170903309300b001ca4dd7b834si5039157plc.309.2023.10.30.06.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:58:13 -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; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5F0C480A1E00; Mon, 30 Oct 2023 06:58:10 -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 S232538AbjJ3N5z (ORCPT + 99 others); Mon, 30 Oct 2023 09:57:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232546AbjJ3NwL (ORCPT ); Mon, 30 Oct 2023 09:52:11 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9D04D3 for ; Mon, 30 Oct 2023 06:52:08 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 342C3C433C8; Mon, 30 Oct 2023 13:52:05 +0000 (UTC) Date: Mon, 30 Oct 2023 09:52:03 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: LKML , Thomas Gleixner , Ankur Arora , Linus Torvalds , 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, 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, Joel Fernandes , Youssef Esmat , Vineeth Pillai , Suleiman Souhlal , Ingo Molnar , Daniel Bristot de Oliveira , Mathieu Desnoyers Subject: Re: [POC][RFC][PATCH] sched: Extended Scheduler Time Slice Message-ID: <20231030095203.33325aee@gandalf.local.home> In-Reply-To: <20231030132949.GA38123@noisy.programming.kicks-ass.net> References: <20231025054219.1acaa3dd@gandalf.local.home> <20231025102952.GG37471@noisy.programming.kicks-ass.net> <20231025085434.35d5f9e0@gandalf.local.home> <20231025135545.GG31201@noisy.programming.kicks-ass.net> <20231025103105.5ec64b89@gandalf.local.home> <20231026084402.GK31411@noisy.programming.kicks-ass.net> <20231026091658.1dcf2106@gandalf.local.home> <20231030132949.GA38123@noisy.programming.kicks-ass.net> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=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]); Mon, 30 Oct 2023 06:58:10 -0700 (PDT) On Mon, 30 Oct 2023 14:29:49 +0100 Peter Zijlstra wrote: > On Thu, Oct 26, 2023 at 09:16:58AM -0400, Steven Rostedt wrote: > > > I said: > > > > If we are worried about abuse, we could even punish tasks that don't call > > sched_yield() by the time its extended time slice is taken. > > This is a user interface, ofcourse I'm worried about abuse. That's the > first thing you *should* think about. > > Userspace is out to get you -- must assume hostile. 100% agree! > > Notably, we were talking usec latencies in the Chrome thread, you're > adding 1000 usec latencies here (in the best case, delaying scheduling > until the next tick, 10000usec for the HZ=100 folks). This is quite > 'unfortunate'. > > On my very aged IVB-EP I can get 50us scheduling latencies on a good > day, on my brand spanking new SPR I can get 20us (more faster more > better etc..). > > Ideally we don't allow userspace to extend much (if any) beyond the > granularity already imposed by the kernel's preempt/IRQ-disable regions. > Sadly we don't have a self-measure of that around. > > So I had a poke at all this and ended up with the below. I still utterly > detest all this, but it appears to actually work -- although I don't > much see the improvement, the numbers are somewhat unstable. (I say it > works because I see the 'yield -- made it' trace_printk when I do it > right and the 'timeout -- force resched' when I do it 'wrong'. > > This thing works across the board and gives userspace 50usec, equal to > what the kernel already imposes on (on the IVB). > > I simply took a bit from the existing flags field, and userspace can use > BTR to test if the kernel cleared it -- in which case it needs yield > (and not any other syscall). > > Additinally doing a syscall with the bit set will SIGSEGV (when > DEBUG_RSEQ). > Thanks for looking into this even though you detest it ;-) Unfortunately, now that the merge window has opened (and someone reported a bug in my code from linux-next :-( ), I need to take a step back from this and may not be able to work on it again until plumbers. By then, I hope to have time to dig deeper into what you have done here. Thanks again Peter! -- Steve