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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E335DC433E3 for ; Sat, 20 Mar 2021 15:48:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A948461970 for ; Sat, 20 Mar 2021 15:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbhCTPsN (ORCPT ); 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 :-)