Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2242522pxf; Sat, 20 Mar 2021 08:51:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhL/W4RkYXGGBOUqvwBUVnSis8L9uhJPYelduGnoWP/HoFEJ2Rq+B45defxDP3efp2xlU0 X-Received: by 2002:a05:6402:1c98:: with SMTP id cy24mr16130331edb.296.1616255501904; Sat, 20 Mar 2021 08:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616255501; cv=none; d=google.com; s=arc-20160816; b=kexWEjNL2pxRtks6cmRw4ucwKvQARJa9SYg4+NwJfTFMaOCfNps4/my5bAMHaW+nm1 BCMzmWLNRyBm5ZSQMnjgIuxvi0iEL1VantErwYZgzOQkVzErvlnGHI5lQdyBxeMH4rQX IvaKcdEhcMpx4//yZHhbDLSj0BbzwjaAO+67/d/USFnY2Gt15+2Vs0Z/t+pJcmHzTKT+ /Iopj6cQL7R/UL5g3ODUe1i29uvRuA7sd+BRU25zYdsMNMxeAUV08wpX6qTE5hXN2CB3 6/vqjzcdpJMGoxWk1QZ7PpnrrSL7DH4VAmhu+YGnZvaM51z0WuMrHfo6Ud+AUVS6+u2b zf1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zbIftbE/u+M6OpaoufTPcNdH56Tj34uXrx7w5JT/Y1E=; b=dDWtdxX/28xFUgxFUHNQ2TPmgDRqpWwZFvydDRyW3wyJMxKnrclbUWCSMFxzehQqDq ZbcFOviUHLA76PpFZonAvlMXOJ1smZJJuE9QLiCsV8sEcmHwq0KhtojQG+/eKiph3MAM cBk6eo0qDuflBxO8ek9ZStc8FWc52J6WZtev6ChXmR1nUDmMmNzeDpWEfbK7YjQmE8hh 5hooWVLtyVbZAwTOroc6tOhB5vkGpUdLi73sTndVoDGO1RFoFMcK8aoGleRncV7TaO7b n4wOOQkWz44bPTctwY8ElL+pXbHtss4ilAxGga+85oKPI6LbCRpVnc54uwBtfdiCncK7 4OFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=LyhUjltM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si7310748edz.247.2021.03.20.08.51.19; Sat, 20 Mar 2021 08:51:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=LyhUjltM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbhCTPsN (ORCPT + 99 others); Sat, 20 Mar 2021 11:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbhCTPsA (ORCPT ); Sat, 20 Mar 2021 11:48:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12680C061574 for ; Sat, 20 Mar 2021 08:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zbIftbE/u+M6OpaoufTPcNdH56Tj34uXrx7w5JT/Y1E=; b=LyhUjltMocKGlYzFZaWpwVKKMv ySLz6nUd3mia5MaCshd5GXoP4WBQA2w4mlmIuVtLlFlWTZvfzKQvnAl9xNTBgDaQMBpS2QtIcxMq0 uPq/1bPD6S/FXoav9lnU460MRrj7InICCK7W91FJPFzS7BHKdD2kSfW1EBybv0M7Uie4ZbDW4NcKw KrGjD19/Hoz4fvTOttiiLKvHVsa6YzsS2Ta/Ap188h7ACCJyMVIYznPid8Kgm5dj8cnJfS6mn0oUJ JZJKtWEzt9TLW/Q+cSRbBrRJANhc936jeq5g/y+P0PrOBASdavEQsH1Rfg3JaqqcyXNRsbYyfZV0D ShwF5NnQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lNdo9-005zlT-1B; Sat, 20 Mar 2021 15:46:33 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 350839864FF; Sat, 20 Mar 2021 16:46:32 +0100 (CET) Date: Sat, 20 Mar 2021 16:46:32 +0100 From: Peter Zijlstra To: "Joel Fernandes (Google)" Cc: Nishanth Aravamudan , Julien Desfossez , Tim Chen , Vineeth Pillai , Aaron Lu , Aubrey Li , tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, torvalds@linux-foundation.org, fweisbec@gmail.com, keescook@chromium.org, Phil Auld , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , vineeth@bitbyteword.org, Chen Yu , Christian Brauner , Agata Gruza , Antonio Gomez Iglesias , graf@amazon.com, konrad.wilk@oracle.com, dfaggioli@suse.com, rostedt@goodmis.org, benbjiang@tencent.com, Alexandre Chartre , James.Bottomley@hansenpartnership.com, OWeisse@umich.edu, Dhaval Giani , chris.hyser@oracle.com, Josh Don , Hao Luo , Tom Lendacky Subject: Re: [PATCH 2/6] sched: tagging interface for core scheduling Message-ID: <20210320154632.GZ4746@worktop.programming.kicks-ass.net> References: <20210319203253.3352417-1-joel@joelfernandes.org> <20210319203253.3352417-3-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210319203253.3352417-3-joel@joelfernandes.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 19, 2021 at 04:32:49PM -0400, Joel Fernandes (Google) wrote: > From: Josh Don > > Adds per-task and per-cgroup interfaces for specifying which tasks can > co-execute on adjacent SMT hyperthreads via core scheduling. > > The per-task interface hooks are implemented here, but are not currently > used. The following patch adds a prctl interface which then takes > advantage of these. > > The cgroup interface can be used to toggle a unique cookie value for all > descendent tasks, preventing these tasks from sharing with any others. > See Documentation/admin-guide/hw-vuln/core-scheduling.rst for a full > rundown. > > One important property of this interface is that neither the per-task > nor the per-cgroup setting overrides the other. For example, if two > tasks are in different cgroups, and one or both of the cgroups is tagged > using the per-cgroup interface, then these tasks cannot share, even if > they use the per-task interface to attempt to share with one another. > > The above is implemented by making the overall core scheduling cookie a > compound structure, containing both a task-level cookie and a > group-level cookie. Two tasks will only be allowed to share if all > fields of their respective cookies match. > > Core scheduler has extra overhead. Enable it only for machines with > more than one SMT hardware thread. Oh man.. I'd soooo hoped to first see the simple task interface and then see the cgroup patch on top of that... I'll see if I can flip them myself (on monday). > +#ifdef CONFIG_SCHED_CORE > +struct sched_core_cookie { > + unsigned long task_cookie; > + unsigned long group_cookie; > + > + /* A u64 representation of the cookie used only for display to > + * userspace. We avoid exposing the actual cookie contents, which > + * are kernel pointers. > + */ Tssk, invalid comment style that.. > + u64 userspace_id; > +}; > +static unsigned long sched_core_alloc_task_cookie(void) > +{ > + struct sched_core_task_cookie *ck = > + kmalloc(sizeof(struct sched_core_task_cookie), GFP_KERNEL); struct sched_core_task_cookie *ck = kmalloc(sizeof(*ck), GFP_KERNEL); Also, those type names are unfortunately long.. > +static void sched_core_get_task_cookie(unsigned long cookie) > +{ > + struct sched_core_task_cookie *ptr = > + (struct sched_core_task_cookie *)cookie; struct sched_core_task_cookie *ptr = (void *)cookie; Know your language and use it to avoid typing excessively long names :-)