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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7701AC4167D for ; Mon, 30 Oct 2023 13:52:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E78626B01F2; Mon, 30 Oct 2023 09:52:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E292B6B01FE; Mon, 30 Oct 2023 09:52:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D17396B01FF; Mon, 30 Oct 2023 09:52:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C20CB6B01F2 for ; Mon, 30 Oct 2023 09:52:11 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 82CA31405C5 for ; Mon, 30 Oct 2023 13:52:11 +0000 (UTC) X-FDA: 81402266862.07.8637725 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id CFA381C001D for ; Mon, 30 Oct 2023 13:52:09 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of "SRS0=hW9q=GM=goodmis.org=rostedt@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=hW9q=GM=goodmis.org=rostedt@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698673929; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eja6aRiaD2ilx62BEkcPCk0tsOkkuif4qACFXAntnn0=; b=f+8g+MhImHuZyQo+lmtE86WZRgWWLDJlZdY/uA0ZggC8cvG5Xcx/SMmJ5rxAZvxek5/uwT ahUGBpgW7eB+Bg1uZzCEPmWSAOY/9qjiOSS1grhHRe4qyuofPsqNskepurGSYvvEBId6KF f3ph9b9R8nopovTgDnJkv62dRp9xWgU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of "SRS0=hW9q=GM=goodmis.org=rostedt@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=hW9q=GM=goodmis.org=rostedt@kernel.org" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698673929; a=rsa-sha256; cv=none; b=jR2jJegEL7j2SMx9AwsG3D2yZVREUsTu09lYv5HzJv0MNQAplsBnUMuLuDdPndfz7luAiP Cs0IPYSTfX5MYlZwjlNH2Ic0SHMFevoQnjZ9JPCCE1sy8FfsrLDjCQvWJsmT+CkM8ZKTSy ft7pujd/Lhn2KaWhRFB6nF9UeCOiG+k= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A996A60A6C; Mon, 30 Oct 2023 13:52:08 +0000 (UTC) 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-Rspam-User: X-Stat-Signature: or6kjagm3ng71oxfsekfkqsiyzabegqr X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CFA381C001D X-HE-Tag: 1698673929-963198 X-HE-Meta: U2FsdGVkX19Tj3bMuYtEos4HSj2PgBQJACZqUv23eXtyeyoWGj6tFh+7II55L2F52Q4llRlHtM9SBFiseKBFX+6EgMlWpCltQIDV5K5iR2x/x3ozXio2r0vAJ974XkZGrqrQ1+rRaOw3lU9HolraeeAPydSf1/K/M/hwYIAHpASfTOfJJdvp6SpivjuiNepbGwoveanIKEQ7E1oHQNuUArLdJG7Vf7TB4un9VzDct/xWOWRdcYrKCxrW1s3sZXRxrrj/NYV3GCyPAlywK5oGB6EQHzBCsxaD96XDC/kzI2ETDhkQrV+Ih9B8zCRNxz88U4jnQgEJ5WM7F3rGmAPbnWG691mg0Q77uKgIpfQjcqetGUgzkK8XfAqdy4GsK+wWdXFZ8PvklW4KfQpT0SM/my69mYgP8l1kkPWOPjGQEKvJZPe0HnMt78AN5iGSpXKsCM5r4aEl/nk9bUUpGB0VnHjGC9SEozQbyGEpXX4BEaKXZDMlCcwgf6bG6m3cApZ4b93NjA33uPnEcX3dmkdtP6+MluZ1mGvfncmqZI4bomgJSr8u4ys0wnoOTPw9h4XihuQIiYqo7bCFa4bEnzQBbpFT2mSq9z48nXr4CFUoeENnnJKP/juy2R58KeRwpZhfiKOOyUHOgFaiyDwkc3uOs7K6fA+dZzDL4oK6lkxCLFjEQdK3Ppo0mrjxvuDf6lI3KYfD8yJ6pBv9ganX+u8Afs4iXjVosIeS+Urdk7BS+ibIDxhbgTb/dfCsLNdPHvfoBpnnuvDyH15N4OMQy+6yACl3l4RfIU2ICNHq81A74ZBLjLRo+CH5+k4Spe6JdkHNceq84OkuXQL6YvsTyRPtE/oF2ONth7uT2xWYyGOkBL4Kg6Eprn/mNrS7FC+CkG5CiXagmuiuV1+TGuODHCk4CbRbEyUanD0f3sDkkOklS9KyEb99BzQ3jKVZ6L4N7aqni1rJq/qUUSkieWvWR0G kFY3BVW2 Freli671qhf5l0tEiPTVX72pvvWqXGMfYr0npfS/22phz2oR/4pCQ2uFQoaQoF/MWiVrT1LQLIral8ESVq3JEgbXhZuNVCuhEX9blSyT6rCBFTj2eKs0O5V2UFCXw1HtLFv1x/HuaxEH/U2b3f96VmH8+NZp7lobc5XYGI3v6Fsz4aG9ooo8ZpXZsPvMdgBaGknBsIGUewyub/XG0DNqMA3A1+sLmMWtrga1MIh6/1RKxd07QulbpjzOnyYAUrYi4aM4ZyStmNMMam3mA04lGFSc5bNaVf+tBazyxN1i3jyoXGQRr911z3QQgCQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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